/* DRAWN — the notebook, on the web. Everything is graphite on squared paper:
   handwriting (Pangolin, Gaegu), pencil rules that wobble (an SVG filter),
   torn-off cards with masking tape, dotted leaders, figure captions, a stamp. */

@font-face { font-family: "Pangolin"; src: url("../fonts/Pangolin-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Gaegu"; src: url("../fonts/Gaegu-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  --paper: #f1eee6;
  --paper-2: #f7f5ef;
  --sheet: #f4f2ec;
  --ink: #2b2b2e;
  --ink-soft: #55555b;
  --ink-light: #8a8a90;
  --grid: rgba(70, 80, 95, 0.075);
  --grid-bold: rgba(70, 80, 95, 0.13);
  --shadow: rgba(40, 40, 45, 0.16);
  --tape: rgba(222, 218, 205, 0.82);
  --mark: rgba(43, 43, 46, 0.07);
  --hand: "Pangolin", "Gaegu", "Comic Sans MS", system-ui, sans-serif;
  --light: "Gaegu", "Pangolin", system-ui, sans-serif;
  --sq: 26px;
  --page: min(1120px, calc(100vw - 32px));
  /* the notebook is paper: never dark, whatever the device is set to ("only" also keeps
     browsers that darken pages by themselves, like Chrome's and Samsung's, away) */
  color-scheme: only light;
}


* { box-sizing: border-box; }
html { scroll-behavior: smooth; background-color: #f1eee6; color: #2b2b2e; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 19px;
  line-height: 1.55;
  background-color: var(--paper);
  /* the notebook's squares: 25 cm each, a bold line every metre */
  background-image:
    linear-gradient(var(--grid-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bold) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: calc(var(--sq) * 4) calc(var(--sq) * 4), calc(var(--sq) * 4) calc(var(--sq) * 4), var(--sq) var(--sq), var(--sq) var(--sq);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* paper grain */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .2 0 0 0 0 .22 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, header, footer { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; background-image: linear-gradient(var(--ink-soft), var(--ink-soft)); background-size: 100% 1.5px; background-position: 0 92%; background-repeat: no-repeat; transition: background-size .2s; }
a:hover { background-size: 100% 3px; }
a:focus-visible, button:focus-visible { outline: 2px dashed var(--ink-soft); outline-offset: 4px; border-radius: 6px; }

h1, h2, h3 { font-weight: 400; line-height: 1.15; margin: 0 0 .4em; letter-spacing: .01em; }
h1 { font-size: clamp(44px, 8vw, 96px); }
h2 { font-size: clamp(32px, 4.6vw, 52px); }
h3 { font-size: 26px; }
p { margin: 0 0 1em; }
.light { font-family: var(--light); color: var(--ink-soft); font-size: 1.12em; }
.small { font-size: .85em; color: var(--ink-light); }
.wrap { width: var(--page); margin: 0 auto; }
.center { text-align: center; }

/* the pencil: a stroke that wobbles (SVG displacement) */
.pencil { filter: url(#wobble); }
.rule { height: 0; border: 0; border-top: 2px solid var(--ink); opacity: .8; margin: 28px auto; width: 82%; filter: url(#wobble); }
.rule.double { border-top-width: 1.5px; box-shadow: 0 5px 0 -3.5px var(--ink); }

/* ── header ─────────────────────────────────────────────────────────── */
.top { display: flex; align-items: center; gap: 18px; padding: 18px 0; }
.mark { display: inline-flex; align-items: center; gap: 12px; font-size: 30px; background: none; }
.mark img { width: 44px; height: 44px; border-radius: 12px; }
.nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 20px; }
.nav a { background-size: 0 1.5px; }
.nav a:hover, .nav a[aria-current] { background-size: 100% 1.5px; }

/* ── a card torn off a pad, taped on ────────────────────────────────── */
.card {
  position: relative; background: var(--sheet); padding: 34px 34px 28px; margin: 24px 0;
  box-shadow: 6px 8px 0 -2px var(--shadow);
  clip-path: polygon(0 3px, 8% 0, 17% 2px, 29% 0, 41% 3px, 55% 1px, 68% 3px, 80% 0, 91% 2px, 100% 1px, 100% 100%, 0 100%);
}
.card::after { /* its edge, drawn in hard pencil */
  content: ""; position: absolute; inset: 2px; border: 1.6px solid var(--ink); opacity: .55; pointer-events: none; filter: url(#wobble);
  border-top: 0;
}
.tape { position: absolute; top: -12px; left: 50%; width: 130px; height: 30px; transform: translateX(-50%) rotate(-2deg); background: var(--tape);
  border-left: 2px dashed rgba(0,0,0,.08); border-right: 2px dashed rgba(0,0,0,.08); z-index: 2; }

/* ── the cover ──────────────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding: 30px 0 10px; }
.cover { padding: 46px 44px 40px; transform: rotate(-.6deg); }
.cover h1 { margin: 0; text-align: center; }
.edition { display: block; width: max-content; margin: 6px auto 26px; padding: 6px 22px; border: 2px solid var(--ink); border-radius: 6px;
  transform: rotate(-3deg); font-size: 24px; background: var(--paper-2); filter: url(#wobble); }
.field { display: grid; grid-template-columns: 110px 1fr; align-items: end; margin: 10px 0; }
.field span:first-child { font-family: var(--light); color: var(--ink-soft); }
.field span:last-child { border-bottom: 1.5px solid var(--ink-light); padding: 0 6px 2px; }
.hero .pitch { font-size: 22px; }
.stores { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; }

.btn { display: inline-flex; align-items: center; gap: 10px; font: inherit; font-size: 20px; color: var(--ink); cursor: pointer;
  padding: 10px 22px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 3px 4px 0 -1px var(--shadow);
  background-image: none; filter: url(#wobble); transition: transform .12s; }
.btn:hover { transform: translate(-1px, -1px) rotate(-.5deg); }
.btn.soon { border-style: dashed; color: var(--ink-soft); cursor: default; }
.btn svg { width: 22px; height: 22px; }

/* ── figures ────────────────────────────────────────────────────────── */
figure { margin: 0; }
figure img { display: block; width: 100%; height: auto; border: 1.5px solid var(--ink-light); background: var(--paper-2); }
figcaption { font-family: var(--light); color: var(--ink-soft); text-align: center; margin-top: 8px; font-size: 18px; }
.shot { padding: 14px; background: var(--sheet); box-shadow: 5px 6px 0 -2px var(--shadow); transform: rotate(.5deg); }
.shot:nth-child(even) { transform: rotate(-.7deg); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 34px 30px; margin: 30px 0; }

/* ── sections ───────────────────────────────────────────────────────── */
section { padding: 46px 0 20px; }
.section-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.section-head .num { font-family: var(--light); color: var(--ink-light); font-size: 22px; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.note { padding-left: 18px; border-left: 2px solid var(--ink-light); }
.note h3 { margin-bottom: 6px; }

/* the table of contents: dotted leaders, like the credits' staff list */
.toc { list-style: none; padding: 0; margin: 20px 0 0; columns: 2; column-gap: 54px; }
.toc li { break-inside: avoid; display: grid; grid-template-columns: 52px 1fr; margin: 0 0 14px; }
.toc .roman { font-size: 22px; }
.toc .line { display: flex; align-items: baseline; gap: 8px; font-size: 21px; }
.toc .line::after { content: ""; flex: 1; border-bottom: 2px dotted var(--ink-light); transform: translateY(-5px); order: 1; }
.toc .line .n { order: 2; font-family: var(--light); color: var(--ink-soft); }
.toc .sub { grid-column: 2; font-family: var(--light); color: var(--ink-soft); font-size: 18px; margin-top: -2px; }

/* a level's tasks, as the game shows them */
.tasks { max-width: 640px; }
.task { display: grid; grid-template-columns: 46px 1fr 1.1fr 34px; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--ink-light); }
.task:last-child { border-bottom: 0; }
.task .and { grid-column: 2 / 5; display: grid; grid-template-columns: 1fr 1.1fr 34px; gap: 8px; padding-left: 12px; border-left: 2px solid var(--ink-light); }
.task .formula { font-family: var(--light); font-size: 20px; color: var(--ink-soft); direction: ltr; }
.star { width: 30px; height: 30px; }
.tick { width: 22px; height: 22px; }

/* the imprint (footer), like the credits page */
.imprint { padding: 40px 0 70px; font-size: 17px; }
.codes { display: flex; justify-content: space-between; color: var(--ink-soft); font-family: var(--light); font-size: 18px; }
.colophon { max-width: 720px; margin: 0 auto; text-align: center; font-family: var(--light); color: var(--ink-soft); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px; margin: 18px 0; font-size: 19px; }
.stamp { display: inline-block; padding: 6px 18px; border: 3px double var(--ink-soft); border-radius: 8px; color: var(--ink-soft);
  transform: rotate(-8deg); letter-spacing: .2em; font-size: 20px; opacity: .8; filter: url(#wobble); }

/* long pages: privacy, terms, support */
.doc { max-width: 820px; margin: 0 auto; }
.doc .card { padding: 40px 46px; }
.doc h2 { font-size: 30px; margin-top: 1.3em; }
.doc h3 { font-size: 23px; margin-top: 1em; }
.doc li { margin-bottom: .35em; }
.doc table { border-collapse: collapse; width: 100%; font-size: .92em; }
.doc th, .doc td { text-align: start; vertical-align: top; padding: 8px 10px; border-bottom: 1px dashed var(--ink-light); }
.doc th { font-weight: 400; color: var(--ink-soft); }
.doc th, .doc td { overflow-wrap: anywhere; }   /* long words and addresses wrap on narrow phones */
details { border-bottom: 1px dashed var(--ink-light); padding: 10px 0; }
summary { cursor: pointer; font-size: 21px; list-style: none; }
summary::before { content: "✎ "; color: var(--ink-light); }

@media (max-width: 880px) {
  .top { flex-wrap: wrap; }
  .nav { margin-left: 0; width: 100%; }
  .field { grid-template-columns: 90px 1fr; }
  .hero { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .toc { columns: 1; }
  .nav { gap: 4px 16px; font-size: 18px; }
  .doc .card { padding: 30px 22px; }
  .task { grid-template-columns: 40px 1fr; }
  .task .formula { grid-column: 2; }
  .task .and { grid-column: 1 / 3; grid-template-columns: 1fr; }
  .codes { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* (no inline styles: the pages' content security policy forbids them) */
svg.defs { position: absolute; width: 0; height: 0; }
.doc-title { font-size: 52px; }
.doc-title.big { font-size: 64px; }
.doc.wide { max-width: 1000px; }
.grow { flex: 1; }

/* ── the new home page: a phone that turns, clips that loop, a tag you can try ── */
.lead { max-width: 760px; }
.hero { grid-template-columns: 1.15fr .85fr; }
.hero-text .cover { margin-bottom: 26px; }
.write::after { content: "|"; opacity: 0; }
.write.typing::after { opacity: 1; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.phone-stage { margin: 0; display: grid; justify-items: center; gap: 14px; }
.phone-stage figcaption { display: grid; justify-items: center; gap: 6px; text-align: center; }
.phone { position: relative; width: min(300px, 70vw); aspect-ratio: 9 / 13.5; padding: 14px; border: 2.5px solid var(--ink); border-radius: 34px;
  background: var(--paper-2); box-shadow: 8px 10px 0 -3px var(--shadow); transform: rotate(1.5deg);
  transition: width .7s cubic-bezier(.3,.7,.2,1), aspect-ratio .7s cubic-bezier(.3,.7,.2,1), transform .7s cubic-bezier(.3,.7,.2,1); filter: url(#wobble); }
.phone::before { content: ""; position: absolute; top: 6px; left: 50%; width: 46px; height: 4px; border-radius: 2px; background: var(--ink-light); transform: translateX(-50%); }
.phone.wide { width: min(440px, 88vw); aspect-ratio: 13.5 / 8; transform: rotate(-1.5deg); }
.phone.wide::before { top: 50%; left: 6px; width: 4px; height: 46px; transform: translateY(-50%); }
.screen { width: 100%; height: 100%; overflow: hidden; border-radius: 20px; border: 1.5px solid var(--ink-light); background: #f2efe8; }
.screen video { width: 100%; height: 100%; object-fit: cover; display: block; filter: none; }
.small-btn { font-size: 17px; padding: 8px 16px; }

video.loop { display: block; width: 100%; height: auto; background: #f2efe8; }
.clip video { aspect-ratio: auto; }
.shot figcaption { margin-top: 10px; font-family: var(--light); color: var(--ink-soft); font-size: 17px; }

.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; margin: 28px 0; }
.steps { display: grid; gap: 22px; }
.step { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start; }
.step .n { display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid var(--ink); border-radius: 50%; font-size: 24px;
  filter: url(#wobble); }
.step h3 { margin: 4px 0 4px; }
.step p { margin: 0; }

/* the tag you can try: a little ball you set and throw */
.tag-demo { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; padding: 30px 28px 24px; margin-top: 34px; align-items: center; }
.tag-scene { width: 100%; height: auto; overflow: visible; }
.tag-scene .ink { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; filter: url(#wobble); }
.tag-scene .thin { stroke-width: 1.4; }
.tag-scene .fill-soft { fill: rgba(43, 43, 46, .08); }
.tag-scene .trail { fill: none; stroke: var(--ink-light); stroke-width: 1.6; stroke-dasharray: 3 6; }
.tag-scene .hand { font-family: var(--hand); fill: var(--ink); font-size: 18px; }
.tag { border-left: 2px dashed var(--ink-light); padding-left: 22px; display: grid; gap: 12px; }
.tag h3 { margin: 0; }
.tag label { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 18px; }
.tag label output { font-family: var(--light); }
.tag input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.tag .btn { justify-self: start; }

/* contents: a chapter's page beside the list */
.contents { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; align-items: start; }
.toc li { cursor: pointer; border-radius: 6px; transition: background .25s; }
.toc li:hover, .toc li.on { background: var(--mark); }
.toc li:focus-visible { outline: 2px dashed var(--ink-soft); outline-offset: 3px; }
.toc-view { position: sticky; top: 24px; }
.toc-view img, .toc-view video { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #f2efe8; }

/* sandboxes: one wide, two tall */
.trio { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; align-items: start; margin: 26px 0 34px; }
.trio .tall video { aspect-ratio: 2 / 3; object-fit: cover; }

/* the lightbox for figures */
.lightbox { border: 0; padding: 18px; background: var(--sheet); box-shadow: 8px 10px 0 -2px var(--shadow); max-width: min(1400px, 94vw); }
.lightbox::backdrop { background: rgba(43, 43, 46, .55); }
.lightbox img { display: block; max-width: 100%; max-height: 80vh; }
.lightbox .btn { margin: 14px auto 0; display: flex; }

/* things arrive like a page being written on */
.reveal { opacity: 0; transform: translateY(14px) rotate(-.3deg); transition: opacity .7s ease, transform .7s ease; }
.reveal.seen { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .hero, .split, .tag-demo, .contents { grid-template-columns: minmax(0, 1fr); }
  .trio { grid-template-columns: 1fr 1fr; }
  .trio .wide { grid-column: 1 / -1; }
  .toc-view { position: static; order: -1; }
  .tag { border-left: 0; border-top: 2px dashed var(--ink-light); padding: 18px 0 0; }
}
/* phones: the wide clip across, the two tall ones side by side (one each would fill the screen) */
@media (max-width: 520px) {
  .trio { gap: 18px; }
  .trio .shot { padding: 8px; }
  .trio .tall figcaption { font-size: 15px; }
  .btn { font-size: 18px; padding: 10px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .phone { transition: none; }
}
.contents .toc { columns: 1; margin-top: 0; }
.contents .toc li { padding: 6px 8px; margin: 0 0 6px; }
[hidden] { display: none !important; }
