/* Link AI Agency — scrollytelling experiment (chaptered editorial grammar)
   Signature move: the rail (.rail) catches one real tool-logo per chapter as it is
   read, then resolves into the full hub diagram at the chapter V peak. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

:root {
  --paper:      #fbfaf7;
  --paper-deep: #f2efe8;
  --ink:        #171522;
  --ink-soft:   #6b6878;
  --ink-faint:  #625d70; /* was #9a97a6 — failed 4.5:1, darkened to clear it on both grounds (6.06:1 paper / 5.51:1 paper-deep) */
  --rule:       rgba(20,18,30,.14);
  --rule-soft:  rgba(20,18,30,.08);
  --accent:     #5b3fa6;
  --accent-ink: #fbfaf7;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --measure: 38ch;
}

@media (prefers-color-scheme: dark) {
  /* Editorial grammar commits to one paper look regardless of OS theme —
     a newsprint page does not go dark at night. Intentional, not an oversight. */
}

html { scroll-behavior: auto; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
a:hover, a:focus-visible { color: var(--ink); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.grain {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  opacity: .028; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- folio (persistent margin chrome, updates per chapter) ---------- */
.folio {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 1.4rem 2rem;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-soft);
  pointer-events: none;
  mix-blend-mode: difference;
  filter: invert(1) grayscale(1) contrast(1.3);
}
.folio__num { color: var(--ink); }

/* ---------- rail — the signature move ---------- */
.rail {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 15;
  width: 4.6rem;
  display: flex; flex-direction: column; align-items: center;
  padding: 6rem 0 2rem;
  opacity: 0; transition: opacity .5s ease;
  pointer-events: none;
}
.rail.is-visible { opacity: 1; }
.rail__label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 1.2rem;
}
.rail__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.rail__chip {
  width: 2.2rem; height: 2.2rem; border-radius: .5rem;
  background: var(--paper); border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  padding: .45rem;
  opacity: 0; transform: scale(.4);
  transition: opacity .5s cubic-bezier(.22,.61,.36,1), transform .5s cubic-bezier(.22,.61,.36,1);
}
.rail__chip.is-caught { opacity: 1; transform: scale(1); }
.rail.is-delivered .rail__chip { opacity: .32; transform: scale(.92); }
.rail__chip img { width: 100%; height: 100%; object-fit: contain; }

/* flight clone used during the catch animation */
.flight-chip {
  position: fixed; z-index: 40; width: 1.8rem; height: 1.8rem; border-radius: .4rem;
  background: var(--paper); border: 1px solid var(--rule); padding: .35rem;
  pointer-events: none;
  transition: transform .75s cubic-bezier(.22,.61,.36,1), opacity .75s cubic-bezier(.22,.61,.36,1);
}
.flight-chip img { width: 100%; height: 100%; object-fit: contain; }

@media (max-width: 860px) {
  .rail { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 3.4rem;
    flex-direction: row; align-items: center; padding: 0 1rem; border-top: 1px solid var(--rule);
    background: var(--paper); }
  .rail__label { writing-mode: horizontal-tb; transform: none; margin: 0 .8rem 0 0; }
  .rail__list { flex-direction: row; }
  .rail__chip { width: 1.8rem; height: 1.8rem; }
}

/* ---------- title page: type only, no media above the fold ---------- */
.titlepage {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  padding: 0 6vw; max-width: 78rem; margin: 0 auto;
}
.titlepage__mast { font-family: var(--mono); font-size: .8rem; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 3.4rem; }
.titlepage__mast .sep { color: var(--rule); margin: 0 .5em; }
.titlepage__claim {
  font-family: var(--serif); font-weight: 600; font-size: clamp(2.6rem, 7vw, 5.6rem);
  line-height: 1.04; letter-spacing: -.01em; margin: 0 0 2rem; max-width: 18ch;
}
.titlepage__lede { font-size: clamp(1rem, 1.6vw, 1.25rem); line-height: 1.55; color: var(--ink-soft); max-width: var(--measure); margin: 0 0 2.6rem; }
.titlepage__running { font-family: var(--mono); font-size: .85rem; color: var(--ink-faint); }
.titlepage__running a { color: var(--accent); }

/* authored silence — one quiet viewport before chapter one, a hard-cut threshold */
.silence { height: 92vh; background: var(--paper); }

/* ---------- chapters ---------- */
.chapter {
  position: relative;
  min-height: 100vh;
  padding: 8rem 6vw 6rem;
  max-width: 78rem; margin: 0 auto;
  border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; justify-content: center;
  opacity: .34; transform: translateY(18px);
  transition: opacity .6s cubic-bezier(.22,.61,.36,1), transform .6s cubic-bezier(.22,.61,.36,1);
}
.chapter.is-active { opacity: 1; transform: translateY(0); }
.chapter:nth-of-type(odd) { background: var(--paper-deep); }

.chapter__folio {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 1.6rem;
}
.chapter__lead {
  font-family: var(--serif); font-weight: 500; font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  line-height: 1.3; max-width: 26ch; color: var(--ink-soft);
}
.chapter__lead b { color: var(--ink); font-weight: 600; }
.chapter h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.2vw, 2.7rem); line-height: 1.12; margin: 0 0 1.3rem; max-width: 16ch; }
.chapter__body { font-size: 1.05rem; line-height: 1.65; color: var(--ink-soft); max-width: var(--measure); margin: 0 0 1.6rem; }
.chapter__body b { color: var(--ink); font-weight: 600; }
.chapter__body--wide { max-width: 52ch; }
.chapter__link { font-family: var(--mono); font-size: .88rem; }

.chapter--media { display: grid; grid-template-columns: 1.05fr .95fr; gap: 4rem; align-items: center; }
.chapter--reverse { grid-template-columns: .95fr 1.05fr; }
.chapter--reverse .chapter__col--text { order: 2; }
.chapter--reverse .chapter__col--media { order: 1; }
@media (max-width: 900px) {
  .chapter--media, .chapter--reverse { grid-template-columns: 1fr; gap: 2.4rem; }
  .chapter--reverse .chapter__col--text, .chapter--reverse .chapter__col--media { order: initial; }
}

.chapter__col--media { margin: 0; }
.chapter__col--media figcaption {
  font-family: var(--mono); font-size: .74rem; color: var(--ink-faint);
  margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: .7rem;
}

.hub-plate svg { width: 100%; height: auto; max-width: 22rem; }
.hub-ring path { stroke: var(--rule); }

.mini-diagram { display: flex; flex-direction: column; align-items: center; gap: .9rem; }
.mini-diagram__row { display: flex; gap: .8rem; }
.mini-diagram__row img { width: 1.8rem; height: 1.8rem; border-radius: .4rem; padding: .3rem; background: var(--paper); border: 1px solid var(--rule); }
.mini-diagram__hub {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .1em; color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: .6rem; padding: .5rem 1.2rem; background: var(--paper);
}

.funnel { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; font-family: var(--mono); font-size: .85rem; }
.funnel__step { border: 1px solid var(--rule); border-radius: .5rem; padding: .6rem 1rem; color: var(--ink-soft); }
.funnel__step--accent { border-color: var(--accent); color: var(--accent); }
.funnel__arrow { color: var(--ink-faint); }
.funnel__arrow--accent { color: var(--accent); }

/* ---------- peak: chapter V ---------- */
.chapter--peak { padding-bottom: 9rem; }
.assembly {
  margin-top: 3rem; padding-top: 3rem; border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1.2rem;
}
.assembly__cue { font-family: var(--mono); font-size: .82rem; color: var(--ink-faint); margin: 0; }
.assembly__hub {
  width: min(28rem, 90vw); height: auto;
  opacity: 0; transform: scale(.86);
  transition: opacity 1s cubic-bezier(.22,.61,.36,1), transform 1s cubic-bezier(.22,.61,.36,1);
}
.assembly.is-assembled .assembly__hub { opacity: 1; transform: scale(1); }
.assembly__resolve {
  font-family: var(--serif); font-weight: 600; font-size: 1.4rem; margin: 0;
  opacity: 0; transform: translateY(10px);
  transition: opacity .7s ease .3s, transform .7s ease .3s;
}
.assembly.is-assembled .assembly__resolve { opacity: 1; transform: translateY(0); }

/* ---------- colophon / close ---------- */
.colophon {
  padding: 8rem 6vw 4rem; max-width: 78rem; margin: 0 auto;
  border-top: 1px solid var(--rule);
}
.colophon h2 { font-family: var(--mono); font-size: 1.3rem; color: var(--accent); margin: 0 0 1.4rem; }
.colophon__running { font-size: 1rem; line-height: 1.7; color: var(--ink-soft); max-width: 52ch; margin: 0 0 4rem; }
.colophon__running a { display: inline-block; margin-top: .6rem; margin-right: 1.4rem; font-family: var(--mono); font-size: .9rem; }
.colophon__label { font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 1.4rem; }

.roster { list-style: none; margin: 0 0 3rem; padding: 0; display: flex; flex-wrap: wrap; gap: 1.6rem 2.2rem; align-items: center; }
.roster img { height: 1.5rem; width: auto; max-width: 6.5rem; filter: grayscale(1) opacity(.62); transition: filter .25s ease; }
.roster a:hover img, .roster a:focus-visible img { filter: grayscale(0) opacity(1); }

.colophon__about { margin: 0 0 3rem; }
.colophon__about a { font-size: 1rem; }

.masthead { display: flex; align-items: center; gap: 1.6rem; padding-top: 2rem; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: .82rem; }
.masthead__logo { opacity: .8; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .chapter, .rail__chip, .assembly__hub, .assembly__resolve, .flight-chip { transition: none !important; }
  .chapter { opacity: 1; transform: none; }
}
