/* ===========================================================================
   Epoch Converter — tool layer.

   base.css is loaded first and owns the reset, shell, typography, forms,
   buttons, chips, tables, FAQ and layout. Everything below is either the
   tool's accent or a control this tool alone has.
   ======================================================================== */

/* ------------------------------------------------------------- accent --- */
/* amber. Dark first, light overridden — same order as base.css.
   #fbbf24 on --bg 11.3:1 / on --surface 10.5:1
   #a94e08 on --bg  5.6:1 / on --surface  5.6:1, and 4.6:1 on --accent-dim,
   so the active nav item and the active segment still clear AA. */

:root {
  --accent: #fbbf24;
  --accent-dim: rgba(251, 191, 36, 0.14);
  /* native widgets (radio dots, the select popup, scrollbars) follow the
     page, otherwise unchecked radios render as bright white discs on the
     charcoal surface */
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --accent: #a94e08;
    --accent-dim: rgba(169, 78, 8, 0.10);
    color-scheme: light;
  }
}

/* --------------------------------------------------------- legibility --- */
/* base.css colours the small mono labels with --text-faint. Measured, that
   is 3.95:1 (dark) and 3.73:1 (light) at 11px — under AA for small text.
   --text-dim keeps the same hierarchy and measures 7.6:1 / 6.8:1.
   Colour only; everything else about these rules stays base's.
   Worth lifting into base.css — it affects all five tools equally. */

.eyebrow, .field-label, legend, .stat-label,
th, .site-nav a.nav-up { color: var(--text-dim); }

/* -------------------------------------------------------------- shell --- */

.narrow { max-width: 48rem; }

/* panel headings are card titles, not section headings */
.panel > :first-child { margin-top: 0; }
.panel > h2 { font-size: 1.125rem; }

.tool-bay > * + * { margin-top: 1.15rem; }

/* body lists — base.css only styles .prose lists */
main ul:not(.tiles), main ol { margin: 0 0 1.1em; padding-left: 1.25em; }
main li { margin-bottom: 0.4em; }

/* ----------------------------------------------------------- controls --- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.75rem;
}
.controls .field { min-width: 0; }
.controls .field.grow { flex: 1 1 20rem; }

/* seconds / milliseconds — a segmented control built out of .chip */
.radios { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.radios label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.78125rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.radios label:hover { color: var(--text); border-color: var(--line-strong); }
.radios input { flex: 0 0 auto; width: 0.85rem; height: 0.85rem; margin: 0; accent-color: var(--accent); }
.radios label:has(input:checked) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}
.radios label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.chips { margin-top: 0.75rem; }

/* the small ghost copy button that sits beside a value */
.mini {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}
.mini:hover { color: var(--text); border-color: var(--line-strong); }
.mini.is-copied { color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------- inputs --- */

#ts-input {
  font-family: var(--mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  padding: 0.6rem 0.7rem;
}

textarea {
  font-family: var(--mono);
  resize: vertical;
  min-height: 8rem;
  line-height: 1.55;
}

.dt-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}
@media (min-width: 40rem) {
  .dt-fields { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.dt-fields input {
  text-align: center;
  font-family: var(--mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  padding-inline: 0.4rem;
  /* the native spinners steal enough width to clip a four-digit year */
  -moz-appearance: textfield;
  appearance: textfield;
}
.dt-fields input::-webkit-outer-spin-button,
.dt-fields input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --------------------------------------------------- readouts / clock --- */
/* The live counter is the signature element: instrument wells holding
   monospace, tabular, accent-coloured numbers under a mono label. */

.clock {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 34rem) {
  .clock { grid-template-columns: 1fr 1fr; }
}

/* .big-out also appears inside a half-width panel, so it sizes off its own
   container rather than the viewport */
.big-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 0.75rem;
}

.clock-cell, .big-out > div {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
}

.clock-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.clock-value output {
  min-width: 0;
  font-family: var(--mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  overflow-wrap: anywhere;
}

/* the two ticking counters carry the page */
#now-seconds, #now-millis {
  font-size: clamp(1.5rem, 1.05rem + 1.9vw, 2.1rem);
}

.clock-sub { margin: 0.9rem 0 0; font-size: 0.875rem; color: var(--text-dim); }

/* ------------------------------------------------------------ results --- */

.results { margin: 1.15rem 0 0; }

.results .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 30rem) {
  .results .row { grid-template-columns: 8.5rem minmax(0, 1fr); align-items: baseline; }
}

.results dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.results dd { display: flex; align-items: center; gap: 0.5rem; min-width: 0; margin: 0; }

/* base.css gives inline <code> a pill; in result rows and data tables the
   value is the content, so it is shown raw. The :not() matches base's own
   specificity so this actually wins. */
.results dd code,
td code:not(pre code) {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  overflow-wrap: anywhere;
}
.results dd code { font-size: 0.9375rem; }

/* first row is the headline answer */
.results .row:first-child dd code {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

/* detected unit: .badge in base supplies the shape */
.detect { margin: 0.7rem 0 0; color: var(--accent); background: var(--accent-dim); }
.detect:empty { display: none; }

.hint { margin: 0.7rem 0 0; font-size: 0.875rem; color: var(--text-dim); }

/* -------------------------------------------------------------- table --- */

.table-scroll { margin-top: 1rem; }
/* inside a panel the full-bleed gutter trick would break out of the card */
.panel > .table-scroll { margin-inline: 0; padding-inline: 0; }

caption {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: 0.6rem;
}

td code { white-space: nowrap; }
tr.bad td { color: var(--err); }
tr.bad td code { color: var(--text-dim); }

/* ------------------------------------------------------------ content --- */

.example, .callout {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: clamp(0.95rem, 3vw, 1.35rem);
  margin-bottom: 1.15rem;
}
.callout { background: var(--bg-sunk); }
.example > :first-child, .callout > :first-child { margin-top: 0; }
.example > :last-child, .callout > :last-child { margin-bottom: 0; }

details .answer > :last-child { margin-bottom: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 0.85rem;
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}
.tiles li { margin: 0; }
.tiles a {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: border-color 0.12s ease;
}
.tiles a:hover { border-color: var(--accent); }
.tiles strong {
  display: block;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

/* ------------------------------------------------------------ utility --- */

[hidden] { display: none !important; }
.mt0 { margin-top: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
