/* The common frame for every lab: a sheet of drafting paper with one vignette on it.
   Same paper, ink and red marker as the main page. A lab adds its own style.css for its vignette only. */

@font-face { font-family: "Young Serif"; src: url("../fonts/YoungSerif-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Crimson Pro"; src: url("../fonts/CrimsonPro-Italic.ttf") format("truetype"); font-style: italic; font-weight: 400; font-display: swap; }

:root {
  --on-pen: #fff; --btn-hover: #34393b; --frame: #e2e9ea;
  --paper: #eef1ef; --sheet: #fbfcfb; --ink: #191b1c; --soft: #3d4345; --red: #2a4dc4;
  --tint: #cfdbde; --shade: #d6dcdc; --pencil: #656c6e; --rule: rgba(25, 27, 28, 0.24);
  --grid: rgba(54, 98, 128, 0.075); --grid-major: rgba(54, 98, 128, 0.11);
  --serif: "Young Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --hand: "Crimson Pro", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
    --paper: #0e1626; --sheet: #16213a; --ink: #e9edf3; --soft: #b8c2d0; --red: #8fa8ff; --on-pen: #0e1626;
    --tint: #2a3d63; --shade: #070c16; --pencil: #8b98ad; --rule: rgba(233, 237, 243, 0.22);
    --grid: rgba(143, 168, 255, 0.055); --grid-major: rgba(143, 168, 255, 0.10); --btn-hover: #ffffff; --frame: #1d2c4a; color-scheme: dark;
} }
:root[data-theme="dark"] {
    --paper: #0e1626; --sheet: #16213a; --ink: #e9edf3; --soft: #b8c2d0; --red: #8fa8ff; --on-pen: #0e1626;
    --tint: #2a3d63; --shade: #070c16; --pencil: #8b98ad; --rule: rgba(233, 237, 243, 0.22);
    --grid: rgba(143, 168, 255, 0.055); --grid-major: rgba(143, 168, 255, 0.10); --btn-hover: #ffffff; --frame: #1d2c4a; color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sheet); color: var(--ink);
  font: 1rem/1.5 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, p, ul, ol, figure, table { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
.defs { position: absolute; }

.lab-page { max-width: 980px; margin-inline: auto; padding: 18px clamp(14px, 3vw, 28px) 26px; }
.lab-back { display: inline-block; margin-bottom: 14px; font-size: 0.875rem; color: var(--soft); }
.embed .lab-back { display: none; }
.lab-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 28px; align-items: baseline; }
.lab-kind { grid-column: 1 / -1; font: italic 1.0625rem/1.3 var(--hand); color: var(--soft); }
.lab-head h1 { font: 400 1.875rem/1.1 var(--serif); letter-spacing: -0.01em; }
.lab-lead { font-size: 1.0625rem; line-height: 1.45; max-width: 36rem; text-wrap: pretty; }

/* the stage: a patch of desk the vignette sits on */
.stage {
  position: relative; margin-top: 16px;
  padding: clamp(14px, 3vw, 26px);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
  overflow: hidden;
}
.stage::after { content: ""; position: absolute; inset: 0; border: 1.5px solid var(--ink); pointer-events: none; }

.stage-bar { display: flex; align-items: center; gap: 14px; min-height: 44px; margin-top: 6px; }
.stage-hint { font: italic 1.0625rem/1.3 var(--hand); color: var(--soft); }
.lab-toggle {
  appearance: none; cursor: pointer; flex: none;
  min-height: 32px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 4px; background: transparent;
  font: 600 0.8125rem/1 var(--sans);
  transition: background-color 160ms ease, color 160ms ease, transform 140ms var(--ease);
}
.lab-toggle:hover { background: var(--ink); color: var(--sheet); }
.lab-toggle:active { transform: scale(0.97); }
.lab-toggle[hidden] { display: none; }

.lab-for { margin-top: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
.lab-for li { padding-top: 10px; border-top: 1px solid var(--rule); font-size: 0.9375rem; line-height: 1.45; text-wrap: pretty; }
.lab-note { margin-top: 14px; font: italic 1.0625rem/1.3 var(--hand); color: var(--soft); }

/* ---------- shared drawing parts for vignettes ---------- */

.ink-box { position: relative; background: var(--sheet); border-radius: 6px 4px 7px 5px / 4px 7px 5px 6px; }
.ink-box::before {   /* an inked outline, with corners that are not quite the same */
  content: ""; position: absolute; inset: 0; border: 1.6px solid var(--ink); border-radius: inherit; pointer-events: none;
}
.kicker { font: 600 0.75rem/1.3 var(--sans); color: var(--soft); }
.hand { font: italic 1.0625rem/1.25 var(--hand); color: var(--soft); }
.mk {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
  background: var(--red); color: var(--on-pen); font: 700 0.75rem/1 var(--sans); font-variant-numeric: tabular-nums;
}
.btn-ink {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 16px; border: 0; border-radius: 4px;
  background: var(--ink); color: var(--sheet); font: 600 0.8125rem/1 var(--sans);
  transition: background-color 160ms ease, transform 140ms var(--ease), opacity 160ms ease;
}
.btn-ink:hover { background: var(--btn-hover); }
.btn-ink:active { transform: scale(0.97); }
.btn-ink.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-ink.ghost:hover { background: var(--tint); }
.btn-ink:disabled { opacity: 0.35; cursor: default; }
.squiggle {
  display: block; height: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0 3q5-4 10 0t10 0' fill='none' stroke='%236f7678' stroke-width='1.2'/%3E%3C/svg%3E") 0 0 repeat-x;
}

/* ink drawings inside a vignette */
.ink { fill: none; stroke: var(--ink); stroke-width: 1.6px; stroke-linecap: round; stroke-linejoin: round; }
.ink .heavy { stroke-width: 2.2px; }
.ink .thin { stroke-width: 1px; }
.ink .paper { fill: var(--sheet); }
.ink .tint { fill: var(--tint); }
.ink .solid { fill: var(--ink); }

/* the drawn cursor is a pencil; its tip is the hot spot */
.pencil-cursor {
  position: absolute; left: 0; top: 0; z-index: 5; width: 0; height: 0;
  pointer-events: none; opacity: 0;
  transition: transform 500ms var(--ease-in-out), opacity 200ms linear;
}
.pencil-cursor.on { opacity: 1; }
.pencil-cursor svg { position: absolute; left: -3px; top: -3px; width: 46px; height: 46px; overflow: visible; transform-origin: 3px 3px; transition: transform 110ms var(--ease); }
.pencil-cursor.down svg { transform: scale(0.9) rotate(-4deg); }
.pencil-tick {
  position: absolute; z-index: 4; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  border: 1.5px solid var(--pencil); pointer-events: none;
  animation: tick 520ms var(--ease) forwards;
}
@keyframes tick { from { opacity: 0.9; transform: scale(0.5); } to { opacity: 0; transform: scale(2.4); } }

@media (max-width: 640px) {
  .lab-head { grid-template-columns: minmax(0, 1fr); }
  .lab-head h1 { font-size: 1.625rem; }
  .lab-lead { margin-top: 6px; font-size: 1rem; }
  .lab-for { grid-template-columns: minmax(0, 1fr); }
  .lab-for li { padding-block: 9px; }
  .stage-hint { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; transition-delay: 0s !important; animation: none !important; }
  .pencil-cursor { display: none; }
}
