/*
 * index.css: components that exist only on the front page.
 *
 * Kept out of site.css because nothing here is reused by the sixteen era pages:
 * the proportional deep-time column, the survival-band legend, and the ranked
 * table. Loading it only from index.html keeps the era pages' CSS honest.
 *
 * The central idea of this page is the proportional column: each era's height is
 * its real share of the 4.54 Gyr, so the first four eras physically occupy 88%
 * of the scroll. The argument is made by the layout, not by the copy.
 *
 * Band colours encode the survival regime and are the only place in the project
 * where colour carries meaning rather than mood. They are shared with the ranked
 * table below the column so the two read as one scale.
 *
 * Read alongside: index.html (markup + the render loop), assets/data.js (source
 * of the durations), assets/site.css (typography and shell this builds on).
 */

/* Survival bands: an ORDINAL ramp, not a rainbow.
   These are ordered severity tiers, and the previous red/orange/amber/green/blue
   set failed on that: weeks-orange and months-amber measured only dE 11.5 apart
   under normal vision, against a floor of 15. That was not a bad pick, it was
   structural: a severity order forces hue-neighbours to sit adjacent, and no
   re-ordering or re-stepping of five hues can clear the gate.
   One hue with monotone lightness solves it and does something the rainbow never
   did: the ordering is legible in the colour itself. Intensity carries danger, so
   the deepest red is 'you die in a minute' and the palest is 'indefinite'.
   Validated as an ordinal ramp against this surface: monotone L, every adjacent
   gap over 0.06, single hue within 5 degrees, 3.91:1 minimum contrast as marks. */
.band-minutes    { --band: #c04339; }
.band-weeks      { --band: #e05f51; }
.band-months     { --band: #f18d7e; }
.band-years      { --band: #fabbb0; }
.band-indefinite { --band: #ffe4de; }

/* A reusable swatch. Text no longer wears the band colour anywhere: a coloured
   mark beside the words carries identity instead. That is the data-viz rule, and
   it is also why the palette was over-constrained before: requiring all five to
   be legible as small text left only hue to separate them. */
.swatch::before {
  content: '';
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  border-radius: 2px;
  background: var(--band, var(--ink-faint));
  margin-right: 0.5em;
}

/* ---- headline stat ---- */
.stat {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  background: var(--rule);
  border-block: 1px solid var(--rule);
  margin-top: clamp(2.5rem, 6vw, 4rem);
}
.stat__cell { background: var(--bg); padding: 1.6rem 1.5rem; }
.stat__n {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.6rem, 5vw, 4rem);
  line-height: 0.85;
  color: var(--ink);
}
.stat__k {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 0.9rem;
  line-height: 1.6;
  display: block;
}

/* ---- chart promo ----
   A text link to the chart page kept getting lost in the surrounding prose, so
   this is a full-width block carrying the actual oxygen curve. The sparkline is
   the affordance: it says "chart" before the words do. */
.promo {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 42%);
  align-items: stretch;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  transition: border-color 200ms;
}
.promo:hover { border-color: var(--accent-2); }
@media (max-width: 820px) { .promo { grid-template-columns: 1fr; } }

.promo__body { background: var(--bg); padding: 2rem 1.9rem 1.9rem; display: flex; flex-direction: column; gap: 0.9rem; }
.promo__title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.005em;
}
.promo__lede { font-size: 1.02rem; line-height: 1.6; color: var(--ink-dim); max-width: 52ch; }
.promo__cta {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-top: auto;
  padding-top: 0.6rem;
}
.promo__cta::after { content: ' →'; }
.promo:hover .promo__cta { color: var(--ink); }

.promo__spark { background: var(--bg-raise); padding: 1.9rem; display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.promo__spark svg { width: 100%; height: 110px; display: block; overflow: visible; }
.promo__spark figcaption {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

/* ---- randomiser ---- */
.roll {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
@media (max-width: 760px) { .roll { grid-template-columns: 1fr; } }

.roll__side { background: var(--bg); padding: 1.8rem 1.6rem; display: flex; flex-direction: column; gap: 1.1rem; }
.roll__btn {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: var(--bg);
  background: var(--ink);
  border: 0;
  padding: 1rem 1.2rem;
  cursor: pointer;
  text-align: left;
  transition: background 160ms, color 160ms, transform 90ms;
}
.roll__btn:hover { background: var(--accent-2); color: var(--bg); }
.roll__btn:active { transform: translateY(1px); }
.roll__hint { font-family: var(--mono); font-size: 0.86rem; line-height: 1.7; color: var(--ink-faint); }

.roll__panel { background: var(--bg); padding: 1.8rem 1.6rem; display: flex; flex-direction: column; gap: 0.55rem; }
.roll__age {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  /* Reserve the line so the panel does not jump on first roll. */
  min-height: 1.2em;
}
.roll__era {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--ink);
  min-height: 0.9em;
}
.roll__verdict {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  min-height: 1.2em;
}
.roll__why { font-size: 0.96rem; color: var(--ink-dim); max-width: 54ch; min-height: 3em; }
/* The result is dimmed while spinning and only resolves on settle, so the
   intermediate frames read as motion rather than as sixteen wrong answers. */
.roll__panel:not(.is-settled) .roll__era,
.roll__panel:not(.is-settled) .roll__verdict { opacity: 0.4; }
.roll__link {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  align-self: flex-start;
  margin-top: 0.3rem;
  min-height: 1.2em;
}
.roll__link:hover { border-color: var(--band, var(--ink)); }

.roll__tally { grid-column: 1 / -1; background: var(--bg); padding: 1.2rem 1.6rem; }
.roll__ticks { display: flex; flex-wrap: wrap; gap: 3px; min-height: 16px; }
.roll__ticks i { width: 10px; height: 16px; background: var(--band); display: block; }
.roll__count {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 0.8rem;
  display: block;
}

/* ---- legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin-bottom: 1.8rem; }
.legend__i {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.legend__i::before { content: ''; width: 14px; height: 14px; background: var(--band); }

/* ---- proportional deep-time column ---- */
.tl { border: 1px solid var(--rule); display: flex; flex-direction: column; }
.tl__row {
  display: grid;
  grid-template-columns: 8px 58px 1fr auto;
  align-items: center;
  gap: 0 1.1rem;
  padding-right: 1.2rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
  transition: background 220ms;
}
.tl__row:last-child { border-bottom: 0; }
.tl__row:hover { background: color-mix(in srgb, var(--band) 10%, transparent); }
.tl__row::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--band); }
.tl__n { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-faint); padding-left: 1.1rem; }
.tl__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.4rem, 2.6vw, 2.4rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.tl__span { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-dim); margin-top: 0.35rem; display: block; }
.tl__v {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-align: right;
  white-space: nowrap;
}
/* Rows shorter than roughly two lines hide their date range rather than clip it. */
.tl__row[data-tight='1'] .tl__span { display: none; }
.tl__row[data-tight='1'] .tl__name { font-size: 1.05rem; }

@media (max-width: 620px) {
  .tl__row { grid-template-columns: 8px 40px 1fr; padding-right: 0.8rem; }
  .tl__v { grid-column: 3; text-align: left; font-size: 0.64rem; margin-top: 0.3rem; }
  .tl__name { font-size: 1.15rem; }
}

/* ---- ranked list ---- */
.rank { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.78rem; }
.rank th {
  text-align: left;
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 0.9rem 0.8rem 0;
  border-bottom: 1px solid var(--rule);
}
.rank td { padding: 0.75rem 0.9rem 0.75rem 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); vertical-align: top; }
.rank tr:hover td { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.rank a { text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); }
.rank a:hover { border-color: var(--band); }
.rank__v { color: var(--ink-dim); white-space: nowrap; }
.rank__why { color: var(--ink-dim); line-height: 1.6; font-size: 0.74rem; }
.rank__wrap { overflow-x: auto; }
