/* ==========================================================================
   Tap Zoom Gone — global styles
   Every font-size, margin and padding below resolves to a token in :root.
   Motion is CSS-only (scroll-driven animations) and progressive: browsers
   without animation-timeline, and anyone with reduced motion, get the
   static page.
   ========================================================================== */

:root {
  /* Brand palette — fixed values, do not substitute */
  --lens-charcoal: #2f353b;
  --shutter-grey: #b0b7bd;
  --globe-silver: #e1e4e8;
  --off-white: #f5f7fa;
  --horizon-blue: #8da9c4;
  --mid-charcoal: #4a525a; /* dark-mode interior fill */
  /* RESERVED. Location markers and the single primary CTA only. Nothing else.
     Two uses on the whole page, never more: the route pin, the CTA marker. */
  --pinpoint-red: #ff4136;

  /* Semantic colours. light-dark() picks a side from color-scheme, which the
     theme blocks below set — so each token is defined once, for both themes. */
  --bg: light-dark(var(--off-white), var(--lens-charcoal));
  --text: light-dark(var(--lens-charcoal), var(--off-white));
  --text-muted: light-dark(var(--mid-charcoal), var(--shutter-grey));
  --border: light-dark(var(--lens-charcoal), var(--off-white));
  --hairline: light-dark(var(--globe-silver), var(--mid-charcoal));
  --fill: light-dark(var(--shutter-grey), var(--mid-charcoal));
  --topic: var(--horizon-blue);
  --on-topic: var(--lens-charcoal);
  --marker: var(--pinpoint-red);

  /* Type scale — modular, 1.25 ratio. Upper steps are fluid between scale values. */
  --step--1: 0.8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: clamp(1.563rem, 1.35rem + 0.9vw, 1.953rem);
  --step-4: clamp(1.563rem, 1.1rem + 2vw, 2.441rem);
  --step-6: clamp(1.953rem, 1.2rem + 3.6vw, 3.815rem);

  --font-heading: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Open Sans', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  /* Spacing scale — 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 px */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --gutter: var(--space-4);
  --page-max: 72rem;
  --measure: 68ch;
  --radius: 2px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding-inline: var(--gutter);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.65;
}

@media (min-width: 48rem) {
  :root {
    --gutter: var(--space-6);
  }
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
  max-inline-size: var(--measure);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--border);
  outline-offset: var(--space-1);
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Monospace is for metadata only: numbers, dates, prices, specs, indices. */
.meta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Small uppercase label treatment shared by nav, hero meta and links. */
.nav-list,
.hero-meta,
.board-head,
.start-label {
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skip-link {
  position: absolute;
  z-index: 20;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--fill);
  color: var(--text);
  translate: 0 -200%;
}

.skip-link:focus {
  translate: 0 0;
}

.shell {
  max-inline-size: var(--page-max);
  margin-inline: auto;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-5);
}

.brand {
  margin-inline-end: auto;
  font-family: var(--font-heading);
  font-size: var(--step--1);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.nav-list a {
  text-decoration: none;
}

.nav-list a:hover {
  text-decoration-line: underline;
}

.nav-contact {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.theme-toggle {
  display: grid;
  place-items: center;
  padding: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--border);
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  gap: var(--space-7);
  padding-block: var(--space-7) var(--space-8);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin-block-end: var(--space-7);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.hero-title {
  font-size: var(--step-6);
  font-weight: 800;
  line-height: 1.1;
}

.hero-title > span {
  display: block;
}

.hero-sub {
  color: var(--text-muted);
}

.hero-aside {
  display: grid;
  align-content: start;
  gap: var(--space-5);
}

.placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.bio {
  margin: 0;
  max-width: 34ch;
  text-wrap: pretty;
}

@media (min-width: 60rem) {
  .hero {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    column-gap: var(--space-8);
    padding-block: var(--space-8);
  }
}

/* ---------- Channels strip ---------- */

.channels {
  margin-block-start: var(--space-7);
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--hairline);
}

.channels-label {
  margin-block-end: var(--space-3);
}

.channels-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Secondary channel buttons: outlined, same footprint as the CTA. */
.channel {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-weight: 700;
  text-decoration: none;
}

.channel-arrow {
  display: inline-block;
}

.channel:is(:hover, :focus-visible) .channel-arrow {
  translate: var(--space-1) calc(var(--space-1) * -1);
}

/* ---------- Sweep: Horizon Blue fills left to right on hover / focus ---------- */

.sweep {
  position: relative;
  isolation: isolate;
}

.sweep::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--topic);
  scale: 0 1;
  transform-origin: left center;
}

.sweep:is(:hover, :focus-visible) {
  color: var(--on-topic);
}

.sweep:is(:hover, :focus-visible)::before {
  scale: 1 1;
}

.sweep:is(:hover, :focus-visible) .meta {
  color: var(--on-topic);
}

/* ---------- Primary CTA — red only as its marker ---------- */

.cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-heading);
  font-weight: 700;
  text-decoration: none;
}

.cta::before {
  content: '';
  inline-size: var(--space-2);
  block-size: var(--space-2);
  background: var(--marker);
}

.cta:hover {
  text-decoration-line: underline;
}

/* ---------- Start here ---------- */

.start {
  padding-block-end: var(--space-8);
}

.start-label {
  max-inline-size: none;
  padding-block-end: var(--space-2);
  border-block-end: 1px solid var(--border);
}

.start-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) var(--space-5);
  align-items: baseline;
  column-gap: var(--space-3);
  padding: var(--space-4) var(--space-3);
  border-block-end: 1px solid var(--hairline);
  text-decoration: none;
}

.start-title {
  font-family: var(--font-heading);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.15;
}

/* Count sits under the title on phones, beside it on wider screens. */
.start-count {
  grid-column: 2;
  grid-row: 2;
}

.start-arrow {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.start-row:is(:hover, :focus-visible) .start-arrow {
  translate: var(--space-1) 0;
}

@media (min-width: 40rem) {
  .start-row {
    grid-template-columns: 3rem minmax(0, 1fr) auto var(--space-5);
  }

  .start-count {
    grid-column: 3;
    grid-row: 1;
  }

  .start-arrow {
    grid-column: 4;
  }
}

/* ---------- Journey: vertical route rail through sections 01–03 ----------
   A dashed rail in the left gutter, a stop at each section, and a sticky red
   pin. The pin is held by position: sticky (not animation), so it works in
   every browser; it rides at the vertical middle of the screen, beside what
   you're reading. */

.journey {
  --rail-x: calc(var(--gutter) / -2);
  --stop-y: calc(var(--space-8) + var(--space-2)); /* stop's offset in its section */
  --pin-y: 50svh; /* where the pin rides on screen */
  position: relative;
  /* Keep the travelled line inside the journey; let the gutter show. */
  clip-path: inset(0 calc(var(--gutter) * -1));
}

.journey::before {
  content: '';
  position: absolute;
  inset-block: var(--stop-y) 0;
  inset-inline-start: var(--rail-x);
  border-inline-start: 1px dashed var(--fill);
}

.journey-pin {
  position: sticky;
  z-index: 2;
  inset-block-start: calc(var(--pin-y) - var(--stop-y));
  block-size: var(--stop-y);
  margin-block-end: calc(var(--stop-y) * -1);
  pointer-events: none;
}

/* The travelled line: from the pin back up the rail (clipped at the journey's top). */
.journey-pin::before {
  content: '';
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: var(--rail-x);
  block-size: 1000vh; /* longer than any page; clipped by .journey */
  border-inline-start: 2px solid var(--text);
  translate: -50% 0;
}

.journey-pin::after {
  content: '';
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: var(--rail-x);
  inline-size: var(--space-3);
  block-size: var(--space-3);
  translate: -50% 50%;
  background: var(--marker);
}

/* ---------- Sections ---------- */

.section {
  position: relative;
  padding-block: var(--space-8);
  border-block-start: 1px solid var(--hairline);
}

/* Route stop for this section. Hollow ahead of you, filled once you pass it. */
.section::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset-block-start: var(--stop-y);
  inset-inline-start: var(--rail-x);
  inline-size: var(--space-2);
  block-size: var(--space-2);
  translate: -50% -50%;
  border: 1px solid var(--border);
  background: var(--bg);
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin-block-end: var(--space-6);
  font-size: var(--step-3);
}

.section-index {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--text-muted);
}

.section-body {
  min-inline-size: 0;
}

.section-body > p + p {
  margin-block-start: var(--space-3);
}

/* Desktop: the section title rides along in a sticky left rail. */
@media (min-width: 60rem) {
  .section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    column-gap: var(--space-8);
  }

  .section-title {
    position: sticky;
    inset-block-start: var(--space-7);
    align-self: start;
    flex-direction: column;
    margin-block-end: 0;
  }
}

/* ---------- Episodes: departure board ---------- */

.board-head {
  display: none;
}

.board-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  padding-block: var(--space-4);
  border-block-end: 1px solid var(--hairline);
}

.board ol {
  border-block-start: 1px solid var(--hairline);
}

.board-detail {
  flex-basis: 100%;
}

.board-detail .meta {
  display: block;
  margin-block-start: var(--space-1);
}

@media (min-width: 40rem) {
  .board-head,
  .board-row {
    display: grid;
    grid-template-columns: 4.5rem 8rem minmax(0, 1fr);
    column-gap: var(--space-4);
  }

  .board-head {
    padding-block-end: var(--space-2);
  }

  .board ol {
    border-block-start-color: var(--border);
  }
}

.topic {
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  background: var(--topic);
  color: var(--on-topic);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.entry-title {
  margin-block-end: var(--space-1);
  font-size: var(--step-1);
  font-weight: 600;
}

/* ---------- Gear: packing list ---------- */

.manifest-summary {
  margin-block-end: var(--space-6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gear-group + .gear-group {
  margin-block-start: var(--space-7);
}

.group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-end: var(--space-3);
  font-size: var(--step-1);
}

.manifest {
  border-block-start: 1px solid var(--border);
}

.manifest-row {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: var(--space-3);
  padding-block: var(--space-4);
  border-block-end: 1px solid var(--hairline);
}

.manifest-code {
  padding-block-start: var(--space-1);
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  margin-block-end: var(--space-1);
}

.entry-name {
  font-weight: 600;
}

/* A row's rule darkens while its link is hovered or focused. */
:is(.board-row, .manifest-row):has(a:hover, a:focus-visible) {
  border-block-end-color: var(--border);
}

/* ---------- Contact ---------- */

.contact-email {
  font-family: var(--font-heading);
  font-size: var(--step-4);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* ---------- Footer ---------- */

.site-footer {
  display: grid;
  gap: var(--space-4);
  padding-block: var(--space-6) var(--space-8);
  border-block-start: 1px solid var(--hairline);
}

.disclosure {
  font-size: var(--step--1);
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-size: var(--step--1);
}

/* ==========================================================================
   Motion. Everything here is off under prefers-reduced-motion.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  /* Hero: staggered arrival on load. */
  .hero-anim {
    animation: rise 700ms var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 90ms);
  }

  .sweep::before,
  .channel-arrow,
  .start-arrow {
    transition:
      scale 300ms var(--ease-out),
      translate 200ms var(--ease-out);
  }

  /* Terminal caret after the hero subline; blinks a few times, then rests. */
  .caret::after {
    content: '';
    display: inline-block;
    inline-size: 0.5em;
    block-size: 0.08em;
    margin-inline-start: var(--space-1);
    background: currentColor;
    animation: blink 1s steps(1) 1s 5 both;
  }

  /* Scroll-driven: only where the browser can tie animations to scroll. */
  @supports (animation-timeline: view()) {
    /* Each section's title comes forward as the section arrives. */
    .section {
      view-timeline: --section block;
    }

    /* A stop fills the moment it scrolls up past the pin. `cover` counts from the
       section's top edge entering at the bottom of the screen, so the stop meets
       the pin after (screen height − pin-y + stop-y) of scrolling. */
    .section::before {
      --meet: calc(100svh - var(--pin-y) + var(--stop-y));
      animation: visit linear both;
      animation-timeline: --section;
      animation-range: cover var(--meet) cover calc(var(--meet) + 1px);
    }

    /* Contact is short, so the page can end before its stop reaches the pin.
       Fill it on arrival at the bottom of the page as well. `forwards` (not
       `both`) so this second animation can't un-fill the stop earlier on. */
    .journey > .section:last-child::before {
      animation: visit linear both, visit linear forwards;
      animation-timeline: --section, scroll(root block);
      animation-range: cover var(--meet) cover calc(var(--meet) + 1px), 99% 100%;
    }

    .section-title {
      animation: fore linear both;
      animation-timeline: --section;
      animation-range: entry 0% entry 70%;
    }

    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 80%;
    }

    /* Departure-board rows flip down into place. */
    .board-row {
      transform-origin: top center;
      animation: flip linear both;
      animation-timeline: view();
      animation-range: entry 10% entry 100%;
    }

    /* Packing-list rows scan in left to right. */
    .manifest-row {
      animation: scan linear both;
      animation-timeline: view();
      animation-range: entry 10% entry 100%;
    }
  }
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 var(--space-5);
  }
}

@keyframes fore {
  from {
    opacity: 0.2;
    translate: calc(var(--space-4) * -1) 0;
  }
}

@keyframes flip {
  from {
    opacity: 0;
    transform: perspective(40rem) rotateX(-80deg);
  }
}

@keyframes scan {
  from {
    clip-path: inset(0 100% 0 0);
  }
}

@keyframes visit {
  to {
    background: var(--text);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}
