/* Recharge and Return: one notebook page, one taped-on scene, a caption on masking tape. */

:root {
  --rule: color-mix(in srgb, var(--ak-outline) 55%, transparent);
  --margin-line: var(--ak-accent);
  --paper: var(--ak-surface);
  --pencil: #3A3F36;
  --line-h: 1.42em;
  --soft-radius: 16px;
  --slow: 520ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Where the pencil square sits in the cropped wall picture (768 x 620, from y 200 of 1024). */
  --sq-left: 25.65%;
  --sq-top: 10.97%;
  --sq-w: 52.21%;
  --sq-h: 63.23%;
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

/* ---------- the page ---------- */

.play {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  padding:
    calc(var(--ac-status-h, 64px) + 8px)
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.desk {
  position: relative;
  width: min(100%, 560px);
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto;
  grid-template-areas:
    "head past"
    "page page"
    "scene scene"
    "track track"
    "cards cards"
    "go go"
    "caption caption";
  column-gap: 8px;
  padding: 6px 12px 10px 30px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--soft-radius);
  background-color: var(--paper);
  background-image: linear-gradient(90deg, transparent 19px, var(--margin-line) 19px, var(--margin-line) 20px, transparent 20px);
  box-shadow: 0 10px 28px rgba(31, 42, 31, 0.14);
}

.head {
  grid-area: head;
  display: flex;
  align-items: center;
  min-height: 48px;
}

.logo {
  display: block;
  height: clamp(34px, 5.4dvh, 48px);
  width: auto;
}

.past-link {
  grid-area: past;
  align-self: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--ak-outline);
  border-radius: 999px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 16px;
  font-style: italic;
}

/* The question, written on the ruled lines. */
.page {
  grid-area: page;
  margin: 2px 0 8px;
}

.question {
  margin: 0;
  min-height: calc(var(--line-h) * 2);
  font-family: var(--ak-font-display);
  font-weight: 600;
  --q: clamp(18px, calc(1.4dvh + 11px), 27px);
  font-size: var(--q);
  line-height: var(--line-h);
  color: var(--ak-ink);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line-h) - 1px), var(--rule) calc(var(--line-h) - 1px), var(--rule) var(--line-h));
  text-wrap: pretty;
}

.lead {
  margin: 0 0 2px;
  color: var(--ak-ink-muted);
  font-size: clamp(15px, calc(0.6dvh + 11px), 18px);
  font-style: italic;
  line-height: 1.35;
}

.question.is-long { font-size: calc(var(--q) * 0.86); }

/* ---------- the scene ---------- */

.scene-slot {
  grid-area: scene;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.scene {
  position: relative;
  margin: 0;
  width: min(100cqw, calc(100cqh * 768 / 620));
  aspect-ratio: 768 / 620;
  border-radius: 6px;
  background-image: url("art/clay-wall.jpg");
  background-size: 100% auto;
  background-position: 0 49.5%;
  box-shadow: 0 2px 0 var(--ak-outline), 0 8px 18px rgba(31, 42, 31, 0.16);
}

/* Two strips of tape hold the picture to the page. */
.scene::before,
.scene::after {
  content: '';
  position: absolute;
  z-index: 6;
  width: 64px;
  height: 20px;
  background: color-mix(in srgb, var(--ak-surface) 80%, var(--ak-bg));
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ak-outline) 60%, transparent);
  pointer-events: none;
}

.scene::before { top: -6px; left: -14px; rotate: -32deg; }
.scene::after { top: -6px; right: -14px; rotate: 32deg; }

.axis {
  position: absolute;
  z-index: 1;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: clamp(12px, 1.6dvh, 15px);
  font-style: italic;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
}

.axis-top { left: calc(var(--sq-left) + var(--sq-w) / 2); top: calc(var(--sq-top) - 3px); translate: -50% -100%; }
.axis-bottom { left: calc(var(--sq-left) + var(--sq-w) / 2); top: calc(var(--sq-top) + var(--sq-h) + 3px); translate: -50% 0; }
.axis-left,
.axis-right {
  top: calc(var(--sq-top) + var(--sq-h) / 2);
  padding: 2px 7px;
  border-radius: 12px;
  text-align: center;
  white-space: normal;
  translate: -50% -50%;
}
.axis-left { left: var(--sq-left); }
.axis-right { left: calc(var(--sq-left) + var(--sq-w)); }

.square {
  position: absolute;
  z-index: 3;
  left: var(--sq-left);
  top: var(--sq-top);
  width: var(--sq-w);
  height: var(--sq-h);
}

/* The pencil line joining the patches in date order, and the guess mark, sit in the square's place. */
.trail,
.guess-layer {
  position: absolute;
  left: var(--sq-left);
  top: var(--sq-top);
  width: var(--sq-w);
  height: var(--sq-h);
  pointer-events: none;
}

.trail { z-index: 2; overflow: visible; opacity: 0; }
.trail.is-shown { opacity: 1; }
.trail polyline {
  fill: none;
  stroke: var(--pencil);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.guess-layer { z-index: 4; }

.guess-mark {
  position: absolute;
  width: 40px;
  height: 40px;
  translate: -50% -50%;
}

.guess-mark svg { width: 100%; height: 100%; fill: color-mix(in srgb, var(--ak-surface) 70%, transparent); stroke: var(--pencil); stroke-width: 2.6; stroke-linecap: round; }

/* While guessing, the whole square is the tap target and says so with a dashed pencil edge. */
.scene.is-guessing .square {
  cursor: crosshair;
  outline: 3px dashed var(--ak-ink);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--ak-surface) 18%, transparent);
}

/* A patch of prism light: a crop of the painted patch, bright for today, muted for the past. */
.patch {
  position: absolute;
  display: grid;
  place-items: center;
  width: max(32%, 48px);
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  translate: -50% -50%;
}

.patch-light {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 329 / 182;
  background-image: url("art/light-patch.png");
  background-size: 100% auto;
  background-position: 0 0;
  background-repeat: no-repeat;
}

.patch.is-past .patch-light,
.patch.is-old .patch-light { background-position: 0 100%; }
.patch.is-old .patch-light { opacity: 0.5; }
.patch.is-today { z-index: 2; }

/* Today's patch also wears a pencil ring, so it differs by mark as well as by brightness. */
.patch.is-today .patch-light::after {
  content: '';
  position: absolute;
  inset: -7px -9px;
  border: 2px solid var(--pencil);
  border-radius: 50%;
  rotate: -4deg;
}

.patch:focus-visible { outline-offset: 0; border-radius: 50%; }

.beam {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.beam line { opacity: 0; stroke-linecap: round; }
.beam-wide { stroke: url(#beam-fill); stroke-width: 26; }
.beam-core { stroke: #FFF6DC; stroke-width: 5; }
.scene.is-beaming .beam line,
.scene.is-lit .beam line { opacity: 1; }
.scene.is-lit .beam-wide { opacity: 0.35; }
.scene.is-lit .beam-core { opacity: 0.45; }

.glint {
  position: absolute;
  z-index: 2;
  left: 7.42%;
  top: 75%;
  width: 6%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6DC 0 30%, rgba(240, 168, 48, 0.55) 31% 55%, transparent 56%);
  opacity: 0;
  pointer-events: none;
}

.scene.is-beaming .glint,
.scene.is-lit .glint { opacity: 1; }

/* The small walker: three painted poses in one picture, chosen by background position. */
.walker {
  position: absolute;
  z-index: 2;
  right: 9%;
  bottom: 1.5%;
  height: 33%;
  aspect-ratio: 88 / 288;
  background-image: url("art/small-walker.png");
  background-repeat: no-repeat;
  background-size: 436.4% 100%;
  background-position: 100% 0;
  pointer-events: none;
  transform-origin: 50% 100%;
}

.walker[data-pose="sit"] { aspect-ratio: 100 / 288; background-size: 384% 100%; background-position: 0 0; }
.walker[data-pose="walk"] { aspect-ratio: 154 / 288; background-size: 249.4% 100%; background-position: 53.9% 0; }
.walker[data-pose="look"] { aspect-ratio: 88 / 288; background-size: 436.4% 100%; background-position: 100% 0; }
.walker[data-face="left"] { scale: -1 1; }

/* ---------- progress and Back ---------- */

.track {
  grid-area: track;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  margin-top: 6px;
  container-type: inline-size;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  min-width: 48px;
  min-height: 48px;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ak-link);
  font-size: 17px;
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.back:disabled { visibility: hidden; }

.dots {
  --dot: clamp(11px, calc((100cqw - var(--reserve, 104px)) / 15.5), 22px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
  margin-inline: auto;
  gap: 1px;
  margin: 0;
  padding: 3px 8px;
  list-style: none;
  border: 2px solid var(--ak-accent);
  border-radius: 999px;
  background: #E2BA72;
}

.dot {
  width: var(--dot);
  height: var(--dot);
  background-image: url("art/progress-dot.png");
  background-repeat: no-repeat;
  background-size: 1920% auto;
  background-position: 14.29% 51.3%;
}

.dot.is-done { background-position: 58.24% 51.3%; }
.dot.is-here { box-shadow: 0 3px 0 -1px var(--ak-accent-2); border-radius: 50%; }

/* ---------- the two cards ---------- */

.cards {
  grid-area: cards;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  height: clamp(124px, calc(37dvh - 90px), 250px);
  margin-top: 6px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: 0;
  padding: 26px 18px 22px;
  border: 0 solid transparent;
  border-image: url("art/choice-card.png") 56 fill / 26px stretch;
  border-radius: 20px;
  background: none;
  color: var(--ak-choice-ink);
  font-size: clamp(16px, 2.3dvh, 21px);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.card::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 14px;
  background: var(--ak-accent-2);
  opacity: 0;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.card-text { position: relative; z-index: 1; }

/* On a question answered before, the earlier pick says so in words, not only in colour. */
.card-keep {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 8px;
  translate: -50% 0;
  display: none;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.card.is-kept .card-keep { display: block; }

/* Keyboard focus is a dashed pencil line, so it never looks like a chosen card. */
.card:focus-visible { outline: 3px dashed var(--ak-ink); outline-offset: 4px; }
.question:focus { outline: none; }

.tick {
  position: absolute;
  z-index: 1;
  right: 14px;
  bottom: 12px;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.card.is-warm {
  box-shadow: 0 0 0 3px var(--ak-accent), 0 0 22px 4px color-mix(in srgb, var(--ak-accent-2) 60%, transparent);
}

.card.is-warm::after { opacity: 0.22; }
.card.is-warm .tick { opacity: 1; }
.card:disabled { cursor: default; }

.cards.is-folded { visibility: hidden; }

/* After the light lands, the strength and the watch-out are written where the cards were. */
.note {
  grid-area: cards;
  z-index: 1;
  align-self: stretch;
  /* It scrolls inside the room the cards had; it never makes that row taller and squeezes the wall. */
  contain: size;
  max-height: 100%;
  overflow-y: auto;
  margin-top: 6px;
  font-size: clamp(16px, calc(1dvh + 9px), 20px);
  line-height: 1.6;
  color: var(--ak-ink);
}

.note p { margin: 0 0 8px; }

.note-head {
  margin: 4px 0 2px;
  font-family: var(--ak-font-display);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--ak-accent);
}

.note .quiet { color: var(--ak-ink-muted); font-style: italic; }

.cards.is-waiting { visibility: hidden; }
.note .label { font-weight: 600; }

/* ---------- the caption: a strip of masking tape ---------- */

.caption {
  grid-area: caption;
  display: flex;
  align-items: center;
  min-height: 48px;
  margin: 10px -4px 0;
  padding: 8px 22px;
  background-color: var(--ak-surface);
  background-image: repeating-linear-gradient(90deg, transparent 0 7px, color-mix(in srgb, var(--ak-outline) 14%, transparent) 7px 8px);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: clamp(16px, 2.1dvh, 19px);
  font-weight: 600;
  line-height: 1.3;
  rotate: -0.6deg;
  filter: drop-shadow(0 1px 0 var(--ak-outline));
  clip-path: polygon(0 6%, 2% 0, 4% 8%, 6% 0, 94% 0, 96% 7%, 98% 0, 100% 9%, 99% 50%, 100% 92%, 98% 100%, 96% 93%, 94% 100%, 6% 100%, 4% 92%, 2% 100%, 0 94%, 1% 50%);
}

/* The one way on: always here, and its words say what it will do. */
.go {
  grid-area: go;
  min-height: 52px;
  margin: 10px 0 0;
  padding: 0 24px;
  border: 2px solid var(--ak-btn-fill);
  border-radius: 999px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 19px;
  font-weight: 600;
}

.go:disabled {
  border: 2px dashed var(--ak-outline);
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
  font-weight: 500;
  cursor: default;
}

/* ---------- the sheet: past results, one result, a delete check ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(72px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ak-bg) 72%, transparent);
}

.sheet-page {
  width: min(100%, 520px);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 18px 18px 52px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--soft-radius);
  background-color: var(--ak-surface);
  background-image:
    linear-gradient(90deg, transparent 38px, var(--margin-line) 38px, var(--margin-line) 39px, transparent 39px),
    repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px);
  background-attachment: local;
  color: var(--ak-ink);
  font-size: 17px;
  line-height: 32px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.sheet-page h2:focus { outline: none; }

.sheet-page h2 {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 32px;
}

.sheet-page p { margin: 0 0 0; }
.sheet-page .quiet { color: var(--ak-ink-muted); font-style: italic; }
.sheet-page .label { font-weight: 600; }

.shelf {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  text-align: left;
  line-height: 1.35;
}

.shelf-row .patch-light { width: 52px; }
.shelf-row.is-past .patch-light { background-position: 0 100%; }
.shelf-date { display: block; font-weight: 600; }
.shelf-summary { display: block; color: var(--ak-ink-muted); font-style: italic; }

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.sheet-actions button {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--ak-outline);
  border-radius: 999px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-style: italic;
}

.sheet-actions .is-main {
  border-color: var(--ak-btn-fill);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-style: normal;
}

.sheet-actions .is-remove {
  border-color: var(--ak-ink-muted);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-style: normal;
}

/* The chrome's ending, laid out as one solid written page: the wall picture, then the words,
   with the two buttons always in reach. Its top stays reachable when it scrolls. */
html #activity-chrome-ending.site-insightenes {
  justify-content: flex-start;
  padding: calc(72px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, none);
  background-size: cover;
  background-position: center;
}

html #activity-chrome-ending.site-insightenes .ac-card {
  display: flex;
  flex-direction: column;
  margin-block: auto;
  padding-bottom: 0;
}

html #activity-chrome-ending.site-insightenes .ac-work { order: 1; margin: 12px 0 16px; }
html #activity-chrome-ending.site-insightenes .ac-lines { order: 2; }
html #activity-chrome-ending.site-insightenes .ac-line:first-child { font-style: italic; }
html #activity-chrome-ending.site-insightenes .ac-actions {
  order: 3;
  position: sticky;
  bottom: 0;
  gap: 10px;
  margin: 16px -24px 0 -64px;
  padding: 10px 16px 12px 64px;
  border-top: 1px solid var(--ak-outline);
  background: var(--ak-surface);
}

html #activity-chrome-ending.site-insightenes .ac-actions button { padding: 0 14px; font-size: 16px; }
html #activity-chrome-ending.site-insightenes .ac-actions .ac-replay { background: var(--ak-btn-fill); color: var(--ak-btn-ink); border-color: var(--ak-btn-fill); font-style: normal; }

/* Sideways: the picture beside the words, and the page scrolls as one with its buttons pinned. */
@media (orientation: landscape) {
  html #activity-chrome-ending.site-insightenes { padding: max(12px, env(safe-area-inset-top)) calc(80px + env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }

  html #activity-chrome-ending.site-insightenes .ac-card {
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
    grid-template-rows: auto auto auto;
    column-gap: 22px;
    width: min(100%, 1040px);
    padding: 14px 20px 0 56px;
    font-size: clamp(15px, calc(1dvh + 11px), 18px);
    line-height: 1.55;
    background-image: linear-gradient(90deg, transparent 40px, var(--ak-accent) 40px, var(--ak-accent) 41px, transparent 41px);
  }

  html #activity-chrome-ending.site-insightenes .ac-work { grid-column: 1; grid-row: 1 / 3; align-self: start; margin: 4px 0 14px; }
  html #activity-chrome-ending.site-insightenes .ac-verdict { grid-column: 2; grid-row: 1; font-size: 20px; line-height: 1.4; margin-bottom: 6px; }
  html #activity-chrome-ending.site-insightenes .ac-lines { grid-column: 2; grid-row: 2; }
  html #activity-chrome-ending.site-insightenes .ac-line { margin-bottom: 6px; break-inside: avoid; }
  html #activity-chrome-ending.site-insightenes .ac-actions { grid-column: 1 / -1; grid-row: 3; margin: 8px -20px 0 -56px; padding: 8px 20px 10px 56px; }
}

/* A phone on its side: the wall was just on screen, so the words get the whole width in two columns. */
@media (orientation: landscape) and (max-height: 520px) {
  html #activity-chrome-ending.site-insightenes .ac-card { grid-template-columns: minmax(0, 1fr); font-size: 15px; line-height: 1.45; }
  html #activity-chrome-ending.site-insightenes .ac-work { display: none; }
  html #activity-chrome-ending.site-insightenes .ac-verdict { grid-column: 1; font-size: 18px; }
  html #activity-chrome-ending.site-insightenes .ac-lines { grid-column: 1; columns: 2; column-gap: 28px; }
}

/* ---------- sideways: the scene on the left, the page on the right ---------- */

@media (orientation: landscape) {
  .desk {
    width: min(100%, 1120px);
    height: min(100%, 760px);
    align-self: center;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.7fr) minmax(0, 0.45fr) auto;
    grid-template-rows: auto auto minmax(0, 340px) minmax(0, 1fr) auto;
    grid-template-areas:
      "scene head head past"
      "scene page page page"
      "scene cards cards cards"
      "scene . . ."
      "track caption go go";
    column-gap: 16px;
    padding: 4px 14px 8px 30px;
  }

  .head { min-height: 44px; }
  .logo { height: clamp(30px, 7dvh, 56px); }
  .page { margin: 0 0 4px; }
  .question { --q: clamp(17px, calc(2.4dvh + 8px), 28px); min-height: auto; }
  .scene-slot { padding: 6px 0 0; }
  .track { margin-top: 6px; align-self: center; }
  .cards { height: auto; min-height: 0; margin-top: 4px; gap: 14px; }
  .card { padding: 20px 16px 16px; border-image-width: 20px; font-size: clamp(17px, calc(1.8dvh + 10px), 23px); }
  .caption { margin-top: 6px; min-height: 44px; font-size: clamp(15px, calc(1dvh + 11px), 19px); }
  .go { align-self: center; margin-top: 6px; padding: 0 16px; font-size: clamp(16px, calc(1dvh + 12px), 19px); }
}

/* A phone on its side is short: the logo and Back sit with the wall, so the question, cards and
   the way on get the whole right side at a comfortable size. */
@media (orientation: landscape) and (max-height: 520px) {
  .desk {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.7fr) minmax(0, 0.5fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head page page"
      "scene page page"
      "scene cards cards"
      "track caption go";
    row-gap: 0;
    column-gap: 14px;
  }

  .head { min-height: 40px; }
  .logo { height: 32px; }
  .past-link { grid-area: head; justify-self: end; min-height: 44px; padding: 0 12px; font-size: 15px; }
  .page { margin: 0 0 6px; }
  .question { --q: clamp(19px, calc(3dvh + 9px), 22px); }
  .cards { gap: 12px; margin-top: 0; }
  .card { padding: 18px 14px 14px; font-size: 19px; line-height: 1.28; }
  .caption { font-size: 16px; padding: 6px 16px; }
  .go { min-height: 52px; font-size: 18px; padding: 0 12px; }
  .track { margin-top: 4px; }
}

/* A tall sideways screen has room: the way on sits right under the cards. */
@media (orientation: landscape) and (min-height: 600px) {
  .desk {
    grid-template-rows: auto auto minmax(0, 340px) auto minmax(0, 1fr) auto;
    grid-template-areas:
      "scene head head past"
      "scene page page page"
      "scene cards cards cards"
      "scene go go go"
      "scene . . ."
      "track caption caption caption";
  }

  .go { margin-top: 14px; }
}

/* ---------- motion: slow, and only when wanted ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .question.is-entering { animation: rr-fade-in var(--slow) var(--ease) both; }

  /* Both cards arrive together, so neither looks picked while they fade in. */
  :root:not(.ac-still) .cards.is-entering { animation: rr-fade-in 380ms var(--ease) both; }

  :root:not(.ac-still) .card { transition: box-shadow 360ms var(--ease), translate 360ms var(--ease); }
  :root:not(.ac-still) .card::after { transition: opacity 360ms var(--ease); }
  :root:not(.ac-still) .card.is-warm { translate: 0 -3px; }
  :root:not(.ac-still) .card.is-warm .tick path { stroke-dasharray: 40; animation: rr-draw 420ms var(--ease) both; }

  :root:not(.ac-still) .caption.is-changing { animation: rr-fade-in 420ms var(--ease) both; }

  :root:not(.ac-still) .walker { transition: scale 380ms var(--ease); }
  :root:not(.ac-still) .walker.is-reacting { animation: rr-hop 520ms var(--ease); }

  :root:not(.ac-still) .cards.is-folding .card { animation: rr-fold 700ms var(--ease) both; }
  :root:not(.ac-still) .cards.is-folding .card:nth-child(2) { animation-delay: 120ms; }

  :root:not(.ac-still) .scene.is-beaming .glint { animation: rr-glint 900ms ease-out both; }
  :root:not(.ac-still) .scene.is-beaming .beam line { animation: rr-beam 1500ms var(--ease) both; }

  :root:not(.ac-still) .patch.is-landing .patch-light { animation: rr-settle 1100ms var(--ease) both; }
  :root:not(.ac-still) .patch.is-landing .patch-light::after { animation: rr-fade-in 600ms 900ms var(--ease) both; }
  :root:not(.ac-still) .patch.is-settling .patch-light { animation: rr-nudge 600ms var(--ease) both; animation-delay: calc(var(--i, 0) * 110ms); }

  :root:not(.ac-still) .sheet-page { animation: rr-fade-in 420ms var(--ease) both; }
}

@keyframes rr-fade-in {
  from { opacity: 0; translate: 0 6px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes rr-draw {
  from { stroke-dashoffset: 40; }
  to { stroke-dashoffset: 0; }
}

@keyframes rr-hop {
  0% { translate: 0 0; }
  40% { translate: 0 -5%; }
  100% { translate: 0 0; }
}

@keyframes rr-fold {
  from { opacity: 1; scale: 1 1; }
  to { opacity: 0; scale: 1 0.04; }
}

@keyframes rr-glint {
  0% { opacity: 0; scale: 0.4; }
  50% { opacity: 1; scale: 1.3; }
  100% { opacity: 1; scale: 1; }
}

@keyframes rr-beam {
  from { stroke-dasharray: 0 2000; }
  to { stroke-dasharray: 2000 0; }
}

@keyframes rr-settle {
  0% { opacity: 0; scale: 1.7; filter: blur(6px); }
  60% { opacity: 1; scale: 0.94; filter: blur(0); }
  100% { opacity: 1; scale: 1; }
}

@keyframes rr-nudge {
  0% { scale: 1; }
  45% { scale: 1.08; }
  100% { scale: 1; }
}
