/* Paper Physics. Two papers: cream grid paper, and white pencil on blueprint. */
@font-face { font-family: "Nunito"; src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Playpen Sans"; src: url("fonts/playpen-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Playpen Sans"; src: url("fonts/playpen-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --paper: #F6F1E8; --sheet: #FDFBF5; --ink: #2C2C2C; --muted: #5A5850; --accent: #B42C24;
  --grid: rgba(92,130,150,.13); --major: rgba(72,112,135,.22); --edge: rgba(44,44,44,.85); --soft-edge: rgba(44,44,44,.22);
  --shadow: 1px 2px 0 rgba(44,44,44,.10), 3px 6px 14px rgba(70,55,30,.10);
  /* Colored pencils sampled from the sims. One per subject, nothing else. */
  --physics: #2460C8; --biology: #D0342C; --chemistry: #7A3FB4; --earth: #128A8E; --engineering: #E8741A; --fluids: #0B8FC7; --statics: #8A6A1F; --dynamics: #C0307A; --elementary: #2F8A3A;
  --hand: "Playpen Sans", "Segoe Print", "Comic Sans MS", cursive;
  --read: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --wobble: 3px 7px 4px 8px / 7px 3px 8px 4px;
}
[data-theme="blueprint"] {
  --paper: #17508F; --sheet: #1B5A9E; --ink: #F6FBFF; --muted: #CFE0F2; --accent: #FFE9A0;
  --grid: rgba(225,240,255,.09); --major: rgba(225,240,255,.20); --edge: rgba(246,251,255,.9); --soft-edge: rgba(246,251,255,.3);
  --shadow: 0 0 0 transparent;
  --physics: #B5DCFF; --biology: #FFC4BB; --chemistry: #E2CEFF; --earth: #B4F1EE; --engineering: #FFDCAE; --fluids: #BDEBFF; --statics: #F5E3A8; --dynamics: #FFC9E6; --elementary: #C8EBC8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  color: var(--ink); font: 400 18px/1.55 var(--read);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--major) 1px, transparent 1px), linear-gradient(90deg, var(--major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
}
main { flex: 1; width: 100%; }
.wrap { width: min(1160px, 100%); margin: 0 auto; padding: 0 20px; }
.prose { max-width: 68ch; }

h1, h2, h3 { font-family: var(--hand); font-weight: 400; line-height: 1.2; margin: 0; }
h1 { font-size: clamp(32px, 5.4vw, 52px); font-weight: 600; }
h2 { font-size: clamp(25px, 3.4vw, 33px); font-weight: 600; }
h3 { font-size: 21px; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px dashed var(--accent); outline-offset: 3px; }
.lede { font-size: clamp(19px, 2.2vw, 22px); line-height: 1.45; color: var(--muted); }
.muted { color: var(--muted); }
.skip { position: absolute; left: 12px; top: -60px; background: var(--sheet); padding: 8px 14px; border: 2px solid var(--edge); z-index: 5; }
.skip:focus { top: 10px; }

/* Header */
.head { padding: 16px 0 12px; }
.head .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand svg { display: block; }
.brand .mark { width: 42px; height: 42px; }
.brand .word { width: 198px; height: auto; color: var(--ink); }
.word g[fill="none"] { stroke: currentColor; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.nav a { padding: 8px 10px; text-decoration: none; font-weight: 700; font-size: 17px; min-height: 44px; display: inline-flex; align-items: center; }
.nav a[aria-current="page"] { text-decoration: underline wavy var(--accent) 2px; text-underline-offset: 6px; }

/* Buttons */
.btn, .paper-switch {
  font: 700 17px/1.2 var(--read); color: var(--ink); background: var(--sheet); text-decoration: none; cursor: pointer;
  border: 2px solid var(--edge); border-radius: var(--wobble); padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; -webkit-appearance: none; appearance: none;
}
.btn:hover, .paper-switch:hover { color: var(--accent); border-color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
[data-theme="blueprint"] .btn.primary:hover { color: #17508F; }
.paper-switch .swatch { width: 18px; height: 18px; border: 1.5px solid currentColor; display: inline-block; background: #17508F; }
[data-theme="blueprint"] .paper-switch .swatch { background: #F6F1E8; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* Sections */
.section { padding: 34px 0; }
.section > .wrap > h2 { margin-bottom: 8px; }
.page-top { padding: 22px 0 8px; }
.page-top .lede { margin: 10px 0 0; max-width: 62ch; }

/* Home */
.hero { padding: 12px 0 8px; }
.hero h1 { font-size: clamp(32px, 4.2vw, 46px); }
.hero .lede { margin: 6px 0 0; }
.feature-frame { width: min(100%, calc((100vh - 262px) * 1.6)); min-width: min(100%, 720px); margin: 16px auto 0; }
.feature figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; padding: 10px 2px 0; }
.feature-link { display: block; position: relative; text-decoration: none; }
.feature-link .thumb { display: block; }

/* A sheet of paper that holds a drawing */
.sim-sheet { background: var(--sheet); border: 2px solid var(--edge); border-radius: var(--wobble); box-shadow: var(--shadow); padding: 5px; }
.sim-sheet iframe { display: block; width: 100%; aspect-ratio: 16 / 10; height: auto; border: 0; background: var(--sheet); }

/* Paths */
.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 18px; margin-top: 14px; }
.paths.steps { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.path { display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 14px; background: var(--sheet); border: 2px solid var(--edge); border-radius: var(--wobble); box-shadow: var(--shadow); text-decoration: none; }
a.path:hover { border-color: var(--accent); color: inherit; }
a.path:hover h3 { color: var(--accent); }
.path p { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.4; }
.path .go { margin-top: auto; padding-top: 6px; font-weight: 800; font-size: 16px; }
.soon { font-size: 14px; font-weight: 800; color: var(--accent); }

/* Subject tabs, like the dividers in a binder. The hatching matches the sims. */
.tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.tab { --c: var(--ink); display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 16px 8px 12px; text-decoration: none; font-weight: 800; background: var(--sheet); border: 2px solid var(--edge); border-radius: var(--wobble); }
.tab:hover { color: var(--accent); border-color: var(--accent); }
.tab .n { font-weight: 600; color: var(--muted); font-size: 15px; }
.hatch { width: 22px; height: 22px; flex: none; border: 2px solid var(--c); background: repeating-linear-gradient(-45deg, var(--c) 0 1.6px, transparent 1.6px 4.6px); }
.s-physics { --c: var(--physics); } .s-biology { --c: var(--biology); } .s-chemistry { --c: var(--chemistry); }
.s-earth { --c: var(--earth); } .s-engineering { --c: var(--engineering); }
.s-fluids { --c: var(--fluids); } .s-statics { --c: var(--statics); } .s-dynamics { --c: var(--dynamics); } .s-elementary { --c: var(--elementary); }
.subject-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.subject-head .hatch { width: 30px; height: 30px; }

/* Sheet cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 24px; margin-top: 16px; }
.card { display: flex; flex-direction: column; background: var(--sheet); border: 2px solid var(--edge); border-radius: var(--wobble); box-shadow: var(--shadow); text-decoration: none; transition: transform .15s; }
.card:nth-child(3n+1) { transform: rotate(-.3deg); } .card:nth-child(3n) { transform: rotate(.25deg); }
.card:hover { transform: translateY(-3px); color: inherit; border-color: var(--accent); }
.card:hover h3 { color: var(--accent); }
.card-body { padding: 10px 14px 14px; }
.card-label { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--muted); }
.card-label .hatch { width: 14px; height: 14px; border-width: 1.5px; }
.card h3 { margin: 2px 0 4px; }
.card p { margin: 0; font-size: 17px; line-height: 1.4; color: var(--muted); }

/* Thumbnail: the doodle sits behind and shows only if the picture is missing. */
.thumb { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 2px solid var(--soft-edge); }
.thumb .doodle { position: absolute; inset: 0; margin: auto; width: 46%; height: 72%; color: var(--ink); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .blue { display: none; }
[data-theme="blueprint"] .thumb .blue { display: block; }
[data-theme="blueprint"] .thumb .cream { display: none; }

/* Two ways to read */
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; margin-top: 12px; }
.note { padding: 14px 18px; background: var(--sheet); border: 2px solid var(--soft-edge); border-radius: var(--wobble); }
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.draft { border: 2px dashed var(--accent); }
.draft-tag { display: inline-block; font-size: 14px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }

/* Stage */
.stage-page .head { padding: 10px 0 6px; }
.stage-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; padding: 0 20px 10px; }
.stage-title { display: flex; flex-direction: column; min-width: 0; }
.stage-title h1 { font-size: clamp(22px, 2.6vw, 30px); }
.stage-title small { font-size: 15px; font-weight: 700; color: var(--muted); }
.stage-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 2px solid var(--edge); border-radius: var(--wobble); background: var(--sheet); overflow: hidden; }
.seg button { font: 700 16px/1.15 var(--read); color: var(--ink); background: transparent; border: 0; padding: 8px 12px; min-height: 40px; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--edge); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible { outline-offset: -5px; }
.stage { padding: 0 20px; }
.stage .sim-sheet { width: min(100%, calc((100vh - 176px) * 1.6)); min-width: min(100%, 640px); margin: 0 auto; }
.stage-below { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 26px; padding-top: 22px; }
.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.keys li { display: flex; align-items: center; gap: 10px; }
kbd { font: 700 14px/1 var(--read); min-width: 30px; text-align: center; padding: 6px 8px; border: 1.5px solid var(--edge); border-bottom-width: 3px; border-radius: 4px 6px 5px 6px; background: var(--paper); color: var(--ink); }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-top: 20px; }
.not-found[hidden], .stage-wrap[hidden] { display: none; }

/* Footer */
.foot { margin-top: 40px; padding: 20px 0 26px; border-top: 2px solid var(--soft-edge); background: var(--paper); font-size: 16px; }
.foot-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px; }
.foot p { margin: 0 0 6px; max-width: 70ch; color: var(--muted); }
.foot nav { display: flex; flex-wrap: wrap; gap: 2px 16px; font-weight: 700; }
.foot nav a { padding: 6px 0; }

@media (max-width: 760px) {
  body { font-size: 17px; }
  .wrap { padding: 0 16px; }
  .brand .word { width: 160px; } .brand .mark { width: 36px; height: 36px; }
  .head { padding-top: 10px; }
  .head .brand { margin-right: auto; }
  .brand .word { width: 136px; }
  .paper-switch { order: 2; padding: 6px 10px; font-size: 15px; }
  .nav { order: 3; width: 100%; justify-content: space-between; gap: 0; }
  .nav a { padding: 6px 2px; font-size: 14px; }
  .feature-frame { width: 100%; min-width: 0; }
  .stage-bar { padding: 0 12px 8px; }
  .stage { padding: 0; }
  /* The sims stack upright on a phone and scroll inside their own frame. */
  .stage .sim-sheet { width: 100%; min-width: 0; padding: 0; border-width: 2px 0; border-radius: 0; box-shadow: none; }
  .stage .sim-sheet iframe { aspect-ratio: auto; height: 82vh; height: 82svh; }
  .stage-below { grid-template-columns: minmax(0, 1fr); padding-left: 0; padding-right: 0; }
  .card:nth-child(n) { transform: none; }
}
@media (max-height: 560px) and (orientation: landscape) { .stage .sim-sheet { width: 100%; min-width: 0; } }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }
@media print { .nav, .paper-switch { display: none; } }
