/* One continuous black notebook: paper, ink, and pencil. Nothing here has a colour, a panel, or a shadow. */
@font-face {
  font-family: "Notebook";
  src: url("../../assets/fonts/NothingYouCouldDo.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Kalam";
  src: url("../../assets/fonts/Kalam-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

/* A number, so it can fade (styles/scene.css). */
@property --lit { syntax: "<number>"; inherits: true; initial-value: 1; }

:root {
  color-scheme: dark;
  --paper: #090a09;
  /* The page darkens with the cellar as path candles are put out (--lit is the share still lit; ui/app.js sets it),
     though never too dark to read: small and secondary ink dims half as much, so a rested path's name stays findable. */
  --lit: 1;
  --k: calc(1 - (1 - var(--lit)) * .34);
  --ink: color-mix(in srgb, #e9e7df calc(var(--k) * 100%), #090a09);
  --marked: color-mix(in srgb, #fff calc(var(--k) * 100%), #090a09); /* a marked word, and whatever the pointer rests on */
  --secondary-ink: color-mix(in srgb, #b8b7ae calc((1 + var(--k)) * 50%), #090a09);
  --pencil: color-mix(in srgb, #a09f96 calc((1 + var(--k)) * 50%), #090a09);
  --line: color-mix(in srgb, #a3a399 calc(var(--k) * 100%), #090a09);
  --receded: color-mix(in srgb, #77766f calc((1 + var(--k)) * 50%), #090a09);
  --faint: color-mix(in srgb, #55584f calc(var(--k) * 100%), #090a09);
  --hand: "Notebook", cursive; /* headings, notes, and the ways onward */
  --margin-hand: "Kalam", cursive; /* small reference text and the labels of a sketch */
  --reading: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;

  --sketch-rule: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 20' preserveAspectRatio='none' fill='none' stroke='%23a09f96' stroke-linecap='round'%3E%3Cpath d='M4 12 C35 10 58 13 90 10 S150 7 187 10 S246 13 281 10 S339 8 381 11 S445 12 483 8 S556 8 596 10' stroke-width='1.15' opacity='.75'/%3E%3Cpath d='M592 13 C563 10 540 14 507 11 S449 9 410 12 S360 14 315 10 S266 9 225 12 S160 14 119 10 S55 10 10 14' stroke-width='.8' opacity='.5'/%3E%3Cpath d='M25 15 Q80 11 133 12 M205 8 Q263 11 320 13 M402 14 Q461 10 540 10' stroke-width='.7' opacity='.35'/%3E%3C/svg%3E");
  --pencil-edge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 400' preserveAspectRatio='none' fill='none' stroke='%23a09f96' stroke-linecap='round'%3E%3Cpath d='M5 3 C2 85 7 148 4 226 S6 325 4 397' stroke-width='1' opacity='.4'/%3E%3Cpath d='M7 32 Q4 118 6 178 M3 247 Q5 317 6 367' stroke-width='.6' opacity='.2'/%3E%3C/svg%3E");
  --strike: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 12' preserveAspectRatio='none' fill='none' stroke='%23e9e7df' stroke-linecap='round'%3E%3Cpath d='M3 7 C70 4 130 8 205 5 S340 8 420 5 S540 7 597 4' stroke-width='1.2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16' fill='none' stroke='%23e9e7df' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 9 C4 10 6 12 7.5 14 C10 9 13 5 18 2'/%3E%3C/svg%3E");
  --cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 17' fill='none' stroke='%23e9e7df' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M3 3 C7 6 11 10 15 14 M15 2 C11 6 7 10 3 14.5'/%3E%3C/svg%3E");
  --ring: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none' fill='none' stroke='%23a3a399' stroke-width='1.1' stroke-linecap='round'%3E%3Cpath d='M52 3 C24 1 4 8 3 20 C2 33 26 38 52 37 C80 37 98 31 97 19 C96 7 74 2 44 4' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --bracket: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none' fill='none' stroke='%23a3a399' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M2 1 C2 5 3 6 8 6 L92 6.5 C97 6 98 5 98 1' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  --elbow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 28' fill='none' stroke='%23a3a399' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M4 1 C4 12 5 17 17 18'/%3E%3C/svg%3E");
  --dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 8' fill='none' stroke='%23a3a399' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M1 4 C5 3 10 5 15 4'/%3E%3C/svg%3E");
  --note-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 16' fill='none' stroke='%23a3a399' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M26 8 C18 8.5 10 7.8 3 8.3 M9 2.6 L2.5 8.3 L8.8 13.6'/%3E%3C/svg%3E");

  /* Steps of space, used for every gap on a page. They tighten on small and on short screens,
     so a question generally fits a phone without scrolling. */
  --step-1: 6px; /* a label and what it labels */
  --step-2: 12px; /* lines of one block */
  --step-3: 24px; /* one block and the next */
  --step-4: 40px; /* one part of a page and the next */

  /* Sizes of type. The script hand is for a few words at a time; a sentence is in the plainer margin hand. */
  --size-prompt: clamp(23px, 2.1vw, 27px);
  --size-prompt-long: clamp(21px, 1.8vw, 24px);
  --size-note: 21px; /* handwritten sentences: the takeaway, the opening's lines */
  --size-reading: 19px; /* choices and explanations */
  --size-code: 15px;
  --size-way: 25px; /* the mark and the ways onward */
  --size-small: 12px; /* labels and sources */

  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--hand);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* No scrollbar is drawn: it would cut a strip out of the wall. A page that runs on goes out of focus behind the desk instead. */
  scrollbar-width: none;
}

* { box-sizing: border-box; }
:root::-webkit-scrollbar { display: none; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p, figure, ol, ul { margin: 0; padding: 0; font-weight: 400; }
ol, ul { list-style: none; }

/* Announce pencil marks without adding visible text or taking space on the page. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

a, button {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a { text-decoration-color: var(--pencil); }
button { border: 0; background: none; padding: 0; font: inherit; text-align: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 6px; }
[tabindex="-1"]:focus { outline: none; }
::selection { color: var(--paper); background: var(--ink); }
code, pre { font-family: var(--mono); }

@media (hover: hover) {
  a:hover, button:not(:disabled):hover { color: var(--marked); }
}

/* Pencil strokes. */
.ink-art {
  display: block;
  overflow: visible;
  fill: none;
  stroke: var(--line);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.ink-art .faint { stroke: var(--faint); }
.ink-art .inked { stroke: var(--ink); stroke-width: 1.4; }

.muted { color: var(--pencil); }
.marked-word { color: var(--marked); }
.hand-note { font: 300 var(--size-note)/1.55 var(--margin-hand); text-wrap: pretty; }
.hand-note code { font-size: .74em; white-space: pre-wrap; }

/* The ways onward are plain handwritten words with a small pencil arrow. */
.hand-link { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: 22px/1.5 var(--hand); text-decoration: none; }
.hand-link svg { width: 24px; height: 14px; stroke: currentColor; stroke-width: 1; }
.continue { display: flex; flex: none; align-items: center; gap: 14px; min-height: 44px; font: var(--size-way)/1.5 var(--hand); white-space: nowrap; }
.continue svg { width: 28px; height: 16px; stroke: currentColor; stroke-width: 1; }
.source-link { display: inline-block; padding-block: 10px; color: var(--pencil); font: 11px/1.8 var(--mono); text-decoration: none; }
.source-link span { margin-left: 5px; }
.voice-credit { color: var(--pencil); font: 11px/1.8 var(--mono); text-decoration: none; white-space: nowrap; }
@media (hover: hover) {
  .source-link:hover, .voice-credit:hover { text-decoration: underline; }
}

/* The page: one column with wide margins, in ordinary document flow. */
/* Its foot is kept clear for the desk (--desk, set in scene.css and by ui/room.js). */
#app { position: relative; z-index: 1; display: flex; flex-direction: column; width: min(820px, calc(100% - 112px)); min-height: 100svh; margin: 0 auto; padding-bottom: var(--desk); }
/* The opening and the list of paths are compositions, and take a wider sheet than a column of reading. */
#app:is([data-view="opening"], [data-view="paths"]) { width: min(940px, calc(100% - 160px)); }
.stage { display: flex; flex: 1; flex-direction: column; }
.stage > main { display: flex; flex: 1; flex-direction: column; padding-bottom: max(var(--step-3), env(safe-area-inset-bottom)); }
.notice { margin: 20vh 0; white-space: pre-line; font: 300 22px/1.7 var(--margin-hand); color: var(--pencil); }
/* The foot of a page: small print on the left, the way onward on the right. */
.colophon { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0 var(--step-3); margin-top: auto; padding-top: var(--step-3); }
.colophon .continue { margin-left: auto; }
.colophon__notes { display: flex; align-items: center; min-height: 44px; }

/* Handwriting. The nib belongs to the current stroke, never to the reader's pointer. */
.pen-tip { position: fixed; z-index: 7; top: -3px; left: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); pointer-events: none; }
.ink-word { display: inline-block; white-space: nowrap; }
.ink-keep, .ink-keep code { white-space: nowrap; }
[data-ink]:not(.written) .ink-word { opacity: 0; }
[data-draw]:not(.written), [data-draw]:not(.written) path { opacity: 0; stroke-dasharray: 1; stroke-dashoffset: 1; }
[data-fade] { transition: opacity .4s ease-out; }
[data-fade]:not(.written) { opacity: 0; pointer-events: none; }
@keyframes draw { from { stroke-dashoffset: 1.01; } }
@keyframes rub { to { opacity: 0; } }

@media (max-width: 1100px) {
  #app:is([data-view="opening"], [data-view="paths"]) { width: calc(100% - 120px); }
}
@media (max-width: 800px) {
  #app, #app:is([data-view="opening"], [data-view="paths"]) { width: auto; margin-inline: 28px; }
}
/* A phone, upright or on its side: every step and size comes down together. */
@media (max-width: 700px), (max-height: 500px) {
  :root {
    --step-2: 10px;
    --step-3: 16px;
    --step-4: 28px;
    --size-prompt: 21px;
    --size-prompt-long: 19px;
    --size-note: 19px;
    --size-reading: 17px;
    --size-code: 12.5px;
    --size-way: 22px;
    --size-small: 11px;
  }
}
@media (max-width: 360px) {
  #app, #app:is([data-view="opening"], [data-view="paths"]) { margin-inline: 22px; }
}
/* A short window on a wide screen keeps its sizes and gives up some air. */
@media (min-width: 701px) and (min-height: 501px) and (max-height: 780px) {
  :root { --step-3: 18px; --step-4: 30px; }
}
@media print {
  :root { --paper: #fff; --ink: #111; --marked: #000; --secondary-ink: #222; --pencil: #555; --line: #555; --receded: #777; --faint: #999; color-scheme: light; }
  :root { --desk: 0px !important; }
  .pen-tip, .continue, .margin__paths, .listen, .room, .room-lamp, .room-desk { display: none; }
  /* Paper has no pen: everything is already written. */
  .ink-word, [data-fade], [data-draw], [data-draw] path { opacity: 1 !important; clip-path: none !important; stroke-dashoffset: 0 !important; }
}
