/* Page system for everything between the original hero and the original close.
   It speaks the hero's language: paper, ink, Inter, glass, the warped monad, gold for chip.
   Radius: 22px surfaces, 14px inner media, 999px controls. */

@font-face { font-family: Inter; src: url('../fonts/inter-latin.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: Inter; src: url('../fonts/inter-latin-ext.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF; }

html[data-theme]:not([data-shell='app']) {
  --night: #0e0d0b;
  --night-2: #171613;
  --night-3: #201f1b;
  --night-line: rgba(255, 255, 255, 0.08);
  --night-text: #f1f0eb;
  --night-dim: #a19e95;
  --late: #b4442c;
  --sheet-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 1px rgba(10, 10, 10, 0.06), 0 30px 60px -30px rgba(20, 20, 30, 0.22), 0 10px 24px -12px rgba(20, 20, 30, 0.1);
  --lift-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 1px rgba(10, 10, 10, 0.07), 0 50px 90px -40px rgba(20, 20, 30, 0.35), 0 18px 36px -18px rgba(20, 20, 30, 0.18);
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --gutter: clamp(20px, 4.5vw, 72px);
}

.ab { overflow-x: clip; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; }
img { display: block; max-width: 100%; height: auto; }

/* Headings speak like the hero wordmark: Inter 600, tight, ink gradient. */
.h {
  margin: 0; font-family: var(--sans); font-weight: 600;
  font-size: clamp(40px, 5.2vw, 84px); line-height: 0.98; letter-spacing: -0.045em;
  background: linear-gradient(180deg, #0a0a0a 0%, #2a2a2a 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-wrap: balance;
}
.mk-pin > .h { font-size: clamp(30px, 3.6vw, 56px); }
.h-quiet { -webkit-text-fill-color: var(--grey-3); color: var(--grey-3); }
/* On the dark panel the clipped gradient fringes on Windows: solid colour, no clip. */
.h--night { background: none; -webkit-background-clip: border-box; background-clip: border-box; -webkit-text-fill-color: #f1f0eb; color: #f1f0eb; }
.h--night .mk-pin > .h { font-size: clamp(30px, 3.6vw, 56px); }
.h-quiet { -webkit-text-fill-color: #8a867d; color: #8a867d; }
.lede { margin: 0; font-size: clamp(15px, 1.15vw, 17px); line-height: 1.55; color: var(--grey-1); max-width: 44ch; letter-spacing: -0.006em; }

/* Controls: the hero's pill language. */
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.72); border: 1px solid var(--hairline); color: var(--grey-1);
  font: 500 13.5px/1 var(--sans); letter-spacing: -0.005em; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 6px 16px -10px rgba(20, 20, 30, 0.18);
  backdrop-filter: blur(10px);
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out), border-color 200ms var(--ease-out), transform 160ms var(--ease-out);
}
.pill:active { transform: scale(0.97); }
.pill[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .pill:hover { border-color: var(--hairline-strong); color: var(--ink); } .pill[aria-pressed='true']:hover { color: #fff; } }
:focus-visible { outline: 2px solid rgba(201, 166, 97, 0.75); outline-offset: 3px; }

/* A sheet is the one surface: white, inner highlight, soft lifted shadow. */
.sheet { background: #fff; border-radius: 22px; box-shadow: var(--sheet-shadow); }

/* The warped monad, wherever it appears as an agent or as chip. */
.monad-svg { display: block; overflow: visible; }

/* Every chapter: generous, never cramped. Pinned chapters own a full viewport. */
.decay, .win, .mem, .rt, .orb, .tools, .lib, .os { position: relative; z-index: 1; }

.close-msg { min-height: 1.2em; margin: -12px 0 0; color: var(--grey-2); }
.close-msg.is-error { color: var(--late); }
.close-foot nav { display: flex; gap: 22px; flex-wrap: wrap; }
.close-foot nav a { color: var(--grey-2); padding: 12px 0; }
.close-foot nav a:hover { color: var(--ink); }

/* Reduced motion: anything that moves by itself stops. Scroll-linked changes stay, because the
   reader drives them, and short state cross-fades stay, because they carry meaning. */
@media (prefers-reduced-motion: reduce) {
  .mx__live i, .ev__stars i, .win__halo, .rt__caret, .amb { animation: none !important; }
}

/* The original stylesheet italicises every em and i in a serif. Inside the new chapters those
   elements are labels and bars, not emphasis, so they inherit the page type. */
.decay :is(i, em), .win :is(i, em), .mem :is(i, em), .team :is(i, em), .rt :is(i, em), .orb :is(i, em), .tools :is(i, em), .lib :is(i, em) { font-family: inherit; font-style: normal; }

/* Travelling Chip: above content, below the nav. Colour eases from ink (on the hero) to gold. */
.chip-travel { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform, opacity; }
.chip-travel svg { position: relative; z-index: 1; width: 100%; height: 100%; overflow: visible; }
.chip-travel .ct__ring { stroke: var(--chip, #0a0a0a); }
.chip-travel .ct__core { fill: var(--chip, #0a0a0a); }
.ct__glow { position: absolute; inset: -60%; border-radius: 50%; background: radial-gradient(circle, rgba(201, 166, 97, 0.35), transparent 65%); opacity: 0.8; }

/* Ambient: three soft colour fields drifting behind the page, tinted by the chapter in view.
   Discreet by design: low alpha, slow, transform-only, and still under reduced motion. */
@property --amb-1 { syntax: '<color>'; inherits: true; initial-value: rgba(201, 166, 97, 0.16); }
@property --amb-2 { syntax: '<color>'; inherits: true; initial-value: rgba(110, 192, 122, 0.10); }
@property --amb-3 { syntax: '<color>'; inherits: true; initial-value: rgba(180, 137, 232, 0.08); }
html { transition: --amb-1 1.6s var(--ease-out), --amb-2 1.6s var(--ease-out), --amb-3 1.6s var(--ease-out); }
html[data-tone='warm'] { --amb-1: rgba(232, 137, 111, 0.13); --amb-2: rgba(201, 166, 97, 0.12); --amb-3: rgba(91, 141, 239, 0.06); }
html[data-tone='gold'] { --amb-1: rgba(201, 166, 97, 0.2); --amb-2: rgba(232, 137, 111, 0.08); --amb-3: rgba(201, 166, 97, 0.08); }
html[data-tone='sage'] { --amb-1: rgba(110, 192, 122, 0.13); --amb-2: rgba(201, 166, 97, 0.1); --amb-3: rgba(91, 141, 239, 0.06); }
html[data-tone='dusk'] { --amb-1: rgba(91, 141, 239, 0.1); --amb-2: rgba(180, 137, 232, 0.1); --amb-3: rgba(201, 166, 97, 0.1); }
html[data-tone='sky'] { --amb-1: rgba(91, 141, 239, 0.1); --amb-2: rgba(110, 192, 122, 0.08); --amb-3: rgba(201, 166, 97, 0.1); }
html[data-tone='lilac'] { --amb-1: rgba(180, 137, 232, 0.12); --amb-2: rgba(232, 137, 111, 0.08); --amb-3: rgba(110, 192, 122, 0.08); }
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.amb { position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; filter: blur(70px); will-change: transform; }
.amb--a { left: -18vmax; top: -14vmax; background: radial-gradient(circle, var(--amb-1), transparent 66%); animation: amb-a 46s ease-in-out infinite alternate; }
.amb--b { right: -22vmax; top: 18vh; background: radial-gradient(circle, var(--amb-2), transparent 66%); animation: amb-b 58s ease-in-out infinite alternate; }
.amb--c { left: 18vw; bottom: -30vmax; background: radial-gradient(circle, var(--amb-3), transparent 66%); animation: amb-c 64s ease-in-out infinite alternate; }
@keyframes amb-a { to { transform: translate(14vw, 12vh) scale(1.12); } }
@keyframes amb-b { to { transform: translate(-12vw, 16vh) scale(0.92); } }
@keyframes amb-c { to { transform: translate(10vw, -14vh) scale(1.08); } }
.amb__grid { position: absolute; inset: 0; background-image: radial-gradient(rgba(10, 10, 10, 0.07) 1px, transparent 1.2px); background-size: 28px 28px; mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000, transparent 75%); opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .amb { animation: none; } }
