/* The three pages of the notebook (the opening, a question, the paths) and the margin above them.
   The gaps between blocks are the steps in notebook.css, and the type people read uses its sizes. */

/* The margin: the mark and the way to the paths. The lantern hangs between them. */
.margin { display: flex; flex: none; align-items: center; justify-content: space-between; gap: var(--step-3); min-height: clamp(56px, 10vh, 84px); }
.mark { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: var(--size-way)/1.5 var(--hand); }
.mark__ring { width: 30px; height: 30px; flex: none; }
.mark__ring .inked { stroke-width: 1.5; transition: stroke-dasharray .9s cubic-bezier(.45, 0, .25, 1), opacity .3s; }
.margin__paths { font-size: var(--size-way); }

/* The opening: one settled composition. Hidden ink still occupies its full space. */
.opening__composition { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--step-4) 64px; margin-block: auto; padding-block: var(--step-3); }
.opening__copy { max-width: 470px; }
.opening__copy h1 { font-size: clamp(36px, 3.4vw, 48px); line-height: 1.35; letter-spacing: -.035em; }
.opening__lead, .opening__word { display: block; }
.opening__word { font-size: clamp(60px, 6.2vw, 88px); line-height: 1.25; white-space: nowrap; }
.opening__underline { width: 100%; margin: 8px 0 var(--step-2); }
.opening__drawing { position: relative; width: min(100%, 440px, 46svh); justify-self: end; }
.opening__drawing svg, .paths__drawing svg { width: 100%; height: auto; }
.orbit-note { position: absolute; color: var(--pencil); font-size: clamp(16px, 1.5vw, 20px); white-space: nowrap; }
.orbit-note--top { left: 16%; top: -3%; transform: rotate(-5deg); }
.orbit-note--bottom { right: 0; bottom: -3%; transform: rotate(3deg); }
.opening__thought { grid-column: 1 / -1; max-width: 30em; text-wrap: pretty; font: 300 clamp(21px, 2vw, 25px)/1.55 var(--margin-hand); }
.opening .colophon { margin-top: 0; }

/* A question. The prompt is in the plain hand; the choices and the reasoning are set for reading. */
/* A tall screen puts some of its spare height above the question, so the page does not hang from the top edge. */
.page { container-type: inline-size; padding-top: clamp(0px, (100svh - 740px) * .3, 140px); }
.eyebrow { display: flex; align-items: center; gap: 18px; min-height: 24px; margin-bottom: var(--step-1); color: var(--pencil); font: var(--size-small)/1.8 var(--mono); white-space: nowrap; }
.eyebrow__difficulty svg { width: 22px; height: 12px; }
.prompt { max-width: 33em; font: 300 var(--size-prompt)/1.42 var(--margin-hand); text-wrap: pretty; overflow-wrap: break-word; }
.prompt[data-long] { font-size: var(--size-prompt-long); }
.prompt code { font-size: .74em; white-space: pre-wrap; }

/* Reading aloud: one word to press and a few quiet words about the voice. One line, always. */
.listen { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--pencil); font: 11px/1.8 var(--mono); white-space: nowrap; }
.listen__button { flex: none; margin-block: -12px; padding-block: 12px; color: var(--ink); font-size: var(--size-small); text-decoration: underline; text-decoration-color: var(--pencil); }
.listen__note { overflow: hidden; min-width: 0; text-overflow: ellipsis; }
.eyebrow .listen { flex-direction: row-reverse; margin-left: auto; }
.eyebrow .listen__button { padding-left: 12px; }
/* Under the notes, room is kept for the longest thing it says, so the line never rewraps. */
.feedback__foot .listen { flex: 0 0 auto; width: 232px; max-width: 100%; }
.feedback__foot .listen__button { padding-right: 4px; }

/* Code is open at the sides: a pencil rule above and below, and no box. */
.code {
  overflow-x: auto;
  margin: var(--step-3) 0 0;
  padding: calc(var(--step-2) + 6px) 4px;
  background: var(--sketch-rule) left top / 100% 10px no-repeat, var(--sketch-rule) left bottom / 100% 10px no-repeat;
  font-size: var(--size-code);
  /* Down to 11px, the type shrinks until the longest line (--longest characters, set by ui/page.js) fits the page. */
  font-size: clamp(11px, (100cqw - 8px) / (var(--longest, 46) * .61), var(--size-code));
  line-height: 1.6;
  tab-size: 4;
}
.code:focus-visible { outline-offset: 2px; }
.tok-comment { color: var(--receded); font-style: italic; }
.tok-string { color: var(--secondary-ink); }
.tok-keyword { color: var(--marked); }
.tok-number { color: var(--ink); }

.options { display: grid; gap: 0 56px; margin-top: var(--step-2); }
.option { position: relative; display: flex; align-items: baseline; gap: 22px; min-height: 44px; padding: 8px 0; font: var(--size-reading)/1.5 var(--reading); overflow-wrap: anywhere; }
.option__n { flex: none; min-width: 12px; color: var(--pencil); font: 300 var(--size-reading)/1.4 var(--margin-hand); }
.option__line { padding-bottom: 5px; background: var(--sketch-rule) left bottom / 0 7px no-repeat; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background-size .25s ease-out; }
.option__text code { font-size: .8em; white-space: pre-wrap; }
@media (hover: hover) {
  .option:not(:disabled):hover .option__line { background-size: 100% 7px; }
  .option:not(:disabled):hover .option__n { color: var(--ink); }
}
.option:focus-visible { outline-offset: 2px; }

/* Answered: a pencil circle around the right choice, a stroke through a wrong one, and the rest recede. */
.option[data-state="right"] { color: var(--marked); }
.option[data-state="rest"] { color: var(--receded); }
.option[data-state="rest"] .option__n, .option[data-state="wrong"] .option__n { color: var(--faint); }
.option[data-state="wrong"] { color: var(--pencil); }
.option[data-state="wrong"] .option__line { padding-bottom: 0; background: var(--strike) left 46% / 100% 9px no-repeat; animation: strike 380ms cubic-bezier(.45, 0, .25, 1) 120ms backwards; }
@keyframes strike { from { background-size: 0 9px; } }
.option__circle { position: absolute; }

.feedback:empty { display: none; }
.feedback { margin-top: var(--step-3); scroll-margin: var(--step-3); }
.verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 20px; }
.verdict__word { display: inline-block; font-size: clamp(28px, 3vw, 36px); line-height: 1.4; transform: rotate(-2deg); transform-origin: left bottom; }
.feedback[data-result="right"] .verdict__word { color: var(--marked); }
.verdict__notes { color: var(--pencil); font: 300 17px/1.5 var(--margin-hand); }
.deepen { display: flex; align-items: center; gap: 12px; margin-top: var(--step-1); font: 300 var(--size-note)/1.5 var(--margin-hand); }
.deepen svg { width: 30px; height: 30px; flex: none; stroke: var(--ink); }
.takeaway { max-width: 34em; margin-top: var(--step-1); overflow-wrap: break-word; }
.why__body { max-width: 62ch; margin-top: var(--step-2); color: var(--secondary-ink); font: calc(var(--size-reading) - 1px)/1.6 var(--reading); overflow-wrap: break-word; }
.why__body code { color: var(--ink); font-size: .8em; }
.feedback__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0 28px; margin-top: var(--step-2); }
.why-toggle { font-size: 20px; text-decoration: underline; text-decoration-color: var(--pencil); }
.page > .continue { align-self: flex-end; margin-top: auto; padding-top: var(--step-3); }

/* The paths: candles to light and put out, and the drawing so far. */
.paths { padding-top: clamp(0px, (100svh - 800px) * .2, 80px); }
.paths__heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 32px; }
.paths__heading h1 { font-size: clamp(56px, 8vw, 92px); line-height: 1.2; letter-spacing: -.02em; }
.paths__heading .hand-note { max-width: 30em; }
.paths__underline { width: min(100%, 300px); margin: 2px 0 var(--step-2); opacity: .6; }
.paths__drawing { position: relative; width: 210px; margin-right: -8px; }
.paths__drawing .orbit-note { font-size: 17px; }
.paths__facts { margin-top: var(--step-3); }
/* The groups stand about like bunches of candles on a table, each bunch as wide as it has candles. */
.paths__groups { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--step-4) 64px; margin-top: var(--step-4); }
.paths__group { max-width: 100%; }
.paths__group h2 { margin-bottom: var(--step-1); color: var(--pencil); font: 11px/1.8 var(--mono); }
/* In a bunch every other candle stands behind its neighbours, with its name between theirs, so a bunch is
   deep rather than a row. Each also stands a little forward or back (--lift), apart (--room), and leans its name (--lean).
   Each candle stands in a niche cut into the wall, drawn in chalk behind the page's flames and names (ui/scenery.js).
   A niche (--niche, half its width) is wider than a candle, so a name behind fits between the niches in front. */
.paths__bunch { --slot: 60px; --niche: 17px; --behind: 62px; position: relative; isolation: isolate; display: flex; flex-wrap: wrap; align-items: flex-end; margin-inline: -10px; padding-inline: 10px; }
.paths__scenery { position: absolute; z-index: -1; pointer-events: none; }
.path { display: flex; flex-direction: column; align-items: center; width: var(--slot); margin: 0 calc(var(--room, 0px) / 2) var(--lift, 0px); padding: 36px 0 6px; text-align: center; }
.path:nth-child(even) { margin-bottom: calc(var(--behind) + var(--lift, 0px)); }
.path__candle { position: relative; display: block; }
/* The pencil candle only sizes the candle and places its flame on screen; on paper, which has no niches, it is the candle. */
.path__stick { display: block; visibility: hidden; }
.path__name { width: calc((var(--slot) - var(--niche)) * 2 - 8px); margin-top: 4px; font: 300 15px/1.2 var(--margin-hand); text-wrap: balance; rotate: var(--lean, 0deg); transition: color .5s; }
.path__count { color: var(--pencil); font: 11px/1.8 var(--mono); }
@media print {
  .paths__scenery { display: none; }
  .path__stick { visibility: visible; }
}
.path[aria-pressed="false"] { color: var(--receded); }
.path[aria-pressed="false"] .path__stick { stroke: var(--faint); }
.path[aria-pressed="false"] .path__count, .path:disabled .path__count { color: var(--faint); }
.path:focus-visible { outline: none; }
.path:focus-visible .path__name { outline: 1px solid var(--ink); outline-offset: 3px; }
.paths__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 32px; margin-top: var(--step-4); }
.paths__restore { font-size: 20px; text-decoration: underline; text-decoration-color: var(--pencil); }
.paths__erase { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; margin-left: auto; color: var(--pencil); font: 11px/1.8 var(--mono); }
.paths__erase button { min-height: 44px; text-decoration: underline; text-decoration-color: var(--faint); }

@media (min-width: 701px) {
  /* Short choices sit two abreast. */
  .options[data-short] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .opening__composition { column-gap: 40px; }
}
/* The opening's two halves need a wide sheet. On an upright tablet or phone they stack. */
@media (max-width: 900px) and (orientation: portrait), (max-width: 700px) {
  .opening__composition { grid-template-columns: 1fr; gap: var(--step-3); padding-block: var(--step-2); }
  .opening__copy h1 { font-size: clamp(28px, 8vw, 44px); }
  .opening__word { font-size: clamp(46px, 14.5vw, 84px); }
  .opening__underline { max-width: 360px; margin-top: 4px; }
  /* The drawing gives up some of its size to the desk, so the way in stays on the first screen. */
  .opening__drawing { width: min(360px, 76%, calc(27svh - var(--desk) * .9)); margin-block: var(--step-2); justify-self: center; }
  .opening__thought { font-size: var(--size-note); }
}
/* A phone on its side keeps the two halves, at a size that leaves them room. */
@media (max-height: 500px) and (orientation: landscape) {
  /* The drawing stands beside everything that is written, so the page is no taller than the screen. */
  .opening__composition { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); column-gap: 40px; row-gap: var(--step-1); padding-block: 0; }
  .opening__copy { max-width: none; }
  .opening__copy h1 { font-size: 26px; }
  .opening__word { font-size: clamp(42px, 6vw, 54px); }
  .opening__underline { max-width: 360px; margin-bottom: var(--step-1); }
  .opening__drawing { grid-area: 1 / 2 / span 2; width: min(100%, 46svh); }
  .opening__thought { grid-column: 1; font-size: var(--size-note); }
  /* The paths' heading gives up its height, so the first screen shows some of the paths themselves. */
  .paths__heading h1 { font-size: 46px; }
  .paths__drawing { width: 120px; }
  .paths__facts { margin-top: var(--step-2); }
  .paths__groups { margin-top: var(--step-3); }
}
@media (max-width: 700px) {
  .margin { min-height: 56px; gap: var(--step-2); }
  .page, .paths { padding-top: 0; }
  .eyebrow { gap: 14px; }
  .option { gap: 18px; padding: 9px 0; line-height: 1.45; }
  .code { padding-inline: 2px; }
  .why-toggle, .paths__restore { font-size: 19px; }
  .paths__heading { gap: 12px; }
  .paths__drawing { width: 112px; align-self: start; margin-top: 8px; }
  .paths__drawing .orbit-note { display: none; }
  .paths__groups { gap: var(--step-3) 24px; }
  .paths__bunch { --slot: 52px; --niche: 15px; --behind: 58px; }
  .path__name { font-size: 13px; }
}
/* A short window on a wide screen: the margin gives its air to the page. */
@media (min-width: 701px) and (max-height: 780px) {
  .margin { min-height: 56px; }
}
@media (max-width: 520px) {
  .paths__erase { margin-left: 0; }
}
@media (max-width: 340px) {
  /* Too narrow for the credit beside the way in: it takes a slim line of its own above it. */
  .opening .colophon__notes { min-height: 0; }
  .opening__drawing { margin-block: 0; }
  .orbit-note { font-size: 14px; }
  .orbit-note--top { top: -13%; }
  .orbit-note--bottom { bottom: -13%; }
  /* Too narrow to say what listening downloads before it is asked for. */
  .eyebrow .listen[data-phase="idle"] .listen__note { display: none; }
}
