/* Epoch Tool
   Direction: a precision instrument. Deep marine band with a seconds ruler,
   brass for the moving part, pale harbour-mist workspace beneath. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Spline Sans Mono";
  src: url("/fonts/spline-sans-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --mist: #e6edf1;
  --paper: #fafcfd;
  --well: #eef3f6;
  --marine: #0d2b3e;
  --marine-2: #16405a;
  --brass: #c8922e;
  --brass-ink: #7a5412;
  --lagoon: #1e7f86;
  --brick: #b23a2e;
  --ink: #12222e;
  --muted: #53677a;
  --line: #cfdbe3;
  --on-marine: #e9f1f5;
  --on-marine-muted: #9db6c6;

  --sans: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --focus: 0 0 0 3px rgba(30, 127, 134, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --mist: #091a26;
    --paper: #10283a;
    --well: #0c2030;
    --marine: #06141e;
    --marine-2: #0f3047;
    --brass: #e0ad4d;
    --brass-ink: #f0c877;
    --lagoon: #4cc0c8;
    --brick: #ff8a7d;
    --ink: #e3ecf1;
    --muted: #93aabb;
    --line: #234259;
    --focus: 0 0 0 3px rgba(76, 192, 200, 0.5);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

.wrap { width: min(1080px, 100% - 2rem); margin-inline: auto; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brass);
  color: #1b1405;
  padding: 0.6rem 1rem;
  z-index: 10;
  border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

:focus-visible { outline: none; box-shadow: var(--focus); }

/* ------------------------------ Clock band ------------------------------ */

.band {
  background: var(--marine);
  color: var(--on-marine);
  padding: 1.75rem 0 2.25rem;
  border-bottom: 4px solid var(--brass);
}
.brand { margin: 0 0 0.25rem; font-weight: 600; color: var(--on-marine-muted); letter-spacing: 0.01em; }
.band h1 {
  margin: 0 0 1.75rem;
  font-size: clamp(1.35rem, 2.4vw + 0.8rem, 2rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.015em;
  max-width: 28ch;
}

.now { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 2.25rem; align-items: end; }

.now-label { margin: 0; font-size: 0.9rem; color: var(--on-marine-muted); }
.now-seconds {
  margin: 0.15rem 0 0.9rem;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(2.6rem, 9vw, 5.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  overflow-wrap: anywhere;
}
.now-ms { margin: 0.65rem 0 0; font-family: var(--mono); font-size: 0.95rem; color: var(--on-marine-muted); font-variant-numeric: tabular-nums; }
.now-ms span { color: var(--on-marine); }

/* Seconds ruler: one tick per second of the current minute */
.ruler { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.ruler i {
  flex: 1;
  height: 10px;
  background: var(--marine-2);
  border-radius: 1px;
}
.ruler i:nth-child(5n + 1) { height: 16px; }
.ruler i.on { background: var(--brass); }
.ruler i.now-tick { height: 26px; background: #fff; }

.now-times { display: grid; gap: 0.9rem; }
.now-time { display: grid; grid-template-columns: 1fr auto; column-gap: 0.75rem; align-items: center; }
.now-time .now-label { grid-column: 1 / -1; }
.now-value { margin: 0; font-family: var(--mono); font-size: 0.95rem; color: var(--on-marine); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.now-copy-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* -------------------------------- Buttons -------------------------------- */

button, select, input, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-weight: 560;
  line-height: 1.2;
  transition: border-color 0.12s, background-color 0.12s;
}
button:hover { border-color: var(--lagoon); }
button:active { transform: translateY(1px); }

button.primary { background: var(--marine); color: #fff; border-color: var(--marine); }
button.primary:hover { background: var(--marine-2); border-color: var(--marine-2); }
@media (prefers-color-scheme: dark) {
  button.primary { background: var(--brass); color: #1b1405; border-color: var(--brass); }
  button.primary:hover { background: var(--brass-ink); border-color: var(--brass-ink); color: #1b1405; }
}

button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--ink); border-color: var(--line); }

.band button.copy {
  background: transparent;
  color: var(--on-marine);
  border-color: var(--marine-2);
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}
.band button.copy:hover { border-color: var(--brass); }

button.copy { padding: 0.28rem 0.65rem; font-size: 0.82rem; border-radius: 4px; white-space: nowrap; }
button.copy.done { border-color: var(--lagoon); color: var(--lagoon); }
.band button.copy.done { color: var(--brass); border-color: var(--brass); }

.chip { border-radius: 999px; padding: 0.35rem 0.8rem; font-size: 0.88rem; font-weight: 500; background: var(--well); }
.presets { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; margin-left: 0.5rem; }

/* ---------------------------------- Tabs ---------------------------------- */

main { padding-block: 2rem 1rem; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tabs button {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  padding: 0.75rem 1.1rem;
  color: var(--muted);
  font-size: 1.02rem;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); font-weight: 650; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 1.75rem clamp(1rem, 3vw, 2rem) 2rem;
}
.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 0.25rem; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; }
.lede { margin: 0 0 1.4rem; color: var(--muted); max-width: 62ch; }

/* --------------------------------- Forms --------------------------------- */

.field { display: grid; gap: 0.3rem; min-width: 0; }
.field.grow { flex: 1 1 260px; }
label, legend { font-size: 0.92rem; font-weight: 560; color: var(--ink); }

input[type="text"], input[type="number"], input[type="date"], input[type="time"], select {
  width: 100%;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.6rem 0.7rem;
  min-height: 2.7rem;
}
input[type="text"], input[type="number"] { font-family: var(--mono); font-size: 0.98rem; }
input:hover, select:hover { border-color: var(--lagoon); }
input:focus, select:focus { outline: none; border-color: var(--lagoon); box-shadow: var(--focus); }
::placeholder { color: var(--muted); opacity: 0.75; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-grid.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.25rem; }

fieldset.segment {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  margin: 1rem 0;
  overflow: hidden;
  background: var(--well);
}
fieldset.segment legend { padding: 0; float: left; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label { padding: 0.55rem 1.4rem; cursor: pointer; color: var(--muted); }
.segment input:checked + label { background: var(--marine); color: #fff; }
@media (prefers-color-scheme: dark) { .segment input:checked + label { background: var(--brass); color: #1b1405; } }
.segment input:focus-visible + label { box-shadow: inset var(--focus); }

.error {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid var(--brick);
  background: var(--well);
  color: var(--brick);
  font-weight: 540;
  border-radius: 0 4px 4px 0;
}
.error[hidden] { display: none; }

.divider { border: 0; border-top: 1px solid var(--line); margin: 2.25rem 0; }

/* -------------------------------- Results -------------------------------- */

.results { margin-top: 1.5rem; }
.results:empty { display: none; }

.answer {
  border-left: 4px solid var(--brass);
  padding: 0.2rem 0 0.2rem 1rem;
  margin-bottom: 1.1rem;
}
.answer .small { margin: 0; color: var(--muted); font-size: 0.9rem; }
.answer .big {
  margin: 0.1rem 0 0;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.1rem, 2.6vw, 1.55rem);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

dl.rows { margin: 0; border-top: 1px solid var(--line); }
dl.rows .row {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
dl.rows dt { color: var(--muted); font-size: 0.92rem; }
dl.rows dd { margin: 0; font-family: var(--mono); font-size: 0.93rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.note { margin: 0.9rem 0 0; font-size: 0.88rem; color: var(--muted); }

/* ---------------------------------- FAQ ---------------------------------- */

.faq { margin-top: 3rem; max-width: 70ch; }
.faq h2 { font-size: 1.35rem; margin: 0 0 0.75rem; font-weight: 650; }
.faq details { border-top: 1px solid var(--line); padding: 0.85rem 0; }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); color: var(--brass-ink); transition: transform 0.15s; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0.6rem 0 0; color: var(--muted); }

.foot { padding: 1.5rem 0 3rem; color: var(--muted); font-size: 0.88rem; }
.foot p { margin: 0; max-width: 70ch; }

/* --------------------------------- Toast --------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 140%);
  background: var(--marine);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--brass);
  transition: transform 0.18s ease, opacity 0.18s ease, visibility 0.18s;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 20;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 860px) {
  .now { grid-template-columns: 1fr; gap: 1.5rem; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  dl.rows .row { grid-template-columns: minmax(0, 1fr) auto; }
  dl.rows dt { grid-column: 1 / -1; }
  .form-grid.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .presets { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
