/* How it works: one sticky stage inside a tall section. worlds.js picks the
   world from the scroll position and sets data-world; CSS does every swap.
   Under reduced motion the swaps happen at once and nothing loops. */

/* ---------- Worlds: theme tokens (set on <html> and on the stage) ---------- */
/* Each world takes the app's palette and follows the loop: paper, the read blue,
   reading parchment, the practiced amber, the demonstrated green, the dark theme. */
[data-world="hero"] {
  --bg: #f6f5f2;
  --fg: #1c1b19;
  --fg-2: #5b5852;
  --accent: #1f3fae;
  --line: #e4e2dc;
  --blob: #ebe9e3;
  --desk: #dcd9d1;
  --desk-2: #cfcbc2;
}
[data-world="goal"] {
  --bg: #f3efe6;
  --fg: #1c1b19;
  --fg-2: #55524c;
  --accent: #1f3fae;
  --line: #e0d9ca;
  --blob: #ebe3d2;
  --desk: #d9ccb1;
  --desk-2: #c9ba9c;
}
[data-world="path"] {
  --bg: #e6ecfb;
  --fg: #1c1b19;
  --fg-2: #474b57;
  --accent: #1f3fae;
  --line: #cbd5ef;
  --blob: #d6e0f7;
  --desk: #bccbee;
  --desk-2: #aabde8;
}
[data-world="study"] {
  --bg: #f6ecd6;
  --fg: #2a2118;
  --fg-2: #5c4e3c;
  --accent: #7a4a00;
  --line: #e3d3b1;
  --blob: #efdfbb;
  --desk: #d3bb8f;
  --desk-2: #c2a677;
}
[data-world="practice"] {
  --bg: #fbebd0;
  --fg: #2b1a00;
  --fg-2: #5a3b06;
  --accent: #7a4a00;
  --line: #e9c98c;
  --blob: #f6dcaa;
  --desk: #e0b56a;
  --desk-2: #cf9f4c;
}
[data-world="review"] {
  --bg: #dcefe3;
  --fg: #10261a;
  --fg-2: #37523f;
  --accent: #1b6340;
  --line: #bddcc8;
  --blob: #c9e6d3;
  --desk: #a9d2b7;
  --desk-2: #93c3a3;
}
[data-world="map"] {
  --logo-k: #6aa3ff;
  --bg: #141412;
  --fg: #edebe5;
  --fg-2: #a8a59d;
  --accent: #6aa3ff;
  --line: #2e2d29;
  --blob: #1f1e1b;
  --desk: #2a2926;
  --desk-2: #22211e;
}
[data-world="runs"] {
  --logo-k: #6aa3ff;
  --bg: #1c1b19;
  --fg: #edebe5;
  --fg-2: #b5b1a8;
  --accent: #6aa3ff;
  --line: #34332f;
  --blob: #262521;
  --desk: #302f2b;
  --desk-2: #272622;
}
.nav-link[aria-current="page"] {
  color: var(--accent);
}

/* ---------- The section and its sticky stage ---------- */
/* Hero plus seven worlds, 0.7 screens of scroll each; the hero gets 0.6 of a world more. */
.worlds {
  --seg: 70vh;
  /* Wider than the page --max: the scene is the content here, so wide screens keep it. */
  --edge: max(var(--gutter), calc((100vw - 1680px) / 2));
  --copy-w: min(460px, 38vw);
  position: relative;
  height: calc(9 * var(--seg));
}
.world-track {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: calc(2 * var(--seg));
  grid-auto-rows: var(--seg);
  pointer-events: none;
}
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
}
.stage-bg,
.sky {
  position: absolute;
  inset: 0;
  opacity: 0;
}
/* Blueprint grid for the path world. */
.stage-bg {
  background-image:
    linear-gradient(rgb(31 63 174 / 10%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(31 63 174 / 10%) 1px, transparent 1px);
  background-size: 32px 32px;
}
[data-world="path"] .stage-bg,
[data-world="map"] .sky {
  opacity: 1;
}
/* Night sky: two layers of stars, the second one twinkles. */
.sky,
.sky::after {
  background:
    radial-gradient(1.6px 1.6px at 8% 14%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 22% 38%, #d6d3cb 50%, transparent 55%),
    radial-gradient(1.8px 1.8px at 36% 9%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 47% 30%, #b5b1a8 50%, transparent 55%),
    radial-gradient(1.6px 1.6px at 63% 12%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 78% 26%, #d6d3cb 50%, transparent 55%),
    radial-gradient(1.8px 1.8px at 91% 8%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 14% 62%, #b5b1a8 50%, transparent 55%),
    radial-gradient(1.4px 1.4px at 30% 78%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 56% 70%, #d6d3cb 50%, transparent 55%),
    radial-gradient(1.6px 1.6px at 84% 58%, #fff 50%, transparent 55%),
    radial-gradient(1.2px 1.2px at 95% 82%, #b5b1a8 50%, transparent 55%);
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translate(3%, 5%) scaleX(-1);
}

/* ---------- Copy: one article per world, stacked; the active one shows ---------- */
.copy {
  position: absolute;
  z-index: 3;
  left: var(--edge);
  top: calc(var(--header) + 24px);
  bottom: 110px;
  width: var(--copy-w);
  display: grid;
  align-items: center;
}
.copy-item {
  grid-area: 1 / 1;
  display: grid;
  gap: 14px;
  justify-items: start;
  opacity: 0;
  transform: translateY(46px);
  pointer-events: none;
}
.copy-item.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.copy-item h1,
.copy-item h2 {
  font: 600 clamp(2rem, 1.2rem + 2.4vw, 3.4rem) / 1.04 var(--font-serif);
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.copy-item h1 {
  font-size: clamp(2.6rem, 1.4rem + 3.6vw, 4.6rem);
}
.copy-body {
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  color: var(--fg);
}
.copy-note {
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--fg-2);
}
.jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg-2);
}
.jump a {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
}
.jump a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.scroll-hint {
  font: 600 0.8125rem var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.scroll-hint::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  margin-left: 0.4em;
  vertical-align: -0.2em;
  background: currentColor;
  mask: url("/icons/arrow-down.svg") center / contain no-repeat;
}

/* ---------- Rail: one dot per world, bottom left ---------- */
.world-rail {
  position: absolute;
  z-index: 4;
  left: var(--edge);
  bottom: 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0;
  visibility: hidden;
}
.stage:not([data-world="hero"]) .world-rail {
  opacity: 1;
  visibility: visible;
}
.rail-dots {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
}
.world-rail button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.world-rail button i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--fg) 35%, transparent);
}
.world-rail button:hover i {
  transform: scale(1.25);
}
.world-rail button[aria-current] i {
  transform: scale(1.45);
  box-shadow: 0 0 0 2px var(--a);
}
.world-rail button:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 0;
}
.world-rail [data-i="1"] {
  --c: #fbe3a6;
  --a: #1c1b19;
}
.world-rail [data-i="2"] {
  --c: #1f3fae;
  --a: #ffffff;
}
.world-rail [data-i="3"] {
  --c: #d9bf8c;
  --a: #2a2118;
}
.world-rail [data-i="4"] {
  --c: var(--st-prac);
  --a: #2b1a00;
}
.world-rail [data-i="5"] {
  --c: #2e8b57;
  --a: #ffffff;
}
.world-rail [data-i="6"] {
  --c: #141412;
  --a: #edebe5;
}
.world-rail [data-i="7"] {
  --c: #6aa3ff;
  --a: #141412;
}
.world-name {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ---------- Board: a fixed 760 x 560 scene, scaled to fit, moved per world ---------- */
/* The wrap ends at the desk line; the board scales around that line. */
.board-wrap {
  position: absolute;
  left: calc(var(--edge) + var(--copy-w) + 24px);
  right: 0;
  top: calc(var(--header) + 16px);
  bottom: max(112px, 14%);
}
/* --lift (set by worlds.js when stacked) raises the scene into height the fit left unused. */
.board {
  position: absolute;
  left: 50%;
  top: calc(100% - 458px);
  width: 760px;
  height: 560px;
  margin-left: -380px;
  transform-origin: 50% 458px;
  transform: translateY(calc(-1 * var(--lift, 0px))) scale(calc(var(--fit, 1) * var(--bs, 1)))
    translate(var(--bx, 0), var(--by, 0));
}
[data-world="goal"] .board {
  --bx: -16px;
  --by: 8px;
  --bs: 0.97;
  --br: -5deg;
}
[data-world="path"] .board {
  --bx: 12px;
  --by: -6px;
  --bs: 0.9;
  --br: 4deg;
}
[data-world="study"] .board {
  --bx: -24px;
  --by: 0;
  --bs: 0.95;
  --br: -2deg;
}
[data-world="practice"] .board {
  --bx: 18px;
  --by: 10px;
  --bs: 0.97;
  --br: 6deg;
}
[data-world="review"] .board {
  --bx: 0;
  --by: -12px;
  --bs: 0.93;
  --br: -7deg;
}
[data-world="map"] .board {
  --bx: 0;
  --by: 0;
  --bs: 0.9;
  --br: 9deg;
}
[data-world="runs"] .board {
  --bx: -8px;
  --by: 4px;
  --bs: 0.93;
  --br: -3deg;
}
.board > * {
  position: absolute;
}
.blob {
  left: 50px;
  top: -20px;
  width: 660px;
  height: 520px;
  border-radius: 48% 52% 44% 56% / 56% 44% 56% 44%;
  background: var(--blob);
  transform: rotate(var(--br, 0deg));
}
/* The desk runs the full width of the stage, like a floor line. */
.desk {
  left: -2400px;
  top: 458px;
  width: 5560px;
  height: 700px;
  border-top: 22px solid var(--desk);
  background: var(--desk-2);
}
.neck {
  left: 350px;
  top: 388px;
  width: 60px;
  height: 60px;
  background: linear-gradient(90deg, #2a2926, #1c1b19);
}
.foot {
  left: 295px;
  top: 444px;
  width: 170px;
  height: 14px;
  border-radius: 8px 8px 3px 3px;
  background: #1c1b19;
}
.monitor {
  z-index: 2;
  left: 100px;
  top: 30px;
  width: 560px;
  height: 360px;
  padding: 12px;
  border-radius: 20px;
  background: #1c1b19;
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 10%),
    0 34px 60px -30px rgb(0 0 0 / 50%);
}
.screen {
  position: relative;
  width: 536px;
  height: 336px;
  overflow: hidden;
  border-radius: 8px;
  background: #f6f5f2;
}

/* The replica app from the tour, drawn at 800 x 501 and scaled into the screen.
   It is an illustration, so it keeps one layout at every viewport width. */
.screen .app {
  position: absolute;
  left: 0;
  top: 0;
  width: 800px;
  height: 501px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: scale(0.67);
  transform-origin: 0 0;
}
.screen .app-body {
  grid-template-columns: 150px minmax(0, 1fr);
  min-height: 0;
}
.screen .app-side {
  display: flex;
}
.screen .app-main {
  min-height: 0;
  overflow: hidden;
}
/* Scoped to the screen so they outrank the home tour's .app rules, which also load here. */
.screen .app .side-goals,
[data-world="hero"] .screen .app .side-chat,
[data-world="goal"] .screen .app .side-chat,
[data-world="review"] .screen .app .side-review {
  background: var(--a-muted-bg);
  color: var(--a-ink);
}
[data-world="hero"] .screen .app .side-goals,
[data-world="goal"] .screen .app .side-goals,
[data-world="review"] .screen .app .side-goals {
  background: none;
  color: var(--a-soft);
}
.screen .goal-head {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 16px;
}
.screen .send,
.screen .app-btn {
  display: inline-grid;
  place-items: center;
}
.scr-stack {
  flex: 1;
  display: grid;
  min-height: 0;
}
.scr {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  opacity: 0;
  transform: translateY(14px);
}
.scr.is-on {
  opacity: 1;
  transform: none;
}
.scr > .k {
  margin: 0;
}
.scr-chat .thread {
  justify-content: flex-end;
}
.scr .topics {
  position: relative;
}
.scr .topics::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: var(--a-border);
}
.scr .topic {
  position: relative;
}
.scr .study-cols {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.scr .practice {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px 20px;
}
.scr .practice > * {
  grid-column: 1;
}
.scr .practice > .feedback {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
}
.scr-review {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}
.scr-review .plan {
  --card: #fff;
  --card-fg: #1c1b19;
  --card-fg-2: #6b6862;
  border: 1px solid var(--a-border);
  box-shadow: none;
}
.map-panel {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 12px;
  background: #141412;
  color: #edebe5;
}
.map-panel .legend {
  display: flex;
  gap: 18px;
  margin: 0;
  font-size: 0.8125rem;
}
.map-panel .map-note {
  margin: 0;
  color: #a8a59d;
  font-size: 0.875rem;
}

/* The editor on the monitor in the last world. */
.editor {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #1c1c19;
  color: #d6d3cb;
  opacity: 0;
}
.editor.is-on {
  opacity: 1;
}
.ed-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  border-bottom: 1px solid #2e2d29;
}
.editor .ed-bar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a3934;
}
.ed-bar b {
  margin-left: 8px;
  font: 500 0.6875rem var(--font-mono);
  color: #a8a59d;
}
.ed-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}
.ed-code {
  margin: 0;
  padding: 14px;
  font: 500 0.6875rem / 1.7 var(--font-mono);
  white-space: pre;
  overflow: hidden;
}
.ed-code .kw {
  color: #8fbcff;
}
.ed-panel {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px 12px;
  border-left: 1px solid #2e2d29;
  background: #161614;
}
.ed-panel .k {
  margin: 0;
  font-size: 0.625rem;
  color: #8fe3b0;
}
.ed-prompts {
  display: grid;
  gap: 4px;
  font: 600 0.75rem var(--font-mono);
}
.ed-prompts li::before {
  content: "› ";
  color: #8fbcff;
}
.ed-msg {
  padding: 8px;
  border-radius: 6px;
  background: #1d2a22;
  color: #8fe3b0;
  font: 600 0.6875rem / 1.4 var(--font-mono);
}

/* ---------- Knowledge map on the screen (dark): two goals, one shared topic ---------- */
.map .stars circle {
  fill: #b5b1a8;
  opacity: 0.6;
}
.map .edges path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.9;
}
.map .e-a {
  stroke: #6aa3ff;
}
.map .e-b {
  stroke: #e0a33b;
}
.map .n.c-b circle {
  fill: #e0a33b;
}
.map .n.shared circle {
  fill: #edebe5;
}
.map .n.shared .halo {
  fill: rgb(106 163 255 / 18%);
  stroke: rgb(106 163 255 / 50%);
  stroke-width: 1.5;
}
.map .n.shared text {
  font-weight: 800;
  fill: #edebe5;
  font-size: 15px;
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.swatch.c-a {
  background: #6aa3ff;
}
.swatch.c-b {
  background: #e0a33b;
}

/* ---------- Props: fade and rise in with their world ---------- */
.prop {
  z-index: 3;
  opacity: 0;
  transform: translateY(18px) rotate(var(--r, 0deg));
}
.prop.is-on {
  opacity: 1;
  transform: rotate(var(--r, 0deg));
}
.constellation {
  z-index: 1;
  left: 0;
  top: 0;
  width: 760px;
  height: 560px;
}
.constellation .lines path {
  fill: none;
  stroke: #8fbcff;
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
  opacity: 0.7;
}
.constellation .points circle {
  fill: #fff;
}
/* Stuck on the monitor's top-right corner: the app logo, where the K lands, stays clear. */
.note {
  --r: 6deg;
  left: 600px;
  top: 14px;
  width: 132px;
  height: 124px;
  padding: 16px 14px;
  background: #fbe3a6;
  box-shadow: 0 14px 24px -14px rgb(60 45 10 / 55%);
  font: italic 600 1.25rem / 1.2 var(--font-serif);
  color: #3a2400;
}
.mug {
  left: 604px;
  top: 392px;
  width: 54px;
  height: 66px;
  border-radius: 6px 6px 16px 16px;
  background: #1f3fae;
}
.mug::after {
  content: "";
  position: absolute;
  right: -18px;
  top: 14px;
  width: 16px;
  height: 26px;
  border: 6px solid #1f3fae;
  border-left: 0;
  border-radius: 0 14px 14px 0;
}
.steam {
  position: absolute;
  bottom: 74px;
  left: 14px;
  width: 6px;
  height: 26px;
  border-radius: 6px;
  background: rgb(85 82 76 / 30%);
}
.steam + .steam {
  left: 30px;
  height: 20px;
}
.cards {
  inset: 0;
}
.pin-card {
  position: absolute;
  width: 124px;
  padding: 16px 10px 10px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 10px 20px -12px rgb(28 27 25 / 40%);
  font: 700 0.8125rem / 1.25 var(--font-sans);
  color: #1c1b19;
}
.pin-card i {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4px;
  border-radius: 50%;
  background: #e5484d;
}
.pin-card::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--st-none);
}
.pin-card:nth-child(1) {
  left: -64px;
  top: 36px;
  rotate: -4deg;
}
.pin-card:nth-child(2) {
  left: -84px;
  top: 164px;
  rotate: 3deg;
}
.pin-card:nth-child(3) {
  left: -60px;
  top: 292px;
  rotate: -2deg;
}
.pin-card:nth-child(4) {
  left: 694px;
  top: 44px;
  rotate: 3deg;
}
.pin-card:nth-child(5) {
  left: 712px;
  top: 172px;
  rotate: -3deg;
}
.pin-card:nth-child(6) {
  left: 690px;
  top: 300px;
  rotate: 2deg;
}
.pdfs {
  left: -10px;
  top: 372px;
  width: 132px;
  height: 86px;
}
.pdfs span {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: #fffdf7;
  box-shadow: 0 6px 14px -8px rgb(60 45 10 / 55%);
}
.pdfs span:nth-child(1) {
  transform: translate(10px, -14px) rotate(4deg);
}
.pdfs span:nth-child(2) {
  transform: translate(4px, -7px) rotate(-3deg);
}
.pdfs span:nth-child(3) {
  display: grid;
  place-items: center;
  font: 800 0.9rem var(--font-mono);
  color: #b3261e;
}
.bookmark {
  left: 612px;
  top: 4px;
  width: 30px;
  height: 104px;
  background: #b3261e;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  transform-origin: top;
}
.checklist {
  --r: -5deg;
  left: -24px;
  top: 200px;
  display: grid;
  gap: 10px;
  width: 150px;
  padding: 16px 14px;
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 0 14px 24px -14px rgb(60 35 0 / 55%);
  font: 700 0.8125rem var(--font-sans);
  color: #2b1a00;
}
.checklist .row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checklist .row i {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid #7a4a00;
  border-radius: 4px;
}
.checklist .row.is-done i {
  background: var(--st-prac);
  border-color: #7a4a00;
}
.pencil {
  --r: -8deg;
  left: 500px;
  top: 440px;
  width: 190px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(90deg, #f2a0a0 0 16px, #c9c9c9 16px 26px, #ffcf40 26px);
  clip-path: polygon(0 0, 88% 0, 100% 50%, 88% 100%, 0 100%);
}
.calendar {
  --r: -4deg;
  left: -14px;
  top: 160px;
  width: 136px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 24px -14px rgb(15 40 27 / 45%);
}
.calendar b {
  display: block;
  padding: 8px 10px;
  background: #1b6340;
  color: #fff;
  font: 700 0.8125rem var(--font-sans);
}
.calendar .days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 10px;
}
.calendar .days i {
  aspect-ratio: 1;
  border-radius: 3px;
  background: #dcefe3;
}
.calendar .days .is-due {
  background: var(--st-prac);
}
.flashdeck {
  left: 640px;
  top: 358px;
  width: 116px;
  height: 84px;
}
.flashdeck span {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 16px -10px rgb(15 40 27 / 45%);
}
.flashdeck span:nth-child(1) {
  transform: rotate(-8deg) translate(-6px, 6px);
}
.flashdeck span:nth-child(2) {
  transform: rotate(5deg) translate(6px, 2px);
}
.flashdeck span:nth-child(3) {
  display: grid;
  place-items: center;
  font: italic 700 1.8rem var(--font-serif);
  color: #1b6340;
}
.laptop {
  left: -44px;
  top: 316px;
  width: 250px;
}
.lap-screen {
  display: grid;
  align-content: start;
  gap: 4px;
  height: 130px;
  margin: 0 12px;
  padding: 12px;
  border: 6px solid #3a3934;
  border-radius: 10px 10px 0 0;
  background: #141412;
  font: 500 0.6875rem / 1.45 var(--font-mono);
  color: #edebe5;
}
.lap-screen code {
  font: inherit;
}
.lap-screen .prompt {
  color: #8fbcff;
}
.lap-screen .dim {
  color: #8fe3b0;
}
.cursor {
  width: 7px;
  height: 12px;
  background: #edebe5;
}
.lap-base {
  height: 12px;
  border-radius: 0 0 10px 10px;
  background: #4a4944;
}
.phone {
  --r: 6deg;
  left: 648px;
  top: 262px;
  display: grid;
  align-content: start;
  gap: 6px;
  width: 96px;
  height: 180px;
  padding: 18px 9px;
  border: 5px solid #3a3934;
  border-radius: 18px;
  background: #141412;
  color: #edebe5;
}
.phone b {
  font: 500 0.5625rem var(--font-mono);
  color: #a8a59d;
}
.phone .k {
  margin: 0;
  font-size: 0.5625rem;
  color: #8fbcff;
}
.phone-title {
  font: 600 0.75rem / 1.2 var(--font-serif);
}

/* ---------- Without JavaScript: a plain page ---------- */
html:not(.js) .worlds {
  height: auto;
}
html:not(.js) .stage {
  position: static;
  height: auto;
  padding: calc(var(--header) + 32px) var(--gutter) 48px;
}
html:not(.js) .copy {
  position: static;
  width: auto;
  max-width: 40rem;
  gap: 56px;
}
html:not(.js) .copy-item {
  grid-area: auto;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
html:not(.js) .board-wrap,
html:not(.js) .world-rail,
html:not(.js) .scroll-hint {
  display: none;
}

/* ---------- Narrow screens: copy on top, board below, rail as a strip ---------- */
/* Stacked: phones and tall screens put the words on top and give the scene the full width
   and the rest of the height. Keep this query in step with `stacked` in worlds.js. */
@media (max-width: 860px), (max-aspect-ratio: 5 / 4) {
  .worlds {
    --copy-w: auto;
  }
  .copy {
    right: var(--edge);
    left: var(--edge);
    top: calc(var(--header) + 16px + var(--lift, 0px));
    bottom: auto;
    align-items: start;
  }
  .copy-item {
    max-width: 44rem;
  }
  /* The board starts under the current copy (--copy-h, measured by worlds.js). */
  .board-wrap {
    left: 0;
    top: calc(var(--header) + 32px + var(--copy-h, 30vh));
    bottom: 76px;
  }
}
@media (max-width: 860px) {
  .copy-item {
    gap: 10px;
  }
  .copy-item h1,
  .copy-item h2 {
    font-size: clamp(1.625rem, 1.2rem + 2vw, 2.4rem);
  }
  .copy-body {
    font-size: 1rem;
    line-height: 1.5;
  }
  .copy-note {
    font-size: 0.875rem;
    line-height: 1.45;
  }
  .scroll-hint {
    display: none;
  }
  .world-rail {
    left: 0;
    right: 0;
    bottom: 0;
    gap: 10px;
    padding: 8px var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
  }
  .world-rail button {
    width: 30px;
    height: 36px;
  }
  .world-name {
    font-size: 0.875rem;
  }
}
@media (max-width: 860px) and (max-height: 760px) {
  .copy-note {
    display: none;
  }
}

/* ---------- Scroll-driven motion: worlds.js sets --o, --p and --tp ---------- */

/* Hero: one camera from a closed book to the K, played on the monitor like an app
   launching. The scene is the app's own logo: .kbook is the 18 x 26 logo box in the
   sidebar, and the camera starts zoomed in far past it. The scene is built in the K's
   frame (246 x 355, the mark's viewBox): x is up from the table, y runs across the
   open book, z runs along the gutter. The mark is the book's bottom edge (z = 0);
   every other plane is that edge pulled back along z. With no perspective the
   projection is parallel, so when the camera reaches the edge each plane is exactly
   edge-on and only the mark is left. Phases are slices of --o, eased with smoothstep. */
@property --o {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}
.kbook {
  --t-open: clamp(0, calc(var(--o) / 0.19), 1);
  --t-p1: clamp(0, calc((var(--o) - 0.15) / 0.17), 1);
  --t-p2: clamp(0, calc((var(--o) - 0.2) / 0.17), 1);
  --t-p3: clamp(0, calc((var(--o) - 0.25) / 0.17), 1);
  --t-up: clamp(0, calc((var(--o) - 0.3) / 0.17), 1);
  --t-lo: clamp(0, calc((var(--o) - 0.38) / 0.11), 1);
  --t-cam: clamp(0, calc((var(--o) - 0.47) / 0.24), 1);
  --t-ink: clamp(0, calc((var(--o) - 0.52) / 0.19), 1);
  --t-roll: clamp(0, calc((var(--o) - 0.66) / 0.17), 1);
  --t-land: clamp(0, calc((var(--o) - 0.87) / 0.13), 1);
  --open: calc(var(--t-open) * var(--t-open) * (3 - 2 * var(--t-open)));
  --p1: calc(var(--t-p1) * var(--t-p1) * (3 - 2 * var(--t-p1)));
  --p2: calc(var(--t-p2) * var(--t-p2) * (3 - 2 * var(--t-p2)));
  --p3: calc(var(--t-p3) * var(--t-p3) * (3 - 2 * var(--t-p3)));
  --up: calc(var(--t-up) * var(--t-up) * (3 - 2 * var(--t-up)));
  --lo: calc(var(--t-lo) * var(--t-lo) * (3 - 2 * var(--t-lo)));
  --cam: calc(var(--t-cam) * var(--t-cam) * (3 - 2 * var(--t-cam)));
  --ink: calc(var(--t-ink) * var(--t-ink) * (3 - 2 * var(--t-ink)));
  --roll: calc(var(--t-roll) * var(--t-roll) * (3 - 2 * var(--t-roll)));
  --land: calc(var(--t-land) * var(--t-land) * (3 - 2 * var(--t-land)));
  /* The two V pages: a real page is shorter and far thinner than the K's arms. */
  --sx: calc(0.667 + 0.333 * var(--ink));
  --sy: calc(0.08 + 0.92 * var(--ink));
  --paper: #fffdf9;
  --d: 250px;
  position: relative;
  z-index: 5;
  width: 18px;
  height: 26px;
  margin: 0 0 14px 8px;
  pointer-events: none;
}
/* A blank screen under the scene. It clears as the K lands, and the app is there. */
.kbook::before {
  content: "";
  position: absolute;
  left: -40px;
  top: -80px;
  width: 860px;
  height: 600px;
  background: var(--a-canvas);
  opacity: clamp(0, calc(1 - var(--land) * 1.6), 1);
}
/* The camera, in app px from the logo box. Three framings: the book (scale 1.3), the
   full K in the middle of the screen (0.93), and the logo (18 / 246). --cam goes from
   the first to the second while it drops pitch and yaw; --land from the second to the
   third. While the cover opens, the pan follows the book's middle. */
.bk {
  position: absolute;
  left: 0;
  top: 0;
  width: 246px;
  height: 355px;
  transform-origin: 0 0;
  transform-style: preserve-3d;
  transform: translate(
      calc((1 - var(--land)) * (266px + (1 - var(--cam)) * (62px - 100px * (1 - var(--open))))),
      calc((1 - var(--land)) * (31px + (1 - var(--cam)) * (-76px - 15px * (1 - var(--open)))))
    )
    scale(calc(0.07317 + (1 - var(--land)) * (0.857 + (1 - var(--cam)) * 0.37)))
    translate3d(40px, 177.5px, -125px) rotateZ(calc(var(--roll) * 90deg))
    rotateX(calc((1 - var(--cam)) * -55deg)) rotateY(calc((1 - var(--cam)) * -24deg))
    rotateZ(-90deg) translate3d(-40px, -177.5px, 125px);
}
.bk > *,
.bk-slab > * {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
/* The table runs past the screen on every side, so the screen starts as its top. */
.bk-table {
  width: 1300px;
  height: 1560px;
  background: var(--desk);
  transform: translate3d(-1px, -600px, 400px) rotateY(90deg);
  opacity: clamp(0, calc((1 - var(--cam)) * 3), 1);
}
.bk-table i {
  position: absolute;
  left: 404px;
  top: 604px;
  width: 242px;
  height: 347px;
  border-radius: 6px;
  background: rgb(28 27 25 / 22%);
  box-shadow: 0 0 22px 8px rgb(28 27 25 / 22%);
  transform-origin: 50% 100%;
  transform: scaleY(calc(0.5 + 0.5 * var(--open)));
}
/* The open spread: two page faces on top of the block. */
.bk-face {
  width: var(--d);
  background: var(--paper);
  transform: translateX(40px) rotateY(90deg);
}
.bk-right {
  top: 180.3px;
  height: 174.7px;
  box-shadow: inset 0 12px 12px -10px rgb(28 27 25 / 22%);
}
.bk-left {
  height: 180.3px;
  box-shadow: inset 0 -12px 12px -10px rgb(28 27 25 / 22%);
}
.bk-face i,
.bk-page i {
  position: absolute;
  border-radius: 2px;
  background: #e4e2dc;
}
.bk-face i {
  left: 42px;
  top: 15%;
  width: 4px;
  height: 70%;
  box-shadow:
    26px 0 #e4e2dc,
    52px 0 #e4e2dc,
    78px 0 #e4e2dc,
    104px 0 #e4e2dc,
    130px 0 #e4e2dc,
    156px 0 #e4e2dc;
}
/* Fore-edges: page stack over a cover board. */
.bk-edge {
  box-sizing: border-box;
  width: 40px;
  height: var(--d);
  border-left: 5px solid var(--a-accent);
  background: #ebe9e3;
  transform: rotateX(-90deg);
}
.bk-edge-r {
  top: 355px;
}
/* The left half starts folded over the right one: the closed book. */
.bk-slab {
  width: 246px;
  height: 355px;
  transform-style: preserve-3d;
  transform-origin: 40px 180.3px;
  transform: rotateZ(calc((1 - var(--open)) * 180deg));
}
.bk-cover {
  display: grid;
  place-items: center;
  width: var(--d);
  height: 180.3px;
  background: var(--a-accent);
  transform: translateZ(calc(-1 * var(--d))) rotateY(-90deg);
}
.bk-cover img {
  width: 58px;
  height: auto;
  transform: rotate(-90deg);
}
/* Pages turn on the gutter, 5 units above the spread. */
.bk-page {
  --f: 0;
  box-sizing: border-box;
  width: 172px;
  height: var(--d);
  border: 1px solid #e4e2dc;
  background: var(--paper);
  transform: translate3d(45.1px, 180.3px, 0) rotateZ(calc(90deg - var(--f) * 180deg))
    rotateX(-90deg);
  opacity: clamp(0, calc(var(--f) * (1 - var(--f)) * 60), 1);
}
.bk-page i {
  left: 15%;
  top: 42px;
  width: 70%;
  height: 4px;
  box-shadow:
    0 26px #e4e2dc,
    0 52px #e4e2dc,
    0 78px #e4e2dc,
    0 104px #e4e2dc,
    0 130px #e4e2dc,
    0 156px #e4e2dc;
}
/* A page mid-turn is in its own shade. */
.bk-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #1c1b19;
  opacity: calc(var(--f) * (1 - var(--f)) * 0.3);
}
.bk-p1 {
  --f: var(--p1);
}
.bk-p2 {
  --f: var(--p2);
}
.bk-p3 {
  --f: var(--p3);
}
/* The two pages that stop mid-turn. Their planes follow the arms' chords. */
.bk-pu,
.bk-pl {
  opacity: 1;
}
.bk-pu {
  width: 258px;
  transform: translate3d(45.1px, 180.3px, 0) rotateZ(calc(-39.16deg + (1 - var(--up)) * 129.16deg))
    scaleX(var(--sx)) rotateX(-90deg);
}
.bk-pl {
  width: 264px;
  transform: translate3d(45.1px, 180.3px, 0) rotateZ(calc(40.6deg + (1 - var(--lo)) * 49.4deg))
    scaleX(var(--sx)) rotateX(-90deg);
}
.bk-pu::after {
  opacity: calc(var(--up) * 0.1);
}
.bk-pl::after {
  opacity: calc(var(--lo) * 0.03);
}
/* The mark, as the book's bottom edge. At --o 1 every transform here is the identity. */
.kmark {
  width: 246px;
  height: 355px;
  overflow: visible;
  fill: var(--a-accent);
  fill-rule: evenodd;
}
.kb-half-l,
.kb-strips,
.kb-upper,
.kb-lower,
.kb-ring {
  transform-box: view-box;
  transform-origin: 45.1px 180.3px;
}
.kb-half-l {
  transform-origin: 40px 180.3px;
  transform: rotate(calc((1 - var(--open)) * 180deg));
}
.kb-paper {
  fill: #ebe9e3;
  opacity: calc(1 - var(--ink));
}
.kb-strips {
  transform-origin: 49px 180.3px;
  transform: scaleX(var(--ink));
}
.kb-upper {
  transform: rotate(calc((1 - var(--up)) * 129.16deg)) rotate(-39.16deg) scale(var(--sx), var(--sy))
    rotate(39.16deg);
}
.kb-lower {
  transform: rotate(calc((1 - var(--lo)) * 49.4deg)) rotate(40.6deg) scale(var(--sx), var(--sy))
    rotate(-40.6deg);
}
.kb-ring {
  transform: scale(calc(0.5 + 0.5 * var(--ink)));
}
/* Screens and copy leave in the direction you scroll. */
.stage .scr:not(.is-on) {
  clip-path: inset(0 0 100% 0);
}
.stage[data-dir="back"] .scr:not(.is-on) {
  clip-path: inset(100% 0 0 0);
}
.scr.is-on {
  clip-path: inset(0);
}
.stage[data-dir="back"] .copy-item:not(.is-on) {
  transform: translateY(-46px);
}

/* A line under the rail moves with every scroll, across the whole page. */
.rail-dots {
  position: relative;
}
.rail-dots::after {
  content: "";
  position: absolute;
  left: 10px;
  bottom: -9px;
  width: calc((100% - 20px) * var(--tp, 0));
  height: 3px;
  border-radius: 2px;
  background: var(--fg);
}

/* Inside each world, the screen plays its moment as you scroll through it. */
.scr[data-for="goal"] .msg-me {
  --show: clamp(0, calc(var(--p, 1) * 6 - 0.4), 1);
}
.scr[data-for="goal"] .thread > div.msg-klugg {
  --show: clamp(0, calc(var(--p, 1) * 5 - 1.8), 1);
}
.scr[data-for="path"] .topics li {
  --show: clamp(0, calc(var(--p, 1) * 9 - var(--n, 0)), 1);
}
.scr[data-for="path"] .topics li:nth-child(2) {
  --n: 1;
}
.scr[data-for="path"] .topics li:nth-child(3) {
  --n: 2;
}
.scr[data-for="path"] .topics li:nth-child(4) {
  --n: 3;
}
.scr[data-for="path"] .topics li:nth-child(5) {
  --n: 4;
}
.scr[data-for="path"] .topics li:nth-child(6) {
  --n: 5;
}
.scr[data-for="practice"] .feedback {
  --show: clamp(0, calc(var(--p, 1) * 5 - 1.6), 1);
}
.scr-review .scheduled {
  --show: clamp(0, calc(var(--p, 1) * 5 - 2), 1);
}
.editor .ed-msg {
  --show: clamp(0, calc(var(--p, 1) * 5 - 1.5), 1);
}
.scr[data-for="goal"] .msg-me,
.scr[data-for="goal"] .thread > div.msg-klugg,
.scr[data-for="path"] .topics li,
.scr[data-for="practice"] .feedback,
.scr-review .scheduled,
.editor .ed-msg {
  opacity: var(--show);
  translate: 0 calc((1 - var(--show)) * 12px);
}
.scr[data-for="study"] .passage mark {
  background-size: calc(clamp(0, calc(var(--p, 1) * 1.8), 1) * 100%) 100%;
}
.scr-review .bar i {
  width: calc(38% * clamp(0, calc(var(--p, 1) * 2), 1));
}
.map .edges path {
  stroke-dasharray: 260;
  stroke-dashoffset: calc(260 * (1 - clamp(0, calc(var(--p, 1) * 1.8), 1)));
}

/* ---------- Motion (off under reduced motion) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .stage,
  .site-header {
    transition:
      background-color 0.6s ease,
      color 0.6s ease;
  }
  .stage-bg,
  .sky {
    transition: opacity 0.6s ease;
  }
  .copy-item {
    transition:
      opacity 0.45s ease,
      transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .world-rail {
    transition:
      opacity 0.4s ease,
      visibility 0.4s;
  }
  .world-rail button i {
    transition:
      transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1),
      box-shadow 0.2s ease;
  }
  .board {
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .blob {
    transition:
      transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
      background-color 0.6s ease;
  }
  .desk {
    transition:
      border-color 0.6s ease,
      background-color 0.6s ease;
  }
  .scr,
  .editor,
  .prop {
    transition:
      opacity 0.45s ease,
      transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1),
      clip-path 0.55s cubic-bezier(0.65, 0, 0.35, 1);
  }
  /* --o glides to where the scroll put it, so a wheel notch plays as motion, not a jump. */
  .kbook {
    transition: --o 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .scroll-hint::after {
    animation: nudge 1.6s ease-in-out infinite;
  }
  .note p {
    animation: sway 5s ease-in-out infinite alternate;
  }
  .steam {
    animation: steam 2.4s ease-in infinite;
  }
  .steam + .steam {
    animation-delay: 1.2s;
  }
  .pin-card:nth-child(odd) {
    animation: swing 4s ease-in-out infinite alternate;
  }
  .bookmark {
    animation: swing 3.2s ease-in-out infinite alternate;
  }
  .checklist .row:last-child i {
    animation: pulse 1.8s ease-in-out infinite;
  }
  .calendar .days .is-due {
    animation: pulse 1.8s ease-in-out infinite;
  }
  .flashdeck span:nth-child(3) {
    animation: bob 3.4s ease-in-out infinite;
  }
  .sky::after {
    animation: twinkle 3s ease-in-out infinite alternate;
  }
  .constellation .lines path {
    animation: march 6s linear infinite;
  }
  .cursor {
    animation: blink 1s steps(1) infinite;
  }
  .phone.is-on {
    animation: bob 4.4s ease-in-out infinite;
  }
}
@keyframes nudge {
  50% {
    transform: translateY(4px);
  }
}
@keyframes bob {
  50% {
    translate: 0 -6px;
  }
}
@keyframes sway {
  to {
    transform: rotate(2deg);
  }
}
@keyframes steam {
  from {
    opacity: 0;
    transform: translateY(8px) scaleY(0.6);
  }
  40% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(-14px) scaleY(1.1);
  }
}
@keyframes swing {
  to {
    transform: rotate(2.5deg);
  }
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 0 4px rgb(191 127 23 / 35%);
  }
}
@keyframes twinkle {
  to {
    opacity: 0.25;
  }
}
@keyframes march {
  to {
    stroke-dashoffset: -60;
  }
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
