/* =========================================================================
   Cabinhub News — Storyline timeline  (lane STORYLINE)

   One block, above the related shelf on a story page: the same event in
   order, newest first. It is the second thing a reader meets after the
   article ends, so it is drawn as a *record*, not as a second card list.

   Design decisions, and what they are made of
     - The spine is the one memorable element. A single hairline runs down the
       left of the list; each entry hangs a dated marker on it. That is the
       information (a storyline IS a sequence), so the numbering/marker is
       content, not decoration.
     - Dates are the left column, prose is the right column, both left aligned.
       The date column is fixed (4.5rem) so the eye can run straight down the
       times without reading; on a phone the date moves above the headline and
       the spine moves with it, because a 390px page has no room for a column.
     - Type: dates and clock times in the UI face at the meta step with tabular
       numerals (they must align down the column); headlines in the display face
       at the card-title step. Nothing here competes with the article H1 above.
     - No card boxes, no shadows, no radius: a hairline and space, exactly like
       the related shelf below it. This is the same newsprint, one register
       quieter.
     - Colour is entirely tokens (tokens.css), so light and dark both follow the
       reader's choice with no dark-only override in this file. The one accent
       use is the "Latest" tag, which is a fact about recency (it is the newest
       entry), not a decoration.
   ========================================================================= */

.storyline {
  margin-top: clamp(2rem, 4.5vw, 3.2rem);
  border-top: 2px solid var(--rule-strong);
  padding-top: clamp(0.9rem, 2vw, 1.3rem);
}

/* Loading is not a skeleton: a skeleton would promise a timeline that may
   never exist (the endpoint answers 404 for most stories). An aria-busy
   empty section occupies no visual space and is removed on answer. */
.storyline--loading {
  display: none;
}

/* The heading and its caption stack: the caption is a description of the
   block, not a second column, and at 1440 a baseline-split head left it
   marooned on the far right of the page. */
.storyline__head {
  display: block;
}

.storyline__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--ink);
}

/* A same-day cluster is a shorter claim than an arc, and the block says so in
   its heading. The shape is carried on the element (`data-kind`) so the two can
   only ever be styled apart deliberately -- no rule here changes geometry, so
   the row rhythm measured at 1440/1024/480 is identical for both. */
.storyline--today .storyline__title {
  letter-spacing: -0.006em;
}

.storyline__meta {
  margin: 0.18rem 0 0;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  line-height: 1.5;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.storyline__retry {
  margin-block-start: .4rem;
  min-height: var(--tap);
}

.storyline__retry[aria-disabled="true"] { opacity: .65; cursor: wait; }

.storyline__retry:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* ---- the list: a spine with dated markers ------------------------------
   Geometry, in one place, because the spine and the markers must land in the
   GAP between the date column and the text column — measured on the first
   build at 1440: a spine at the date column's edge cut through "Sep 30".
     date column   3.8rem
     gap           1.35rem
     spine         at 4.48rem (the middle of the gap)
     text column   from 5.15rem                                            */

.storyline__list {
  list-style: none;
  margin: clamp(0.8rem, 1.8vw, 1.2rem) 0 0;
  padding: 0;
  position: relative;
  max-width: 66rem;
}

/* The spine. Drawn once on the list, not per row, so it is continuous even
   where a row's own content is short. */
.storyline__list::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  bottom: 1rem;
  left: 4.48rem;
  width: 1px;
  background: var(--rule);
}

.storyline__item {
  position: relative;
  display: grid;
  /* The text column is capped, not elastic: at 1440 the elastic middle column
     grew to ~870px while the summaries inside it stop at their reading measure,
     which left a dead band between every row and the thumbnail (measured
     2026-11-10 on the merged tree, 1440 light). Capping the column moves the
     picture in beside the text a reader is reading. */
  grid-template-columns: 3.8rem minmax(0, var(--measure)) auto;
  justify-content: start;
  column-gap: 1.35rem;
  padding: 0 0 clamp(1rem, 2.2vw, 1.45rem) 0;
}

.storyline__item:last-child {
  padding-bottom: 0;
}

/* The marker: a small square centred on the spine. A square, not a circle —
   the newsroom's shapes are the small end of the radius ramp. */
.storyline__item::before {
  content: "";
  position: absolute;
  left: 4.48rem;
  top: 0.52rem;
  width: 7px;
  height: 7px;
  margin-left: -3px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 1px;
}

/* The newest entry is the one a reader came for: a filled marker and the tag. */
.storyline__item:first-child::before {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- when ------------------------------------------------------------- */

.storyline__when {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-top: 0.05rem;
  text-align: right;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.storyline__date {
  font-size: var(--fs-meta);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
}

.storyline__clock {
  font-size: var(--fs-micro);
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.storyline__latest {
  margin-top: 0.15rem;
  align-self: flex-end;
  font-size: var(--fs-micro);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--accent);
}

/* ---- what ------------------------------------------------------------- */

.storyline__body {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.storyline__link {
  display: block;
  color: var(--ink);
  text-decoration: none;
}

/* The headline link measured 643x24 and 315x22 (n3_routes, 2026-11-10, 1440 and
   360): full width but under the 44px --tap the rest of the estate keeps. The
   first attempt scoped this to >=561px and left the phone rows failing, so it
   is unconditional; on the phone the date line sits above the link, so the
   grown box costs the row nothing. */
.storyline__link { min-height: var(--tap); }

.storyline__link:hover .storyline__headline {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.storyline__link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

.storyline__headline {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.006em;
  text-wrap: pretty;
}

/* The thumbnail is its OWN grid cell at the right edge of the row, not a float.
   Measured on the first build: a float put the picture at the far right of a
   1040px column with the summary hugging the left, which read as two unrelated
   things. As a cell, every picture in the timeline aligns on one edge and every
   headline starts on one line. It is drawn only when the server published a
   URL, so an item without a picture has an empty cell, not a frame.
   The third grid track is `auto`, so a timeline with no pictures at all has no
   empty column. */
.storyline__thumb {
  grid-column: 3;
  grid-row: 1;
  width: 96px;
  margin: 0.1rem 0 0 0;
  border: 0;
  align-self: start;
}

.storyline__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--r-xs);
  background: var(--paper-2);
}

.storyline__summary {
  margin: 0.3rem 0 0;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 62ch;
  text-wrap: pretty;
}

/* ---- phone: the date becomes a line above the headline ----------------- */

@media (max-width: 560px) {
  .storyline__list::before,
  .storyline__item::before {
    display: none;
  }
  .storyline__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.8rem;
    padding-bottom: clamp(0.95rem, 3.4vw, 1.25rem);
  }
  /* The date line is the FIRST row here, so it must be pinned: `.storyline__body`
     and `.storyline__thumb` carry `grid-row: 1` from the desktop rules, and
     without these three lines that pinning wins and the date renders BELOW the
     summary — measured on the phone viewport at 390 px, the date sat under the
     paragraph and read as the next story's. */
  .storyline__when {
    grid-column: 1 / -1;
    grid-row: 1;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    text-align: left;
    margin-bottom: 0.28rem;
  }
  .storyline__body {
    grid-column: 1;
    grid-row: 2;
  }
  .storyline__thumb {
    grid-column: 2;
    grid-row: 2;
    width: 76px;
  }
  .storyline__latest {
    align-self: baseline;
    margin-top: 0;
    order: 3;
    margin-left: auto;
  }
  .storyline__summary {
    max-width: none;
  }
}

/* ---- CJK -------------------------------------------------------------
   The display face falls back to a serif CJK; the headline step needs a
   little more leading at the same size, and the date column can be narrower
   because 11月6日 is shorter than "6 Nov". */
html[lang="zh-Hans"] .storyline__headline {
  line-height: 1.45;
  letter-spacing: 0;
}

html[lang="zh-Hans"] .storyline__meta {
  letter-spacing: 0;
}

@media (min-width: 561px) {
  /* 11月6日 is narrower than "Sep 30", so the date column tightens and the
     spine moves with it — same three numbers as above, one step smaller. */
  html[lang="zh-Hans"] .storyline__list::before,
  html[lang="zh-Hans"] .storyline__item::before {
    left: 4.15rem;
  }
  html[lang="zh-Hans"] .storyline__item {
    grid-template-columns: 3.45rem minmax(0, var(--measure)) auto;
  }
}

/* ---- forced colours ---------------------------------------------------
   Windows high contrast drops backgrounds, so the spine and the markers must
   get a system colour or the timeline loses its sequence. */
@media (forced-colors: active) {
  .storyline__list::before {
    background: CanvasText;
  }
  .storyline__item::before,
  .storyline__item:first-child::before {
    background: Canvas;
    border-color: CanvasText;
  }
  .storyline__latest {
    color: Highlight;
  }
}

/* ---- reduced motion ---------------------------------------------------
   This file declares no motion: the timeline is a record, and a record does
   not animate in. The rule is here so a later addition cannot forget it. */
@media (prefers-reduced-motion: reduce) {
  .storyline *,
  .storyline *::before {
    transition: none !important;
    animation: none !important;
  }
}
