/* Blindfair — a white page, a kid's handwriting, a pencil in the margins. */

@font-face { font-family: 'Blindfair Crayon'; src: url(fonts/blindfair-crayon-regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Blindfair Crayon'; src: url(fonts/blindfair-crayon-bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Crayon Extra'; src: url(fonts/crayon-extra-a.woff2) format('woff2'); unicode-range: U+003C, U+003E, U+00A7, U+00B2, U+00B3, U+00B7, U+00B9, U+00D7, U+00E4, U+00F7, U+2013, U+2026, U+2212; font-display: swap; }
@font-face { font-family: 'Crayon Extra'; src: url(fonts/crayon-extra-greek.woff2) format('woff2'); unicode-range: U+0370-03FF; font-display: swap; }
@font-face { font-family: 'Crayon Extra'; src: url(fonts/crayon-extra-math.woff2) format('woff2'); unicode-range: U+2032, U+221A, U+2248, U+2260, U+2264, U+2265; font-display: swap; }
@font-face { font-family: 'Comic Mono'; src: url(fonts/comic-mono.woff2) format('woff2'); font-display: swap; }

:root {
  --paper: #ffffff;
  --ink: #26307a;      /* school ballpoint blue */
  --lead: #5d636d;     /* soft pencil */
  --pencil: #7c828c;
  --eth: #5b5fd8;      /* felt pen, ether violet */
  --green: #22924a;    /* green felt pen, bullish */
  --red: #d6392f;      /* red felt pen, titles */
  --hl: #fff27a;       /* highlighter */
  --col: 690px;
  --fs: 23px;
  --hand: 'Blindfair Crayon', 'Crayon Extra', 'Comic Sans MS', sans-serif;
  --mono: 'Comic Mono', 'Crayon Extra', ui-monospace, monospace;
  color-scheme: light;
}

html { background: #fff; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: #fff; color: var(--ink);
  font: 400 var(--fs)/1.48 var(--hand);
  position: relative; overflow-x: hidden;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--hl); color: var(--ink); }

.skip { position: absolute; left: -9999px; top: 12px; z-index: 60; background: #fff; padding: 6px 12px; }
.skip:focus { left: 12px; }

/* ---------- the pencil layer ---------- */
#doodles { position: absolute; left: 0; top: 0; width: 100%; height: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.dd-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.dd { position: absolute; overflow: visible; opacity: .62; filter: url(#grain); transform-origin: 50% 50%; }
.dd.behind { opacity: .17; }
.dd text, .figsvg text { font-family: var(--hand); }
.deco { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

.hero, main, .foot { position: relative; z-index: 1; }

/* ---------- hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh; box-sizing: border-box;
  display: grid; place-items: center; text-align: center;
  padding: 96px 20px 80px; overflow: hidden;
}
.hero-dd { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.hero-dd .dd { opacity: .88; }
/* the one moment of motion: the hero doodles get sketched in when the page opens */
.hero-dd .dd { animation: sketch .8s cubic-bezier(.4, .1, .3, 1) both; animation-delay: var(--d, 0s); }
@keyframes sketch { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .hero-dd .dd { animation: none; } }
.hero-dd.again .dd { animation: none; }
.hero-in { position: relative; z-index: 1; }
.hero-date { position: absolute; top: 22px; right: 30px; margin: 0; font-size: 22px; z-index: 1; color: var(--ink); }
.hero-title {
  font-size: clamp(66px, 18vw, 226px); line-height: .92; margin: 0;
  font-weight: 700; letter-spacing: .015em; color: var(--ink);
}
.hero-sub { font-size: clamp(24px, 3.3vw, 38px); margin: 14px 0 2px; line-height: 1.2; }
.hero-motto { margin: 2px 0 10px; font-size: clamp(21px, 2.4vw, 27px); color: var(--eth); }
.hero-x { margin: 0; font-size: 21px; }
.doors { display: flex; flex-wrap: wrap; justify-content: center; gap: 30px 46px; margin-top: 54px; }
.door {
  position: relative; display: block; width: 330px; box-sizing: border-box;
  padding: 18px 24px 22px; text-align: left; color: var(--ink); text-decoration: none;
  transition: transform .18s ease;
}
.door:hover { transform: rotate(-1.4deg) translateY(-3px); color: var(--ink); }
.door:nth-child(2):hover { transform: rotate(1.2deg) translateY(-3px); }
.door-t { display: block; font-weight: 700; font-size: 31px; line-height: 1.08; }
.door-d { display: block; font-size: 19px; line-height: 1.35; color: var(--lead); margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .door, .door:hover, .door:nth-child(2):hover { transition: none; transform: none; } }

/* ---------- reading column ---------- */
.col { max-width: var(--col); margin: 0 auto; padding: 0 22px; position: relative; }
.part { padding-top: 30px; }
.part-head { margin: 30px 0 52px; }
.part-title { font-size: clamp(46px, 7.4vw, 78px) !important; line-height: 1.04 !important; margin: 0 0 14px !important; }
.part-meta { color: var(--lead); font-size: 20px; margin: 0; }

h1, h2, h3 { position: relative; font-weight: 700; color: var(--ink); }
h2 { font-size: clamp(31px, 4.4vw, 42px); line-height: 1.12; margin: 2.1em 0 .62em; }
h3 { font-size: clamp(24px, 3.2vw, 29px); line-height: 1.2; margin: 1.65em 0 .48em; }
h2 + h3 { margin-top: .7em; }
p { margin: 0 0 .86em; }
strong, b { font-weight: 700; }
sub { font-size: .68em; line-height: 0; vertical-align: -.25em; }

a { color: var(--eth); text-decoration: underline wavy; text-decoration-thickness: 1.4px; text-underline-offset: 5px; text-decoration-skip-ink: none; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2.5px dashed var(--eth); outline-offset: 4px; border-radius: 6px; }

ul, ol { padding-left: 1.55em; margin: 0 0 1em; }
li { margin: .3em 0; }
li > p { margin: .2em 0; }
ul { list-style: none; }
ul > li { position: relative; }
ul > li::before {
  content: ''; position: absolute; left: -1.08em; top: .56em; width: .5em; height: .5em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M11 3.2c3.9.3 6.4 3.2 6 6.9-.4 3.8-3.6 6.4-7.4 6-3.6-.4-6.1-3.5-5.6-7 .4-3.1 3.2-5.6 6.4-5.6 1.4 0 2.6.4 3.6 1.1' fill='none' stroke='%23d6392f' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
ol > li::marker { color: var(--red); font-weight: 700; }

code { font-family: var(--mono); font-size: .76em; }
.codebox { position: relative; margin: 1.2em 0 1.5em; }
pre.code {
  margin: 0; padding: 18px 20px; overflow-x: auto; white-space: pre;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.6; color: var(--ink);
}
pre.code code { font-size: inherit; }

/* ---------- formulas ---------- */
.math { position: relative; margin: 1.3em 0 1.5em; padding: 12px 56px 12px 16px; }
.math-in { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.math .katex-display { margin: 0; }
.katex { font-size: 1.04em; color: var(--ink); }
.eqn { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--eth); font-size: 21px; }

/* ---------- tables ---------- */
.tbl { overflow-x: auto; margin: 1.2em 0 1.7em; padding: 8px 6px 12px; }
.tbl-in { position: relative; display: inline-block; min-width: 100%; vertical-align: top; }
.tbl table { border-collapse: collapse; font-size: 18px; line-height: 1.38; width: 100%; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 9px 13px 8px; }
.tbl th { font-weight: 700; }
.hex { word-break: break-all; }
.tbl-wide { width: min(1000px, calc(100vw - 36px)); margin-left: calc(50% - min(500px, calc(50vw - 18px))); box-sizing: border-box; }

/* ---------- figures ---------- */
.fig { width: min(920px, calc(100vw - 36px)); margin: 2.2em 0 2.4em calc(50% - min(460px, calc(50vw - 18px))); box-sizing: border-box; }
.fig-title { font-weight: 700; font-size: 23px; line-height: 1.25; margin-bottom: 2px; }
.fig-sub { color: var(--lead); font-size: 18px; margin-bottom: 8px; }
.fig-art { position: relative; margin-top: 14px; min-height: 40px; }
.figsvg { display: block; overflow: visible; }
.figsvg text.halo { paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round; }
.fig figcaption { color: var(--pencil); font-size: 17px; margin-top: 10px; text-align: center; }
.tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2;
  background: #fff; border: 2px solid var(--ink); border-radius: 14px 5px 16px 7px;
  padding: 6px 11px; font-size: 16px; line-height: 1.3; white-space: nowrap;
  opacity: 0; transition: opacity .12s;
}

/* ---------- between the two parts ---------- */
.cut { position: relative; height: 90px; max-width: 900px; margin: 90px auto 0; }

/* ---------- footer ---------- */
.foot { padding: 70px 0 140px; text-align: center; color: var(--lead); font-size: 20px; }

/* ---------- floating section switch ---------- */
.pill {
  position: fixed; z-index: 30; left: 50%; bottom: 16px;
  transform: translate(-50%, 160%); transition: transform .35s cubic-bezier(.2, .9, .3, 1.15);
  display: flex; align-items: center; gap: 4px; padding: 8px 18px;
  background: #fff; border-radius: 999px;
}
.pill.show { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .pill { transition: none; } }
.pill a, .pill button {
  position: relative; font: inherit; font-size: 20px; line-height: 1.2; color: var(--ink);
  text-decoration: none; background: none; border: 0; padding: 4px 13px; cursor: pointer;
}
.pill a.on { font-weight: 700; }
.pill .pill-line { z-index: -1; }
.toc-panel {
  position: fixed; z-index: 31; left: 50%; bottom: 80px; transform: translateX(-50%);
  width: min(560px, calc(100vw - 28px)); box-sizing: border-box; background: #fff; padding: 8px;
}
.toc-panel[hidden] { display: none; }
.toc-in { max-height: min(68vh, 640px); overflow: auto; padding: 14px 20px 10px; }
.toc-in h2 { font-size: 24px; margin: .2em 0 .3em; }
.toc-in ol { list-style: none; padding: 0; margin: 0 0 1em; }
.toc-in li { margin: .15em 0; font-size: 19px; line-height: 1.3; }
.toc-in a { text-decoration: none; color: var(--ink); }
.toc-in a:hover { color: var(--eth); text-decoration: underline wavy; }

@media (max-width: 640px) {
  :root { --fs: 20px; }
  .hero { padding-top: 84px; }
  .hero-date { right: 16px; top: 14px; font-size: 18px; }
  .door { width: 100%; max-width: 340px; }
  .col { padding: 0 18px; }
  pre.code { font-size: 12.5px; padding: 14px 14px; }
  .tbl table { font-size: 16px; }
  .tbl th, .tbl td { padding: 8px 10px 7px; }
  .math { padding-right: 46px; }
  .katex { font-size: .95em; }
  .pill a, .pill button { font-size: 18px; padding: 4px 9px; }
}

@media (min-width: 1100px) {
  .pill { left: auto; right: 22px; transform: translateY(160%); }
  .pill.show { transform: translateY(0); }
  .toc-panel { left: auto; right: 22px; transform: none; }
}

@media print {
  #doodles, .hero-dd, .pill, .toc-panel { display: none !important; }
}
