/* SYNAPSE — Connects.so Field Notes № 01
   Self-hosted type, no framework, no build step. */

:root {
  --ink:      #0e151c;
  --ink-2:    #16202a;
  --bone:     #eef3ef;
  --bone-dim: #bcc7c2;
  --muted:    #98a5a0;
  --line:     rgba(238, 243, 239, .19);
  --line-soft:rgba(238, 243, 239, .10);

  --bio:      #6bff9e;
  --teal:     #17b8ad;
  --teal-hi:  #4fe6da;
  --violet:   #9a6bff;
  --amber:    #ffa955;

  --accent:   var(--teal);

  --pad:   clamp(20px, 3.6vw, 62px);
  --nav-h: 78px;
  --ease:    cubic-bezier(.22, .61, .36, 1);
  --ease-out:cubic-bezier(.16, 1, .3, 1);
}

/* chapter-reactive accent */
[data-chapter="0"] { --accent: var(--bone); }
[data-chapter="1"] { --accent: var(--bio); }
[data-chapter="2"] { --accent: var(--teal-hi); }
[data-chapter="3"] { --accent: var(--amber); }
[data-chapter="4"] { --accent: var(--violet); }
[data-chapter="5"] { --accent: var(--teal); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: 'Onest', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

::selection { background: var(--accent); color: var(--ink); }

.skip {
  position: fixed; top: 10px; left: 10px; z-index: 120;
  padding: 11px 16px; background: var(--bone); color: var(--ink);
  font-size: 13px; text-decoration: none; transform: translateY(-220%);
}
.skip:focus { transform: none; }
:where(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ── type ────────────────────────────────────────────────────── */

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.028em; line-height: .98; }

.display { text-wrap: balance; }
.h-hero { font-size: clamp(33px, 6.1vw, 90px); }
.h-sec  { font-size: clamp(29px, 4.9vw, 74px); }
.h-man  { font-size: clamp(30px, 4vw, 60px); }

.lead {
  font-size: clamp(15px, 1.18vw, 19px); line-height: 1.68;
  color: #d7e0da; font-weight: 300;
}
.lead b, .body b { font-weight: 400; color: var(--bone); }
.body {
  font-size: clamp(14px, 1.02vw, 16px); line-height: 1.78;
  color: var(--bone-dim); font-weight: 300;
}
.ko, [lang="ko"] {
  font-family: 'Onest', 'Pretendard Variable', Pretendard,
               'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  word-break: keep-all;
}

.num {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: 0;
}

.k, .eyebrow, .cue, .readout dt, .rail, .nav-link, .foot-nav a, .foot-fine, .pre-meta {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400; letter-spacing: .16em; text-transform: uppercase;
}

/* ── environment layers ──────────────────────────────────────── */

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(10, 16, 22, .92) 0%, rgba(10, 16, 22, .72) 28%, rgba(10, 16, 22, .18) 50%, transparent 63%),
    linear-gradient(180deg, rgba(10, 16, 22, .68) 0%, transparent 13%),
    radial-gradient(140% 100% at 52% 45%, transparent 44%, rgba(8, 13, 18, .55) 100%);
}
#grain {
  position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: .032;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

/* ── cursor ──────────────────────────────────────────────────── */

.cur { display: none; }
@media (pointer: fine) {
  .cur {
    display: block; position: fixed; top: 0; left: 0; z-index: 110;
    width: 0; height: 0; pointer-events: none; mix-blend-mode: difference;
  }
  .cur i, .cur b {
    position: absolute; left: 50%; top: 50%; translate: -50% -50%;
    border-radius: 50%; border: 1px solid var(--bone);
  }
  .cur i { width: 5px; height: 5px; background: var(--bone); border: 0; }
  .cur b {
    width: 30px; height: 30px; opacity: .42;
    transition: width .3s var(--ease-out), height .3s var(--ease-out), opacity .3s var(--ease);
  }
  .cur.hot b { width: 58px; height: 58px; opacity: .85; }
  body, a, button { cursor: none; }
}

/* ── preloader ───────────────────────────────────────────────── */

#pre {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; background: var(--ink);
  transition: opacity .9s var(--ease), visibility .9s;
}
#pre.gone { opacity: 0; visibility: hidden; }
.pre-in { width: min(320px, 76vw); text-align: center; }
.pre-mark { width: 46px; margin: 0 auto 26px; }
.pre-mark svg { width: 100%; display: block; animation: turn 9s linear infinite; }
@keyframes turn { to { rotate: 360deg; } }
.pre-ko {
  font-size: 26px; font-weight: 600; letter-spacing: .5em; text-indent: .5em;
  color: var(--bone); margin-bottom: 30px;
}
/* the wordmark fills instead of a bar: the logo's own alpha masks a solid
   accent, clipped to the load percentage, so the brand is the progress. */
.pre-logo { position: relative; width: clamp(180px, 22vw, 260px); margin: 0 auto; }
.pre-logo img { display: block; width: 100%; height: auto; opacity: .16; }
.pre-fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--teal-hi), var(--bio));
  -webkit-mask: url("../logo-light.png") left top / 100% 100% no-repeat;
          mask: url("../logo-light.png") left top / 100% 100% no-repeat;
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0);
  transition: clip-path .4s cubic-bezier(.4, 0, .2, 1);
}
.pre-meta {
  display: flex; justify-content: center; gap: 14px; margin-top: 22px;
  font-size: 9.5px; color: var(--muted);
}
.pre-meta b { color: var(--bone-dim); font-weight: 400; }

/* ── nav ─────────────────────────────────────────────────────── */

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad);
  border-bottom: 1px solid transparent;
  transition: background .6s var(--ease), border-color .6s var(--ease), backdrop-filter .6s;
}

/* the wordmark is the logo; nothing else sits in the header */
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: clamp(112px, 9vw, 150px); height: auto; }

.nav-links { display: flex; gap: clamp(14px, 2.2vw, 34px); }
.nav-link {
  position: relative; display: block; overflow: hidden; height: 13px;
  font-size: 10.5px; color: var(--bone-dim); text-decoration: none;
}
.nav-link span { display: block; transition: transform .45s var(--ease-out), color .45s var(--ease); }
.nav-link .alt { position: absolute; inset: 0; transform: translateY(105%); color: var(--accent); letter-spacing: .1em; }
.nav-link:hover span:first-child, .nav-link[aria-current="true"] span:first-child { transform: translateY(-105%); }
.nav-link:hover .alt, .nav-link[aria-current="true"] .alt { transform: none; }

.burger { display: none; }

/* ── chapter rail ────────────────────────────────────────────── */

.rail { position: fixed; right: clamp(12px, 1.8vw, 26px); top: 50%; translate: 0 -50%; z-index: 90; }
.rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  text-decoration: none; color: var(--muted); font-size: 9.5px;
}
.rail b { font-weight: 400; transition: color .4s var(--ease); }
.rail em {
  font-style: normal; max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
  transition: max-width .55s var(--ease-out), opacity .4s var(--ease);
}
.rail a::after {
  content: ""; width: 18px; height: 1px; background: currentColor; opacity: .4;
  transition: width .5s var(--ease-out), background .5s var(--ease), opacity .5s;
}
.rail a[aria-current="true"] { color: var(--bone); }
.rail a[aria-current="true"] em { max-width: 160px; opacity: .75; }
.rail a[aria-current="true"]::after { width: 40px; background: var(--accent); opacity: 1; }

/* ── page shell ──────────────────────────────────────────────── */

.page { position: relative; z-index: 10; }

.hero, .sec {
  position: relative;
  min-height: 150vh;
  padding: calc(var(--nav-h) + 12vh) var(--pad) 20vh;
}
.hero { min-height: 148vh; display: flex; flex-direction: column; }

/* ── mask-line heading reveal ────────────────────────────────── */

.ml { display: block; overflow: hidden; padding-bottom: .06em; }
.ml > span { display: block; transform: translateY(108%); }
.reveal-on .ml > span {
  transition: transform 1.15s var(--ease-out);
  transition-delay: calc(var(--l, 0) * 105ms);
}
.in .ml > span { transform: none; }

/* generic reveals — hidden only once the module confirms it is alive */
.reveal-on [data-rv] { opacity: 0; }
.reveal-on [data-rv="up"] { transform: translateY(26px); }
.reveal-on [data-rv] {
  transition: opacity 1s var(--ease), transform 1s var(--ease-out);
  transition-delay: calc(var(--l, 0) * 95ms);
}
.reveal-on [data-rv].in { opacity: 1; transform: none; }

/* ── hero ────────────────────────────────────────────────────── */

.word-fb {
  position: absolute; left: 0; right: 0; bottom: 6vh; z-index: -1;
  font-size: 17.4vw; line-height: .74; font-weight: 700; letter-spacing: .04em;
  text-align: center; color: rgba(228, 233, 228, .028);
  pointer-events: none; user-select: none;
}

.hero-top { max-width: 920px; }
.eyebrow { margin: 0 0 26px; font-size: 10px; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.h-hero { margin-bottom: 32px; }
.hero-sub { max-width: 50ch; }
.hero-sub sup { font-size: .62em; vertical-align: super; }

.hero-foot { margin-top: auto; padding-top: 12vh; }
.cue { margin: 0 0 34px; font-size: 9.5px; color: var(--muted); display: flex; align-items: center; gap: 14px; }
.cue .track { width: 62px; height: 1px; background: var(--line); position: relative; overflow: hidden; }
.cue .track i { position: absolute; inset: 0 auto 0 0; width: 20px; background: var(--accent); animation: trace 3s var(--ease) infinite; }
@keyframes trace { 0% { translate: -100% 0; } 100% { translate: 320% 0; } }




/* ── section chrome ──────────────────────────────────────────── */

.sec-head {
  display: flex; align-items: center; gap: 18px; margin: 0 0 44px;
  font-size: 10px; color: var(--bone-dim);
}
.sec-head .k b { color: var(--accent); font-weight: 400; }
/* the rule is also the chapter's progress track */
.sec-head .rule {
  flex: 1; max-width: 320px; height: 1px;
  background: linear-gradient(90deg,
    var(--accent) var(--p, 0%), var(--line) var(--p, 0%));
}
.sec-head .ko { letter-spacing: .3em; color: var(--muted); }

/* the chapter is one title. it stays pinned while the structure works through
   its state, and every part of that — arriving, holding, leaving — is driven by
   the same fractional chapter index the camera uses. no observers, no one-shot
   reveals: scroll back up and it plays in reverse. */
.head-only {
  max-width: 880px;
  position: sticky; top: calc(var(--nav-h) + 9vh);
  opacity: var(--vis, 1);
  translate: 0 var(--y, 0px);
  will-change: opacity, translate;
}
/* the observer-driven rule parks these at translateY(108%) until .in lands;
   chapter headings are no longer observed, so clear it and drive `translate`
   from the scroll value instead */
.head-only .ml > span {
  transform: none;
  translate: 0 calc((1 - var(--e, 1)) * 112%);
}
.reveal-on .head-only .ml > span { transition: none; }
.h-sec { margin-bottom: 0; }
.copy { display: grid; gap: 20px; }
.copy .lead { margin: 0; }
.copy .body { margin: 0; }

.arrowlink {
  display: inline-flex; align-items: center; gap: 12px; margin-top: 8px;
  color: var(--bone); text-decoration: none; font-size: 13px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; width: fit-content;
  transition: border-color .45s var(--ease), color .45s var(--ease);
}
.arrowlink .ar {
  width: 22px; height: 22px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; color: var(--accent);
  transition: transform .45s var(--ease-out), border-color .45s var(--ease);
}
.arrowlink svg { width: 11px; }
.arrowlink:hover { border-bottom-color: var(--accent); color: var(--accent); }
.arrowlink:hover .ar { transform: translate(3px, -3px); border-color: var(--accent); }

/* ledger readout: one rule, then label over value. no cells, no fills. */
.readout {
  display: grid; gap: 26px 44px; margin: clamp(56px, 8vw, 110px) 0 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
  padding-top: 20px; border-top: 1px solid var(--line);
  max-width: min(680px, 52vw);
}
.readout.wide {
  max-width: 1180px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 208px), 1fr));
}
.readout div { min-width: 0; }
.readout a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.readout a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.readout dt {
  font-size: 9px; color: var(--muted); margin-bottom: 10px;
  text-transform: none; letter-spacing: .14em;
}
.readout dd {
  margin: 0; font-size: clamp(17px, 1.5vw, 21px); color: var(--bone);
  letter-spacing: -.01em; overflow-wrap: anywhere;
}


/* ── manifesto + footer ──────────────────────────────────────── */

/* the closing section has to land on the footer without a seam: the gradient
   used to stop at .94 alpha against an opaque footer, and both carried a
   border-top, so the canvas got cut off on a hard line. it now reaches full
   ink before the footer starts and neither draws a rule. */
.manifesto {
  position: relative; z-index: 10;
  padding: 22vh var(--pad) 18vh;
  background: linear-gradient(180deg,
    transparent 0%, rgba(14, 21, 28, .55) 30%, rgba(14, 21, 28, .9) 58%, var(--ink) 82%);
}
.h-man { margin: 0 0 clamp(34px, 4vw, 56px); }
.manifesto .readout { margin-top: 0; margin-bottom: clamp(40px, 5vw, 68px); }
.man {
  list-style: none; margin: 0; padding: 24px 0 0; max-width: 1180px;
  border-top: 1px solid var(--line);
  display: grid; gap: 34px 56px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 262px), 1fr));
}
.man li { display: grid; gap: 12px; }
.man .num { font-size: 10px; letter-spacing: .18em; color: var(--accent); }
.man p { margin: 0; font-size: 14.5px; line-height: 1.8; color: var(--bone-dim); }

.foot {
  position: relative; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 26px 40px;
  align-items: center; justify-content: space-between;
  padding: 12vh var(--pad) 8vh;
  background: var(--ink);
}
.foot-brand img { display: block; width: clamp(126px, 10vw, 168px); height: auto; opacity: .9; }
.foot-nav { display: flex; gap: 26px; }
.foot-nav a { font-size: 10px; color: var(--bone-dim); text-decoration: none; transition: color .4s var(--ease); }
.foot-nav a:hover { color: var(--accent); }

/* the structure owns the right of the frame once there is room for it */
@media (min-width: 1081px) {
  .hero-top { max-width: min(920px, 58vw); }
  .head-only { max-width: min(880px, 56vw); }
}

/* ── responsive ──────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .head-only { max-width: none; position: static; }
  }

@media (max-width: 780px) {
  .rail { display: none; }
  .hero, .sec { min-height: 150vh; padding-top: calc(var(--nav-h) + 8vh); }
  .word-fb { font-size: 22vw; bottom: 3vh; }

  #vignette {
    background:
      linear-gradient(180deg, rgba(14, 21, 28, .8) 0%, rgba(14, 21, 28, .4) 26%, rgba(14, 21, 28, .3) 100%),
      radial-gradient(150% 90% at 50% 45%, transparent 44%, rgba(14, 21, 28, .42) 100%);
  }

  .burger {
    display: grid; place-content: center; gap: 6px;
    width: 42px; height: 42px; margin-right: -10px;
    background: none; border: 0; padding: 0;
  }
  .burger i { display: block; width: 22px; height: 1px; background: var(--bone); transition: transform .4s var(--ease), opacity .3s; }
  .burger[aria-expanded="true"] i:first-child { transform: translateY(3.5px) rotate(45deg); }
  .burger[aria-expanded="true"] i:last-child { transform: translateY(-3.5px) rotate(-45deg); }

  .nav-links {
    position: fixed; inset: 0 0 auto 0; flex-direction: column; gap: 0;
    padding: calc(var(--nav-h) + 8px) var(--pad) 28px;
    background: rgba(14, 21, 28, .97); border-bottom: 1px solid var(--line);
    transform: translateY(-100%); transition: transform .55s var(--ease-out);
  }
  .nav-links.open { transform: none; }
  .nav-link { height: auto; padding: 17px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
  .nav-link .alt { position: static; transform: none; display: inline; margin-left: 12px; opacity: .55; }
  .nav-link:hover span:first-child, .nav-link[aria-current="true"] span:first-child { transform: none; }

  .foot { grid-template-columns: 1fr; }

  /* the model list needs its own row once the third column stops fitting */
  .toc a { grid-template-columns: 2.4em minmax(0, 1fr); }
  .toc .m { grid-column: 2; text-align: left; white-space: normal; margin-top: 8px; }
}

/* ── reduced motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal-on [data-rv], .ml > span { opacity: 1 !important; transform: none !important; }
  .cue .track i, .pre-mark svg { animation: none; }
  * { transition-duration: .01s !important; }
}

/* ── closing hand-off ────────────────────────────────────────── */

.close-links { display: flex; flex-wrap: wrap; gap: 14px; margin: clamp(36px, 5vw, 60px) 0 0; }
.cta, .ghost {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; text-decoration: none; font-size: 13.5px;
  border: 1px solid var(--line); transition: background .4s var(--ease),
    border-color .4s var(--ease), color .4s var(--ease);
}
.cta { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.cta:hover { background: transparent; color: var(--accent); }
.ghost { color: var(--bone); }
.ghost:hover { border-color: var(--accent); color: var(--accent); }
