:root {
  --bg: #fdfdfb;
  --ink: #1c1c1a;
  --muted: #75756f;
  --faint: #6b6b66;
  --rule: #e4e4de;
  --plank: #f0f0ea;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[role="button"], a, .bk { touch-action: manipulation; }
html.reading, html.reading body { overflow: hidden; }
html, body { margin: 0; background: var(--bg); transition: background-color .7s ease; }
a { color: var(--ink); text-decoration: none; }
a:hover, [role="button"]:hover { color: #9a9a94; }
.mono { font-family: 'DM Mono', ui-monospace, monospace; letter-spacing: 0; }
.muted { color: var(--muted); }

.root {
  position: relative; min-height: 100vh; overflow: hidden;
  background-color: var(--tint, var(--bg)); color: var(--ink);
  transition: background-color .7s ease;
  font-family: 'Bricolage Grotesque', Helvetica, sans-serif;
  font-size: clamp(17px, 1.5vw, 26px); line-height: 1.08; letter-spacing: -0.01em;
}
.root.custom-cursor, .root.custom-cursor * { cursor: none !important; }

.page {
  display: grid; grid-template-columns: minmax(280px, 26%) minmax(0, 1fr);
  gap: 24px; min-height: 100vh; padding: 12px 14px;
  transition: transform .7s cubic-bezier(.7,0,.2,1), opacity .5s ease;
}
.col-index { display: flex; flex-direction: column; gap: 1.6em; }
.nav { display: flex; flex-direction: column; align-items: flex-start; }
.nav a { cursor: pointer; }
.foot { margin-top: auto; }
.list-row {
  display: grid; grid-template-columns: 2.4em minmax(0,1fr); padding-left: .9em; cursor: pointer;
  transition: color .15s ease, transform .3s cubic-bezier(.3,1.5,.5,1);
}
.list-row .mono { font-size: .92em; }
.list-row.dim { color: var(--muted); }
.list-row.on { transform: translateX(.5em); }

.col-shelf { display: flex; flex-direction: column; min-width: 0; }
.col-shelf .stage { margin: auto 0; }
.shelf-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.tagline { max-width: 20em; text-wrap: balance; }
.clock { font-size: .92em; white-space: nowrap; }
.preview { margin-top: auto; padding-top: clamp(1em, 5vh, 3em); min-height: 6.6em; }
.kicker { font-size: 12px; color: var(--faint); text-transform: uppercase; }
.pv-title { font-size: 2.5em; font-weight: 500; letter-spacing: -0.035em; line-height: 1; margin-top: .15em; text-wrap: balance; }
.pv-sub { margin-top: .35em; max-width: 26em; text-wrap: pretty; }

/* ---------- 3D stage ---------- */
.stage {
  position: relative; flex: none; min-height: 272px;
  perspective: 1400px; perspective-origin: 50% -10%;
}
/* containers sit in the same plane as the book faces; let taps fall through to the books and the kid */
.world { position: absolute; inset: 0; transform-style: preserve-3d; pointer-events: none; }
#books { position: absolute; inset: 0; transform-style: preserve-3d; pointer-events: none; }
.bk, .kid-hit { pointer-events: auto; }
.caption { position: absolute; left: 0; bottom: 4px; font-size: 11px; color: var(--faint); }

/* ---------- phone drawer ---------- */
.menu-btn, .clock-m, .pv-rows { display: none; }
html.drawer-open, html.drawer-open body { overflow: hidden; }
.drawer-back { position: fixed; inset: 0; z-index: 59; background: rgba(28,28,26,.32); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(86vw, 380px);
  display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: var(--bg); color: var(--ink); font-family: 'Bricolage Grotesque', Helvetica, sans-serif;
  box-shadow: -24px 0 60px rgba(28,28,26,.18); transform: translateX(104%); transition: transform .38s cubic-bezier(.3,.9,.3,1);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 10px; }
.drawer-head button { background: none; border: 0; padding: 10px 0 10px 12px; font-size: 12px; color: var(--ink); cursor: pointer; }
.drawer-list { display: flex; flex-direction: column; }
.dr-item {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-items: stretch; width: 100%;
  padding: 10px 0; border: 0; border-top: 1px solid var(--rule); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.dr-item:active .dr-spine { transform: translateY(-4px); }
.dr-spine { display: flex; justify-content: center; padding-top: 7px; min-height: 60px; border-radius: 4px 4px 1px 1px; font-size: 11px; transition: transform .2s ease; box-shadow: inset -3px 0 0 rgba(0,0,0,.08); }
.dr-text { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.dr-kind { font-size: 11px; color: var(--faint); text-transform: uppercase; }
.dr-name { font-size: 21px; line-height: 1.08; letter-spacing: -.02em; }
.drawer-foot { margin-top: auto; padding-top: 18px; display: flex; gap: 1.4em; font-size: 17px; border-top: 1px solid var(--rule); }

/* ---------- the room ---------- */
.room { position: absolute; left: 0; display: block; pointer-events: none; user-select: none; filter: drop-shadow(0 24px 30px rgba(28,28,26,.14)); }
.plank { display: none; }
.stage > .preview { position: absolute; margin: 0; padding: 0; min-height: 0; overflow: hidden; z-index: 3; pointer-events: none; }
.stage > .preview .pv-title { font-size: 2.3em; }
.stage > .preview .pv-sub { font-size: .9em; color: #5f5b55; }

.plank { position: absolute; left: 0; right: 0; bottom: 70px; height: 0; transform-style: preserve-3d; }
.plank-top {
  position: absolute; left: 0; right: 0; top: 0;
  transform-origin: 50% 0;
  background: linear-gradient(to bottom, rgba(28,28,26,.08), rgba(28,28,26,.03) 70%, rgba(255,255,255,.25));
}
.plank-front { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--ink); }

.bk {
  position: absolute; left: 0; bottom: 70px; transform-style: preserve-3d;
  transform-origin: 50% 100%; cursor: pointer;
  transition: transform .45s cubic-bezier(.3,1.4,.5,1);
}
.bk.pulled { transition: transform .45s cubic-bezier(.3,1.2,.5,1); }
.bk.live { transition: none; }
.bk-face { position: absolute; }
.bk-front { backface-visibility: hidden; }
.bk-front {
  inset: 0; border-radius: 3px 3px 0 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 8px 0 10px;
  box-shadow: inset -3px 0 0 rgba(0,0,0,.06), inset 3px 0 0 rgba(255,255,255,.18);
}
.bk-front .mono { font-size: 10px; }
.bk-front .spine { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 500; line-height: 1; }
.bk-top { left: 0; top: 0; transform-origin: 50% 0; transform: rotateX(-90deg); }
.bk-side { top: 0; transform-origin: 0 50%; }
.bk-side.l { left: 0; transform: rotateY(90deg); }
.bk-side.r { transform: rotateY(90deg); }

.kid { position: absolute; left: 0; bottom: 70px; transform-style: preserve-3d; will-change: transform; z-index: 2; pointer-events: none; }
.kid-canvas { position: absolute; pointer-events: none; }
.kid-shadow {
  position: absolute; left: 50%; bottom: 0; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(28,28,26,.28), rgba(28,28,26,0));
  transform-origin: 50% 100%;
}
.kid-hit { position: absolute; left: 0; bottom: 0; }
.bubble {
  position: absolute; left: 62%; bottom: 98%;
  background: var(--ink); color: var(--bg); font-size: 12px; line-height: 1.2;
  padding: 7px 10px; border-radius: 12px 12px 12px 2px; white-space: nowrap; pointer-events: none;
  opacity: 0; transform: scale(.6); transform-origin: 0 100%;
  transition: opacity .15s ease, transform .25s cubic-bezier(.3,1.6,.5,1);
}
.bubble.on { opacity: 1; transform: scale(1); }

/* ---------- open book ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .3s ease .35s; }
.overlay.open { pointer-events: auto; opacity: 1; transition-delay: 0s; }
.book {
  position: absolute; left: 50%; top: 50%;
  width: min(1240px, 94vw); height: min(760px, 86vh);
  margin-left: calc(min(1240px, 94vw) / -2); margin-top: calc(min(760px, 86vh) / -2);
  perspective: 2600px; transform: scale(.04);
  transition: transform .7s cubic-bezier(.7,0,.2,1);
}
.page-right {
  position: absolute; right: 0; top: 0; width: 50%; height: 100%;
  background: #fff; border: 1px solid var(--rule);
  padding: clamp(16px, 2.6vw, 40px); display: flex; flex-direction: column; gap: clamp(10px, 1.3vw, 18px);
  overflow: auto; box-shadow: 0 30px 80px rgba(28,28,26,.16);
}
.shot {
  flex: 1; min-height: 110px; background: repeating-linear-gradient(135deg, #f3f3ee 0 10px, #e9e9e3 10px 20px);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; font-size: 11px; color: var(--faint);
}
.stat { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1em .5em; }
.stat-n { font-size: clamp(34px, 5vw, 84px); font-weight: 600; letter-spacing: -0.045em; line-height: .9; }
.stat-l { color: var(--faint); font-size: clamp(13px, 1.1vw, 17px); }
.small-cap { font-size: 11px; color: var(--faint); text-transform: uppercase; }
.points { display: flex; flex-direction: column; gap: .5em; }
.point {
  display: grid; grid-template-columns: 2em minmax(0,1fr); font-size: clamp(13px, 1.1vw, 17px); line-height: 1.25; letter-spacing: 0;
  border-top: 1px solid var(--rule); padding-top: .5em;
}
.point .mono { font-size: .8em; color: var(--faint); padding-top: .15em; }
.book-nav { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; font-size: 12px; }
.book-nav span { cursor: pointer; padding: 6px 0; }
.leaf {
  position: absolute; left: 50%; top: 0; width: 50%; height: 100%;
  transform-origin: 0 50%; transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.6,0,.2,1);
}
.leaf-front, .leaf-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  padding: clamp(16px, 2.6vw, 40px); display: flex; flex-direction: column;
}
.leaf-front { justify-content: space-between; box-shadow: 0 30px 80px rgba(28,28,26,.16); }
.leaf-top { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.cover-title { font-size: clamp(34px, 5.4vw, 92px); font-weight: 600; line-height: .92; letter-spacing: -0.045em; text-wrap: balance; }
.cover-sub { margin-top: .7em; font-size: clamp(14px, 1.25vw, 20px); }
.leaf-back { transform: rotateY(180deg); background: #fff; border: 1px solid var(--rule); gap: clamp(10px, 1.4vw, 20px); overflow: auto; }
.back-title { font-size: clamp(26px, 3.6vw, 58px); font-weight: 500; line-height: .98; letter-spacing: -0.035em; text-wrap: balance; }
.back-blurb { font-size: clamp(14px, 1.25vw, 19px); line-height: 1.28; letter-spacing: 0; text-wrap: pretty; }
.rows { margin-top: auto; display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 5.5em minmax(0,1fr); gap: 10px; border-top: 1px solid var(--rule);
  padding: .5em 0; font-size: clamp(13px, 1.05vw, 16px); line-height: 1.25; letter-spacing: 0;
}
.row .mono { font-size: .8em; color: var(--faint); text-transform: uppercase; padding-top: .15em; }
.m-head { display: none; }

/* ---------- cursor ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 99; pointer-events: none; opacity: 0;
  display: flex; align-items: center; gap: 6px; mix-blend-mode: difference; will-change: transform;
}
.cursor-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; margin: -6px 0 0 -6px; transition: transform .2s ease; }
.cursor-label {
  font-size: 11px; line-height: 1; background: #fff; color: #000; padding: 6px 9px; border-radius: 99px; white-space: nowrap;
  opacity: 0; transform: scale(.5); transform-origin: 0 50%;
  transition: opacity .15s ease, transform .2s cubic-bezier(.3,1.5,.5,1);
}
.cursor.has-label .cursor-dot { transform: scale(.6); }
.cursor.has-label .cursor-label { opacity: 1; transform: scale(1); }

@media (hover: none) { .cursor { display: none; } .kbd { display: none; } }

/* ---------- phones + portrait tablets ---------- */
@media (max-width: 743px), (max-width: 1100px) and (orientation: portrait) {
  /* one screen, one focus: the shelf button and clock on top, a big block of text, then the whole room */
  .page { display: flex; flex-direction: column; gap: 0; padding: max(14px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); min-height: 100svh; }
  .col-index, .col-shelf { display: contents; }
  .id-head { order: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .id-head > div:first-child, .shelf-head, .shelf-list, .nav, .foot, .caption { display: none; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: 8px; flex: none;
    padding: 9px 14px; border: 1px solid var(--ink); border-radius: 99px; background: transparent; color: var(--ink); font-size: 12px; cursor: pointer;
  }
  .clock-m { display: block; font-size: clamp(28px, 9vw, 44px); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

  /* the text block, in the reference's register: title, an italic grey line, then "Label: value" lines */
  .preview { order: 2; margin-top: auto; padding-top: 28px; min-height: calc(7.8em + 28px); font-size: clamp(22px, 6.8vw, 34px); line-height: 1.1; letter-spacing: -.015em; }
  .preview .kicker { display: none; }
  .preview .pv-title { font-size: 1em; font-weight: 500; letter-spacing: -.015em; margin: 0; }
  .preview .pv-sub {
    font-size: 1em; font-style: italic; color: #9a9a94; margin: 0; max-width: none;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .pv-rows { display: block; }
  .pv-rows .k { color: var(--ink); }
  .pv-rows .v { color: #9a9a94; }
  .stage, .col-shelf .stage { order: 3; flex: none; margin: 30px -16px auto; }
  /* the spines are slim on a phone, so give each a taller invisible hit area */
  .bk::after { content: ''; position: absolute; left: -2px; right: -2px; top: -18px; bottom: -6px; }

  /* the open book becomes one tall page: cover first, then it flips away to a scrolling sheet */
  .book {
    width: calc(100vw - 20px); height: calc(100svh - 20px);
    margin-left: calc((100vw - 20px) / -2); margin-top: calc((100svh - 20px) / -2);
    perspective: 1800px;
  }
  .page-right { width: 100%; padding: 22px 18px 0; gap: 14px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .m-head { display: flex; flex-direction: column; gap: 12px; }
  .m-head .rows { margin-top: 4px; }
  .m-head .back-title { font-size: 34px; }
  .leaf { left: 0; width: 100%; }
  .leaf-back { display: none; }
  .shot { flex: none; min-height: 150px; }
  .book-nav {
    position: sticky; bottom: 0; margin: auto -18px 0; padding: 4px 18px max(6px, env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--rule); font-size: 13px; flex-wrap: nowrap;
  }
  .book-nav span { padding: 12px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .page, .bk, .book, .leaf, .overlay, .drawer, .drawer-back { transition-duration: .01s !important; }
}
