/* Deeper: the landing. One fixed stage; the page scroll only sets the depth. */

* { box-sizing: border-box; }
html { background: #0c0c0d; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
/* No CSS snapping: it pulled each small scroll back to the last chapter. home.js settles the dive instead. */
body { margin: 0; background: #0c0c0d; color: #f1efe9; font-family: "Literata", Georgia, serif; -webkit-font-smoothing: antialiased; }
.sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* The scroll length: one stop per chapter */
.track { position: relative; width: 100%; height: 100vh; pointer-events: none; }
.track i { position: absolute; left: 0; width: 1px; height: 1px; scroll-snap-align: start; }

/* The stage */
.stage {
  position: fixed; left: 0; top: 0; z-index: 1;
  width: 100%; height: 100%;
  overflow: hidden; overflow: clip;
  background: #b5875a;
  --mu: var(--u);
}
.stage.portrait { --mu: calc(var(--u) * 2.2); }

/* A chapter screen */
.plane {
  position: absolute; left: 0; top: 0;
  width: var(--W); height: var(--H);
  transform-origin: 0 0;
  overflow: hidden; overflow: clip;
  background: var(--tex);
  background-color: var(--bg);
  opacity: 0; pointer-events: none;
}
.plane.on { opacity: 1; pointer-events: auto; }
.plane.deep, .plane.deep a { cursor: zoom-in; }
.plane.on .pl-frame { cursor: zoom-in; }
.plane.last .pl-frame { cursor: default; }

.pl-bg { position: absolute; inset: 0; pointer-events: none; }
.pl-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .2;
  mix-blend-mode: luminosity;
  -webkit-mask-image: var(--fade); mask-image: var(--fade);
}
.w-smoke .pl-img, .w-polaroid .pl-img, .w-movies .pl-img { opacity: .17; }
.w-brick .pl-img { opacity: .14; }
.lay-0 { --fade: linear-gradient(to top left, #000 8%, transparent 62%); }
.lay-1 { --fade: linear-gradient(to bottom left, #000 8%, transparent 62%); }
.lay-2 { --fade: linear-gradient(to top right, #000 8%, transparent 62%); }
.lay-3 { --fade: linear-gradient(to bottom right, #000 8%, transparent 62%); }
.portrait .lay-0, .portrait .lay-2 { --fade: linear-gradient(to top, #000 10%, transparent 58%); }
.portrait .lay-1, .portrait .lay-3 { --fade: linear-gradient(to bottom, #000 10%, transparent 58%); }

/* The words, kept clear of the window */
.pl-text {
  position: absolute; z-index: 3;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: calc(var(--u) * .7);
}
.pl-text .pl-no { margin-bottom: calc(var(--u) * .35); }
.pl-text .pl-in { margin-top: calc(var(--u) * .5); }
.lay-0 .pl-text { left: calc(var(--uw) * .065); top: 15%; width: calc(var(--uw) * .5); }
.lay-1 .pl-text { left: calc(var(--uw) * .065); bottom: 10%; width: calc(var(--uw) * .45); }
.lay-2 .pl-text { left: calc(var(--uw) * .47); top: 15%; width: calc(var(--uw) * .49); }
.lay-3 .pl-text { left: calc(var(--uw) * .47); bottom: 10%; width: calc(var(--uw) * .49); }

.portrait .lay-0 .pl-text, .portrait .lay-2 .pl-text { left: calc(var(--uw) * .06); width: calc(var(--uw) * .88); top: 11%; bottom: auto; }
.portrait .lay-1 .pl-text, .portrait .lay-3 .pl-text { left: calc(var(--uw) * .06); width: calc(var(--uw) * .88); bottom: 4.5%; top: auto; }
.portrait .pl-text { gap: calc(var(--u) * 2.2); }
.portrait .pl-text .pl-no { margin-bottom: 0; }
.portrait .pl-text .pl-in { margin-top: calc(var(--u) * 1); }
.portrait .pl-no { font-size: calc(var(--u) * 19 * var(--nf) * var(--fit, 1)); }
.portrait .pl-title { font-size: calc(var(--u) * 10.6 * var(--tf) * var(--fit, 1)); }
.portrait .pl-tag { font-size: max(16px, calc(var(--u) * 4.3)); }
.portrait .pl-kind { font-size: 12px; }
.portrait .pl-in { font-size: 13px; }
.portrait .w-mirror .pl-echo { font-size: calc(var(--u) * 10.6 * var(--tf) * var(--fit, 1) * .62); }

/* The window. Its place and lean are set from the script. */
.pl-frame {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: var(--fw); height: var(--fh);
  transform-origin: 0 0;
}

/* Glass over a chapter while it is still inside the window above it */
.pl-glass {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 calc(var(--pu) * 6) rgba(0, 0, 0, .5);
}
.g-w-mirror { background: linear-gradient(118deg, transparent 26%, rgba(255, 255, 255, .38) 33%, transparent 41%, transparent 60%, rgba(255, 255, 255, .24) 63%, transparent 68%); }
.g-w-smoke { background: linear-gradient(150deg, rgba(255, 236, 190, .28), rgba(255, 210, 140, .06) 38%, transparent 55%, rgba(255, 236, 190, .12)); }
.g-w-what { background: linear-gradient(125deg, rgba(255, 255, 255, .3), transparent 34%); }
.g-w-polaroid { background: radial-gradient(ellipse at 50% 45%, rgba(255, 214, 150, .08) 40%, rgba(40, 25, 0, .4)); }
.g-w-movies { background: radial-gradient(ellipse 70% 60% at 50% 0%, rgba(255, 240, 200, .24), transparent 70%); }
.g-w-silver, .g-w-brick, .g-w-life { box-shadow: inset 0 0 calc(var(--pu) * 7) rgba(0, 0, 0, .68); }

/* Marks: small things that belong to a world. Placed clear of the words by the script. */
.pl-mark { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; }
.pl-mark.hide { display: none; }
.pl-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mk-arrows { width: calc(var(--mu) * 5.6); height: calc(var(--mu) * 5.6); color: var(--ink); opacity: .8; }
.mk-beads { width: calc(var(--mu) * 15); height: calc(var(--mu) * 2.2); }
.mk-ring { width: calc(var(--mu) * 5.6); height: calc(var(--mu) * 2.6); }
.pl-stk {
  padding: .32em .7em .2em;
  font: 400 calc(var(--mu) * 2.3)/1 "Nanum Pen Script", cursive;
  color: #111; background: #fffdf7; border-radius: .22em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 10px rgba(0, 0, 0, .1);
  white-space: nowrap; transform: rotate(var(--rot, 0deg));
}
.pl-q {
  position: absolute; top: -6%; right: calc(var(--gr) + var(--uw) * .02);
  font: 800 calc(var(--H) * .82)/1 "Syne", sans-serif; color: rgba(13, 13, 13, .045);
}
.portrait .pl-q { top: auto; bottom: -4%; right: auto; left: -4%; font-size: calc(var(--W) * 1.1); }
.pl-wisp { position: absolute; bottom: 0; right: calc(var(--gr) + var(--uw) * .03); height: 92%; width: calc(var(--H) * .3); }
.portrait .pl-wisp { right: calc(var(--gr) + 4%); height: 60%; }

/* The name */
.hud {
  position: fixed; z-index: 20; left: 28px; top: 24px; margin: 0;
  pointer-events: none; color: #17110b;
  transition: color .35s ease;
}
.hud h1 { margin: 0; font: 600 15px/1.1 "Martian Mono", ui-monospace, monospace; letter-spacing: .16em; text-transform: uppercase; }
.hud p { margin: 7px 0 0; font: italic 400 15px/1.3 "Literata", Georgia, serif; opacity: .88; }

/* The depth gauge */
.gauge {
  position: fixed; z-index: 30; right: 20px; top: 20px;
  width: 222px; max-height: calc(100% - 40px);
  display: flex; flex-direction: column;
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: rgba(13, 13, 15, .8);
  color: #f1efe9;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28), inset 0 0 0 1px rgba(255, 255, 255, .1);
  font-family: "Martian Mono", ui-monospace, monospace;
}
.g-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 12px; }
.g-lab { margin-right: auto; align-self: center; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; opacity: .62; }
.g-no { font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.g-of { font-size: 11px; opacity: .62; }
.g-body { position: relative; flex: 0 1 auto; min-height: 0; }
.g-list { position: relative; z-index: 1; margin: 0; padding: 0; list-style: none; touch-action: none; }
.g-list li { height: var(--row, 34px); }
.g-list button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 100%; margin: 0; padding: 0 6px 0 20px;
  border: 0; border-radius: 8px; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.g-sw {
  flex: none; width: 12px; height: max(3px, calc(100% - 2px)); border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2);
  transition: transform .2s ease;
}
.g-n { flex: none; font-size: 11px; font-weight: 600; opacity: .55; font-variant-numeric: tabular-nums; }
.g-t { flex: 1 1 auto; min-width: 0; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .55; }
.g-list button[aria-current] .g-n, .g-list button[aria-current] .g-t { opacity: 1; }
.g-list button[aria-current] .g-sw { transform: scaleX(1.5); }
.g-list button:hover .g-n, .g-list button:hover .g-t { opacity: .95; }
.g-list button:focus-visible { outline: 2px solid #f1efe9; outline-offset: -2px; }
.g-band { position: absolute; left: 0; right: 0; top: 0; height: var(--row, 34px); border-radius: 8px; background: rgba(255, 255, 255, .09); pointer-events: none; }
.g-needle {
  position: absolute; left: 3px; top: 0; z-index: 2; width: 0; height: 0;
  border-style: solid; border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #f1efe9;
  pointer-events: none;
}
.g-bub { display: none; }
.g-dense .g-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.g-dense .g-n { font-size: 9px; }
.g-vdense .g-n { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }

.deeper {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; margin-top: 12px; padding: 0 16px;
  border: 0; border-radius: 999px;
  background: #f1efe9; color: #111;
  font: 600 12px/1 "Martian Mono", ui-monospace, monospace;
  letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.deeper svg { width: 18px; height: 18px; flex: none; transition: transform .3s ease; }
.deeper.up svg { transform: rotate(180deg); }
.deeper:hover { background: #fff; }
.deeper:focus-visible { outline: 2px solid #f1efe9; outline-offset: 3px; }

/* Middle widths: numbers only */
.g-mid .gauge { width: 84px; padding: 12px 8px 10px; }
.g-mid .g-head { justify-content: center; padding: 0 0 10px; }
.g-mid .g-lab, .g-mid .g-of { display: none; }
.g-mid .g-no { font-size: 24px; }
.g-mid .g-list button { padding: 0 2px 0 17px; gap: 7px; }
.g-mid .g-t, .g-mid .deeper-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.g-mid .deeper { padding: 0; }

/* Phones: a slim strip down the right edge */
.g-strip .gauge {
  right: 8px; top: 74px; width: 26px;
  max-height: calc(100% - 74px - 92px);
  padding: 5px 0; border-radius: 13px;
  background: rgba(13, 13, 15, .64);
}
.g-strip .g-list::before { content: ""; position: absolute; inset: -6px -8px -6px -16px; }
.g-strip .g-head, .g-strip .g-band { display: none; }
.g-strip .g-list button { padding: 0; justify-content: center; gap: 0; border-radius: 6px; }
.g-strip .g-n, .g-strip .g-t, .g-strip .deeper-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.g-strip .g-sw { width: 14px; }
.g-strip .g-needle { left: auto; right: calc(100% + 7px); width: auto; height: auto; border: 0; }
.g-strip .g-bub {
  display: block; padding: 5px 7px 4px; border-radius: 9px;
  background: #f1efe9; color: #111; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  font-size: 12px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.g-strip .deeper {
  position: fixed; right: 8px; bottom: 18px;
  width: 52px; height: 52px; margin: 0; padding: 0;
  border-radius: 50%; box-shadow: 0 6px 18px rgba(0, 0, 0, .32);
}
.g-strip .deeper svg { width: 22px; height: 22px; }
.g-strip .hud { left: 16px; top: 16px; }
.g-strip .hud h1 { font-size: 13px; }
.g-strip .hud p { font-size: 15px; margin-top: 5px; }
.gauge.drag .g-list { cursor: grabbing; }

@media (prefers-reduced-motion: reduce) {
  .hud, .g-sw, .deeper svg { transition: none; }
}

/* Phones: each chapter screen gets its own layer, so zooming it does not repaint its background every frame. */
@media (max-width: 820px), (pointer: coarse) {
  .plane { will-change: transform; }
}
