/* ------------------------------------------------------------------ *
 * The Shape of Interfaces to Come — its own world.
 *
 * A pale acoustics laboratory: cool daylight ground, ink type, one
 * electric ultramarine, and an inverted passage at the close.
 * Deliberately unlike the home page (dark petrol specimen) and the LoRA
 * article (black keynote) — each article is its own artifact.
 *
 * This is a long read: ~130 paragraphs, 35 figures, 19 pull quotes. The
 * layout is built around a comfortable measure with figures allowed to
 * break wider than the text.
 * ------------------------------------------------------------------ */

:root {
  --paper: #e7eaee;
  --plate: #f5f7f9;
  --tint: #dde3ea;
  --ink: #0c1016;
  --ink-2: #2c3541;
  --ink-mid: #5b6672;
  --rule: rgba(12, 16, 22, 0.14);
  --rule-soft: rgba(12, 16, 22, 0.08);
  --accent: #2440ff;

  --ink-plate: #0c1016;
  --on-ink: #eef1f5;
  --on-ink-mid: #99a3b0;
  --rule-ink: rgba(238, 241, 245, 0.16);

  --display: 'Clash Display', 'Segoe UI', system-ui, sans-serif;
  --text: 'Switzer', 'Segoe UI', system-ui, sans-serif;

  --s--1: clamp(0.78rem, 0.75rem + 0.14vw, 0.86rem);
  --s-0: clamp(1.02rem, 0.98rem + 0.2vw, 1.14rem);
  --s-1: clamp(1.18rem, 1.08rem + 0.5vw, 1.45rem);
  --s-2: clamp(1.5rem, 1.25rem + 1.1vw, 2.1rem);
  --s-3: clamp(2rem, 1.45rem + 2.4vw, 3.4rem);
  --s-4: clamp(2.9rem, 1.6rem + 5.6vw, 7rem);

  --pad: clamp(1.15rem, 4vw, 4rem);
  --max: 1240px;
  --measure: 68ch;
  --bar: 3.25rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scrollbar-color: #b9c2cc var(--paper); scroll-padding-top: calc(var(--bar) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--s-0);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.02; letter-spacing: -0.02em; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
ol, ul { list-style: none; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--pad); }

.skip {
  position: fixed; z-index: 90; top: .5rem; left: .5rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  font-size: var(--s--1); letter-spacing: .12em; text-transform: uppercase;
  text-decoration: none; transform: translateY(-160%); transition: transform .25s var(--ease);
}
.skip:focus-visible { transform: none; }

/* ---------- topbar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 60; height: var(--bar);
  display: flex; align-items: center; gap: 1.5rem; padding: 0 var(--pad);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule-soft);
}
.topbar__home {
  display: inline-flex; align-items: center; gap: .4rem; text-decoration: none;
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mid);
  white-space: nowrap; transition: color .25s;
}
.topbar__home:hover { color: var(--ink); }
.topbar__home svg { width: .8rem; flex: none; }
.topbar__nav { margin-left: auto; display: flex; gap: 1.4rem; }
.topbar__nav a { color: var(--ink-mid); text-decoration: none; font-size: .8rem; white-space: nowrap; transition: color .2s; }
.topbar__nav a:hover, .topbar__nav a.active { color: var(--accent); }
.topbar__progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.topbar__progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 100svh; display: flex; align-items: center;
  padding-block: calc(var(--bar) + 4rem) 5rem; overflow: clip;
}
.hero__canvas { position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity 1.2s var(--ease); }
.hero__canvas[data-ready='true'] { opacity: 1; }
.hero__canvas canvas { width: 100% !important; height: 100% !important; display: block; }
.hero__inner { position: relative; z-index: 2; }

.eyebrow {
  display: flex; align-items: center; gap: .85em; max-width: 22rem;
  font-size: var(--s--1); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-mid);
}
.eyebrow__rule { flex: 1; height: 1px; background: var(--rule); }

.hero__title {
  font-size: var(--s-4); font-weight: 600; letter-spacing: -0.035em; line-height: 0.9;
  margin-top: clamp(1.4rem, 4vh, 2.6rem); text-wrap: balance;
}
.hero__deck {
  margin-top: clamp(1.2rem, 3vh, 1.9rem); max-width: 44ch;
  font-size: var(--s-1); line-height: 1.5; color: var(--ink-2);
}
.meta { display: flex; flex-wrap: wrap; gap: clamp(1.2rem, 4vw, 3rem); margin-top: clamp(1.8rem, 5vh, 3rem); }
.meta dt { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-mid); }
.meta dd { font-family: var(--display); font-weight: 500; font-size: var(--s-1); margin-top: .2rem; }

.origin {
  display: inline-flex; align-items: center; gap: .55rem; margin-top: clamp(1.6rem, 4vh, 2.4rem);
  padding: .75rem 1.2rem; border: 1px solid var(--ink); border-radius: 999px;
  font-size: var(--s--1); letter-spacing: .1em; text-transform: uppercase; text-decoration: none;
  transition: background .3s var(--ease), color .3s var(--ease);
}
.origin:hover { background: var(--ink); color: var(--paper); }
.origin svg { width: .85rem; }

.hero__cue {
  position: absolute; left: 50%; bottom: 1.6rem; transform: translateX(-50%);
  font-size: .68rem; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-mid);
  animation: cue 2.6s ease-in-out infinite;
}
@keyframes cue { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hero__cue { animation: none; } }

/* ---------- the article ---------- */
.article { position: relative; background: var(--paper); padding-block: clamp(3rem, 9vh, 6rem) clamp(4rem, 11vh, 8rem); }

/* Everything in the reading column shares one measure; figures opt out below. */
.article p,
.article .sub,
.article .quote,
.article .list,
.article .embed,
.opening p,
.toc { max-width: var(--measure); }

.article p { margin-top: 1.15em; color: var(--ink-2); }
.article p a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(36, 64, 255, .35); }
.article p a:hover { border-color: var(--accent); }
.article strong { font-weight: 600; color: var(--ink); }
.article em { font-style: italic; }

.opening { border-left: 2px solid var(--accent); padding-left: clamp(1rem, 2.5vw, 1.8rem); }
.opening p { font-size: var(--s-1); line-height: 1.55; color: var(--ink); margin-top: 1em; }
.opening p:first-child { margin-top: 0; }

/* ---------- contents ---------- */
.toc {
  margin-top: clamp(2.5rem, 7vh, 4rem);
  padding: clamp(1.2rem, 3vw, 1.8rem) clamp(1.2rem, 3vw, 2rem);
  background: var(--plate); border: 1px solid var(--rule-soft);
}
.toc__title { font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-mid); margin-bottom: .9rem; }
.toc__list { display: grid; gap: .1rem; counter-reset: none; }
.toc__item a {
  display: block; padding: .28rem 0; text-decoration: none; color: var(--ink-2);
  font-size: var(--s--1); transition: color .2s;
}
.toc__item a:hover { color: var(--accent); }
.toc__item--h3 a { font-family: var(--display); font-weight: 600; font-size: var(--s-0); color: var(--ink); }
.toc__item--h3 + .toc__item--h4 { margin-top: .2rem; }
.toc__item--h4 a { padding-left: 1.1rem; border-left: 1px solid var(--rule); }

/* ---------- chapters ---------- */
.chapter { margin-top: clamp(4rem, 11vh, 7rem); }
.chapter__mark { display: flex; align-items: center; gap: 1.1em; max-width: none; }
.chapter__mark span:first-child {
  font-family: var(--display); font-weight: 500; font-size: var(--s--1);
  letter-spacing: .14em; color: var(--accent);
}
.chapter__rule { flex: 1; height: 1px; background: var(--rule); }
.chapter__title { font-size: var(--s-3); margin-top: 1.2rem; max-width: 18ch; text-wrap: balance; }

.sub {
  font-family: var(--display); font-weight: 600; font-size: var(--s-2);
  margin-top: clamp(2.4rem, 6vh, 3.4rem); letter-spacing: -0.02em;
}
.sub + p { margin-top: .8em; }

/* ---------- figures ---------- */
.fig { margin-top: clamp(2rem, 5vh, 3rem); max-width: min(100%, 60rem); }
.fig img { width: 100%; border: 1px solid var(--rule-soft); background: var(--plate); }
.fig figcaption { margin-top: .8rem; font-size: var(--s--1); color: var(--ink-mid); max-width: var(--measure); }
.fig figcaption a { color: var(--ink-mid); }

/* ---------- quotes ---------- */
.quote {
  margin-top: clamp(1.6rem, 4vh, 2.4rem);
  padding: 1.1rem 0 1.1rem clamp(1rem, 2.5vw, 1.6rem);
  border-left: 2px solid var(--accent);
  font-family: var(--display); font-weight: 400; font-size: var(--s-1);
  line-height: 1.45; color: var(--ink); letter-spacing: -0.01em;
}
.quote a { color: var(--accent); }

/* ---------- lists ---------- */
.list { margin-top: 1.2em; display: grid; gap: .5rem; }
.list li { position: relative; padding-left: 1.3rem; color: var(--ink-2); }
.list li::before {
  content: ''; position: absolute; left: 0; top: .72em;
  width: .42rem; height: .42rem; background: var(--accent);
}

/* ---------- click-to-load embeds ---------- */
.embed { margin-top: clamp(1.8rem, 4vh, 2.6rem); }
.embed__btn {
  position: relative; display: block; width: 100%; padding: 0; overflow: hidden;
  border: 1px solid var(--rule); background: var(--plate); cursor: pointer;
  aspect-ratio: 16 / 9; text-align: left;
}
.embed__poster { width: 100%; height: 100%; object-fit: cover; filter: saturate(.9) brightness(.94); transition: filter .5s var(--ease), transform 1s var(--ease); }
.embed__btn:hover .embed__poster { filter: none; transform: scale(1.03); }
.embed__scrim { position: absolute; inset: 0; background: linear-gradient(to top, rgba(12,16,22,.6), rgba(12,16,22,0) 55%); }
.embed__label {
  position: absolute; left: 0; bottom: 0; display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.1rem; color: #fff; font-size: var(--s--1);
  letter-spacing: .12em; text-transform: uppercase;
}
.embed__play {
  width: 1.6rem; height: 1.6rem; flex: none; border-radius: 50%;
  background: var(--accent); position: relative;
}
.embed__play::after {
  content: ''; position: absolute; left: 54%; top: 50%; transform: translate(-50%, -50%);
  border-left: .5rem solid #fff; border-top: .32rem solid transparent; border-bottom: .32rem solid transparent;
}
.embed__frame { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--rule); display: block; }

/* Audio has no poster: a drawn waveform stands in for one. */
.embed--audio .embed__btn { aspect-ratio: auto; height: 5.5rem; background: var(--ink-plate); border-color: var(--ink-plate); }
.embed--audio .embed__label { position: static; padding: 0 1.1rem; height: 100%; color: var(--on-ink); text-transform: none; letter-spacing: .02em; }
.embed__wave {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(238,241,245,.16) 0 2px, transparent 2px 7px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.embed--audio .embed__frame { aspect-ratio: auto; height: 10rem; }
.embed-fallback { margin-top: 1.2em; }

/* ---------- close ---------- */
.close { background: var(--ink-plate); color: var(--on-ink); padding-block: clamp(4rem, 10vh, 7rem); }
.close__kicker { font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: var(--on-ink-mid); }
.close__line { font-family: var(--display); font-weight: 500; font-size: var(--s-2); margin-top: 1rem; max-width: 34ch; line-height: 1.2; }
.close__line a { color: #8f9dff; text-decoration: none; border-bottom: 1px solid rgba(143,157,255,.4); }
.close__line a:hover { color: #fff; border-color: #fff; }
.close__note { margin-top: 1.4rem; max-width: 56ch; font-size: var(--s--1); color: var(--on-ink-mid); }
.close__nav { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: clamp(2.5rem, 6vh, 3.5rem); padding-top: 1.5rem; border-top: 1px solid var(--rule-ink); }
.close__nav a { font-size: var(--s--1); letter-spacing: .16em; text-transform: uppercase; text-decoration: none; color: var(--on-ink-mid); transition: color .25s; }
.close__nav a:hover { color: #fff; }

/* ---------- reveal ---------- */
[data-in] { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .9s var(--ease); }
[data-in].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-in] { opacity: 1; transform: none; transition: none; } }

@media (max-width: 900px) {
  .topbar__nav { display: none; }
  .chapter__title { max-width: none; }
}
