/*
 * features.html — Features & mechanics, on ticket stock.
 *
 * Builds on site.css, and in particular on the price section's fare ticket
 * (.fare, .fare__perf, .fare__stamp, .fare__live): the two fares at the top
 * ARE that ticket, expanded, and every system, victory and mandate below is
 * a smaller ticket of the same stock (.tkt) in a rack. Route colours are
 * the stripe across each ticket's top — this is the one page where the
 * whole palette is meant to show, because every system is its own line.
 *
 * All motion is a class this file styles and js/features.js toggles —
 * opacity and transform only — plus the trains on the strip maps, which
 * run on Web Animations.
 */

/* ── Page head ─────────────────────────────────────────────────────────── */

.feat-head { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.75rem, 3vw, 2.5rem); border-bottom: 2px solid var(--ink); }
.feat-head h1 { font-size: clamp(2.6rem, 6.2vw, 4.75rem); line-height: 0.98; max-width: 20ch; margin: 0.9rem 0 1rem; letter-spacing: -0.01em; }
.feat-head .lede { font-size: clamp(1.0625rem, 1.5vw, 1.25rem); color: var(--ink-2); max-width: var(--measure); }
.feat-head .lede b { color: var(--ink); font-weight: 600; }
.feat-jump { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-top: 1.25rem; }
.feat-jump a {
  display: inline-flex; align-items: center; min-height: 2.5rem;
  font-family: var(--display); font-weight: 600; font-size: 1.0625rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--ink);
}
.feat-jump a:hover { color: var(--accent); border-bottom-color: var(--accent); }
/* Deep-links from the jump bar (#inherit, #ferries, #challenge are rows of
   the "Carried on both" fare) must clear the sticky nav. */
.tkt[id], .fare__cols li[id] { scroll-margin-top: 5.5rem; }
/* A phone: each jump chip is a 44 px tap. */
@media (pointer: coarse), (max-width: 767.98px) {
  .feat-jump a { min-height: 2.75rem; }
}

/* ── The fares, expanded ───────────────────────────────────────────────── */

.fares--feat { margin-top: 1rem; }
/* The $25 flips in as three split-flap cells (js/weekly.js turns them with the board). */
.fare__amount[data-flip] { display: inline-flex; perspective: 300px; }
.fare__amount .flip { display: inline-block; transform-origin: 50% 50%; backface-visibility: hidden; }
/* The third ticket, full width: the conditions of carriage in three columns. */
.fare--wide { margin-top: 2.5rem; }
.fare__cols { display: grid; gap: 0.5rem 2rem; }
@media (min-width: 640px) { .fare__cols { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .fare__cols { grid-template-columns: 1fr 1fr 1fr; } }
.fare__cols li a { color: var(--accent); }
.fare__cols code { font-family: var(--mono); font-size: 0.85em; }
/* The honours pointer: three figures on a strip inside the ticket. */
.fare__figs { display: grid; gap: 1rem 2.5rem; }
@media (min-width: 720px) { .fare__figs { grid-template-columns: repeat(3, 1fr); } }
.fare__figs div { display: grid; gap: 0.2rem; }
.fare__figs b { font-family: var(--display); font-weight: 600; font-size: clamp(2.8rem, 5vw, 4rem); line-height: 0.95; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.fare__figs b .unit { font-size: 0.5em; font-weight: 600; color: var(--ink-2); margin-inline-start: 0.1rem; }
.fare__figs small { font-size: 0.875rem; color: var(--ink-2); line-height: 1.4; }
.fare--honours .fare__note { margin-top: 0; font-size: 0.9375rem; color: var(--ink-2); max-width: 70ch; }
/* Six badges in a row on the ticket, the name under each in mono. The artwork is a dark tile; the tier rim is drawn in.
   Written against .fare so they outrank site.css's `.fare ul` / `.fare li` (the conditions-of-carriage list). */
.fare .fare__badges { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; }
.fare .fare__badges li { display: grid; grid-template-columns: none; justify-items: center; gap: 0.4rem; width: 4.5rem; font-size: 0.7rem; }
.fare .fare__badges img { display: block; inline-size: 4rem; block-size: 4rem; border-radius: 0.5rem; background: #12171F; }
.fare .fare__badges span { font-family: var(--mono); line-height: 1.2; color: var(--ink-2); text-align: center; }

/* ── The strip map divider ─────────────────────────────────────────────── */

.strip {
  display: block;
  width: 100%;
  height: 4.5rem;
  margin: 0;
  overflow: visible;
  color: var(--ink);
}
.strip .track { stroke: var(--ink); stroke-width: 3; fill: none; stroke-linecap: round; }
.strip .stop { fill: var(--ground); stroke: var(--ink); stroke-width: 2.5; }
.strip .term { fill: var(--ink); }
.strip .name { font-family: var(--display); font-weight: 600; font-size: 9px; fill: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
/* A train: pale body, the line's colour as the rim, a dark shell under it —
   the hero's treatment (css/hero.css --hm-body / --hm-shell). */
.strip { --train-body: #FFFFFF; --train-shell: var(--ink); }
.strip .train rect.shell { fill: var(--train-shell); }
.strip .train rect.body { fill: var(--train-body); stroke: var(--line-c, var(--line-blue)); stroke-width: 1.6; }
.strip .train rect.nose { fill: var(--line-c, var(--line-blue)); }
/* fill-box: the anchor is the train's own centre. The default view-box would
   anchor the whole SVG's centre to the path and float the body off the line. */
.strip .train { offset-rotate: auto; offset-anchor: center; transform-box: fill-box; }
.section--strip { padding-block: 0; border-bottom: 0; }
.section--strip .wrap { padding-block: 0.5rem 0; }
/* Under 640 px the 1200-unit drawing would be squeezed three to one (its
   stops to slivers, its names to dust), so the divider becomes the rack's
   own HTML strip — one line, three stops, one train — and the SVG is put
   away. The HTML strip stands in the markup beside it. */
.strip--phone { display: none; }
@media (max-width: 639.98px) {
  svg.strip { display: none; }
  .strip--phone { display: block; margin: 0.75rem 0.5rem 0.5rem; }
}

/* ── The rack ──────────────────────────────────────────────────────────── */

.rack { margin-top: 1rem; }
.rack__row { display: grid; gap: 1.5rem; }
@media (min-width: 640px) {
  .rack__row { grid-template-columns: 1fr 1fr; }
  /* Three tickets in two columns: the third runs the full width, a long ticket. */
  .rack__row > :nth-child(3) { grid-column: 1 / -1; }
}
@media (min-width: 960px) {
  .rack__row { grid-template-columns: repeat(3, 1fr); gap: 1.75rem; }
  .rack__row > :nth-child(3) { grid-column: auto; }
}

/* A thin running strip map between rows: a hairline track, three stops, one
   train. Drawn in HTML so nothing distorts at any width; the train moves on
   a transform js/features.js animates. */
.rack__strip {
  --line-c: var(--accent);
  position: relative; block-size: 1.5rem; margin: 1.25rem 0.5rem;
}
.rack__strip::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: calc(50% - 1px); block-size: 2px; background: var(--ink); }
.rack__strip::after, .rack__stop {
  content: ""; position: absolute; inset-block-start: calc(50% - 0.3rem); inline-size: 0.6rem; block-size: 0.6rem; box-sizing: border-box;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--ink);
}
.rack__strip::after { inset-inline-end: 0; background: var(--ink); }
.rack__stop { inset-inline-start: calc(var(--x, 50%) - 0.3rem); }
.rack__train {
  position: absolute; inset-inline-start: 0; inset-block-start: calc(50% - 0.4rem); inline-size: 2.1rem; block-size: 0.8rem;
  border-radius: 0.4rem; background: var(--ink); display: block; will-change: transform;
}
.rack__train i { position: absolute; inset: 2px; border-radius: 0.3rem; background: var(--ground); border: 1.5px solid var(--line-c); }
.rack__train i::after { content: ""; position: absolute; inset-block: 1px; inset-inline-end: 1px; inline-size: 3px; border-radius: 2px; background: var(--line-c); }
/* Running the other way, the nose is at the other end. */
.rack__train.rev i::after { inset-inline-end: auto; inset-inline-start: 1px; }
@media (prefers-color-scheme: dark) { .rack__train i { background: var(--ink-2); } }

/* A ticket: the fare's stock at a smaller size. The stripe is the line. */
.tkt {
  --tkt-c: var(--accent);
  --fare-pad: 1.1rem;
  position: relative; min-width: 0;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 0.85rem var(--fare-pad) var(--fare-pad);
  background: var(--surface);
  border: 1px solid var(--ink);
  border-top: 6px solid var(--tkt-c);
}
.tkt__top { display: flex; align-items: center; gap: 0.7rem; }
/* The kicker: a station plate with the ticket's colour as its tick. */
.tkt__kick { --tick: var(--tkt-c); font-size: 0.8125rem; min-height: 1.75rem; padding-inline: 0.6rem 0.75rem; }
.tkt__tag { margin-inline-start: auto; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
/* The figure that matters, in Barlow at signage size, and its unit. */
.tkt__fig { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.1rem; }
.tkt__fig b { font-family: var(--display); font-weight: 600; font-size: clamp(2.6rem, 3.6vw, 3.2rem); line-height: 0.9; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tkt__fig small { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); line-height: 1.35; flex: 1 1 8rem; min-width: 0; }
/* The perforation's notches are cut from the page ground the ticket sits on. */
.tkt .fare__perf { margin-block: 0.1rem; }
.tkt h3 { font-size: 1.35rem; line-height: 1.08; margin: 0; }
.tkt p { font-size: 0.9375rem; color: var(--ink-2); margin: 0; }
.tkt p b { color: var(--ink); font-weight: 600; }
.tkt p a { color: var(--accent); }
.tkt code { font-family: var(--mono); font-size: 0.85em; }
.tkt .card__cite { margin-top: auto; padding-top: 0.6rem; }
/* The requirement line on a victory ticket, in Barlow. */
.tkt__req { font-family: var(--display); font-weight: 500; font-size: 1.15rem; line-height: 1.15; color: var(--ink) !important; }
/* The "held one year" stamp, landed askew at the top right. */
.tkt__stamp {
  position: absolute; inset-block-start: 3.1rem; inset-inline-end: 1rem;
  display: inline-grid; gap: 0.05rem; padding: 0.3rem 0.5rem 0.25rem;
  border: 2px solid var(--accent); outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 3px;
  transform: rotate(-7deg); color: var(--accent);
  font-family: var(--display); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1; text-align: center;
  opacity: 0.92;
}
.tkt__stamp span { display: block; }
.tkt__stamp span + span { font-weight: 600; font-size: 0.6875rem; letter-spacing: 0.1em; }
.tkt--win .tkt__fig { padding-inline-end: 6rem; }
@media (max-width: 479.98px) {
  /* The caption takes its own line under the figure rather than three
     squeezed beside the stamp; the stamp sits level with the figure. */
  .tkt--win .tkt__fig { padding-inline-end: 0; }
  .tkt--win .tkt__fig b { padding-inline-end: 6.5rem; }
  .tkt--win .tkt__fig small { flex-basis: 100%; }
}
/* Mandates: the modes line and the objectives. */
.tkt__modes { font-family: var(--mono) !important; font-size: 0.78rem !important; color: var(--ink-3) !important; letter-spacing: 0.02em; }
.tkt__obj { margin: 0; padding: 0 0 0 1.1rem; font-size: 0.9rem; color: var(--ink-2); display: grid; gap: 0.2rem; }
.tkt__obj li::marker { color: var(--tkt-c); }

/* Losing: three short plates in a row. */
.losses { display: grid; gap: 1rem 2rem; margin-top: 2.5rem; }
@media (min-width: 760px) { .losses { grid-template-columns: repeat(3, 1fr); } }
.loss { padding-top: 0.8rem; border-top: 2px solid var(--ink); }
.loss h3 { font-size: 1.35rem; margin: 0.5rem 0 0.35rem; }
.loss p { font-size: 0.9rem; color: var(--ink-2); margin: 0; }

/* ── Arrival ───────────────────────────────────────────────────────────── */

/* Tickets rise in, 70 ms apart; rows inside a ticket (the wide one's
   conditions, the figures) 40 ms apart. CSS does the motion; features.js
   sets --i (the row's place among those that came into view in the same
   frame) and adds the class to the ROW as it scrolls into view, so nothing
   moves below the fold and the last of a batch has landed inside 1.1 s. */
[data-reveal] [data-row] { opacity: 0; transform: translateY(0.9rem); transition: opacity 520ms var(--ease-land), transform 520ms var(--ease-land); transition-delay: calc(min(var(--i, 0), 8) * 70ms); }
[data-reveal] .fare__cols [data-row], [data-reveal] .fare__figs [data-row] { transform: translateY(0.4rem); transition-duration: 380ms; transition-delay: calc(min(var(--i, 0), 12) * 40ms); }
[data-reveal] [data-row].is-in { opacity: 1; transform: none; }

/* ── Motion refused ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  [data-reveal] [data-row] { transition: none; opacity: 1; transform: none; }
}
.no-js [data-reveal] [data-row] { opacity: 1; transform: none; }

/* Ticket wall: hover names the line; the stamp lands after the ticket arrives. */
.tkt:hover, .tkt:focus-within { border-color: var(--tkt-c); }
.loss { transition: border-color 160ms ease; }
.loss:hover { border-top-color: var(--accent); }
.fare:hover, .fare:focus-within { border-color: var(--fare-c, var(--ink)); }

@media (prefers-reduced-motion: no-preference) {
  .tkt {
    transition: transform 180ms var(--ease-land), border-color 180ms ease;
  }
  .tkt:focus-within,
  [data-reveal] .tkt.is-in:focus-within { transform: translateY(-4px); }
  /* Hover gated: on a touch screen a tap fires :hover and the lift sticks
     until the next tap elsewhere. :focus-within stays ungated so a
     keyboard still gets the same affordance. */
  @media (hover: hover) and (pointer: fine) {
    .tkt:hover,
    [data-reveal] .tkt.is-in:hover { transform: translateY(-4px); }
  }
  .fare {
    transition: transform 180ms var(--ease-land), border-color 180ms ease;
  }
  .fare:focus-within,
  [data-reveal] .fare.is-in:focus-within { transform: translateY(-3px); }
  /* Hover gated: on a touch screen a tap fires :hover and the lift sticks
     until the next tap elsewhere. :focus-within stays ungated so a
     keyboard still gets the same affordance. */
  @media (hover: hover) and (pointer: fine) {
    .fare:hover,
    [data-reveal] .fare.is-in:hover { transform: translateY(-3px); }
  }
  [data-reveal] .tkt__stamp {
    opacity: 0;
    transform: rotate(-12deg) scale(1.18);
  }
  [data-reveal] .tkt.is-in .tkt__stamp {
    opacity: 0.92;
    transform: rotate(-7deg) scale(1);
    transition: opacity 420ms var(--ease-land) 380ms,
                transform 420ms var(--ease-land) 380ms;
  }
}
