/* LessHW public pages: a sheet of squared maths paper, a red margin line,
   schoolbook type and two pens. The printed page stays quiet. The voice is the
   engine's handwriting: blue-black ink under the heading, red pen for the
   notes. Each note writes itself once as it scrolls into view. */
:root {
  color-scheme: light dark;
  --paper: #f4eedc;
  --leaf: #fffdf6;
  --ink: #1b1f2a;
  --pencil: #5d5a52;
  --red: #c6261b;
  --grid: rgb(72 108 150 / .15);
  --margin-line: rgb(198 38 27 / .46);
  --edge: rgb(27 31 42 / .24);
  --shade: rgb(27 31 42 / .16);
  --cell: 24px;
  --gutter: clamp(24px, 11vw - 18px, 170px);
  --indent: clamp(14px, 3.2vw, 30px);
  --outdent: clamp(18px, 5vw, 56px);
  --notes: clamp(170px, 26vw, 250px);
  --gap: clamp(44px, 7vw, 72px);
  --serif: "Century Schoolbook", "New Century Schoolbook", "Century Schoolbook L", C059, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --typed: "Nimbus Mono PS", Courier, "Courier New", monospace;
  --underline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 8' preserveAspectRatio='none'%3E%3Cpath d='M2 5.2C22 2.6 41 5.8 62 3.9S101 2.4 118 4.6' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1916;
    --leaf: #24221e;
    --ink: #efe8d6;
    --pencil: #aaa392;
    --red: #f26d60;
    --grid: rgb(239 232 214 / .07);
    --margin-line: rgb(242 109 96 / .42);
    --edge: rgb(239 232 214 / .26);
    --shade: rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  min-height: 100%;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent calc(var(--gutter) - 1px), var(--margin-line) calc(var(--gutter) - 1px), var(--margin-line) calc(var(--gutter) + 1px), transparent calc(var(--gutter) + 1px)),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: 100% var(--cell), var(--cell) var(--cell), var(--cell) var(--cell);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(17px, 1.2vw + 12.5px, 19px);
  line-height: 1.55;
}
h1, h2, h3, h4, p, figure { margin: 0; }
p, li, h1, h2, h3, h4, figcaption { overflow-wrap: break-word; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a:focus-visible, button:focus-visible, .story-crop:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
main:focus { outline: none; }
::selection { background: var(--ink); color: var(--paper); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; top: -100px; left: 12px; z-index: 20; padding: 12px 18px; background: var(--ink); color: var(--paper); font-weight: 700; }
.skip-link:focus { top: 12px; }

/* Everything hangs to the right of the margin line. Nothing is centred. */
.sheet {
  max-width: calc(var(--gutter) + var(--indent) + 940px + var(--outdent));
  padding: 0 var(--outdent) 0 calc(var(--gutter) + var(--indent));
}
.masthead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 28px; padding-top: clamp(16px, 4vw, 38px); }
.brand-link { display: inline-flex; align-items: center; min-height: 56px; }
.brand-link img { display: block; width: clamp(148px, 22vw, 176px); height: auto; }
.nav-list { display: flex; flex-wrap: wrap; gap: 0 clamp(12px, 2.6vw, 28px); list-style: none; margin: 0; padding: 0; }
.nav-list a { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 16px; text-decoration: none; }
.nav-list a:hover { text-decoration: underline; }
.nav-list a[aria-current] { font-weight: 700; }
.nav-list a[aria-current]::after, .price::after {
  content: ""; position: absolute; left: -4px; right: -4px; bottom: 5px; height: 7px;
  background: var(--red); -webkit-mask: var(--underline) center / 100% 100% no-repeat; mask: var(--underline) center / 100% 100% no-repeat;
}

.page { padding-top: clamp(30px, 6vw, 68px); }
.page-heading { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: clamp(22px, 3.4vw, 34px); }
h1 { max-width: 16em; font-size: clamp(34px, 6.4vw, 58px); line-height: 1.04; font-weight: 700; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: clamp(21px, 3vw, 27px); line-height: 1.16; font-weight: 700; letter-spacing: -.012em; text-wrap: balance; scroll-margin-top: 24px; }
h3 { font-size: 1.04em; line-height: 1.3; font-weight: 700; }
h4 { font-size: 1em; line-height: 1.3; font-weight: 700; scroll-margin-top: 24px; }
.page-content { max-width: 39em; }
.page-content > * + * { margin-top: 1em; }
.page-content > h2 { margin-top: 2.2em; }
.page-content > h2 + * { margin-top: .6em; }
.page-content > section { margin-top: var(--gap); }
.intro { font-size: 1.2em; line-height: 1.45; }
/* The planned price is underlined once in red pen. It is never struck. */
.price { position: relative; white-space: nowrap; }
.price::after { bottom: -5px; }

/* Engine-made handwriting. The same words sit beside each note as ordinary
   text; the drawing is hidden from assistive technology. Every note is shown at
   one scale, so the hand keeps one size down the page: --w is the drawing's
   own width (the build writes it per note) and --ink-scale the size it is
   shown at. The pen weight is set here because the drawings are shown smaller
   than they were made. */
.ink { --ink-scale: .62; width: min(100%, calc(var(--w, 420) * var(--ink-scale) * 1px)); color: var(--red); }
.ink svg { display: block; width: 100%; height: auto; overflow: visible; stroke-width: var(--pen, 2.2px); }

/* Home heading: the printed line is quiet and the handwriting under it is the
   loud one. The false start and its correction run the full width. */
.inked h1 { max-width: 21em; font-size: clamp(24px, 4.3vw, 36px); line-height: 1.14; letter-spacing: -.014em; }
.ink--heading { --ink-scale: .88; --pen: 1.8px; margin-top: clamp(6px, 1.6vw, 14px); color: var(--ink); rotate: -1.5deg; transform-origin: 0 70%; }
.ink--home-heading-like-this { --ink-scale: .7; --pen: 2.1px; margin: 2px 0 0 12%; color: var(--red); rotate: -4deg; }
.ink--home-hero-false-start { width: min(100% + var(--indent) * .5, 800px); margin: clamp(4px, 1.4vw, 14px) 0 0 calc(var(--indent) * -.5); rotate: -1deg; }
.ink-stop {
  display: inline-flex; align-items: center; min-height: 44px; margin-top: 6px; padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer;
  font: 700 16px/1.3 var(--serif); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 6px;
}
.ink-stop:hover { text-decoration-thickness: 3px; }
.ink-stop[aria-disabled="true"] { color: var(--pencil); cursor: default; font-weight: 400; font-style: italic; text-decoration: none; }

/* Home opening: what it is for, that it is not open, and the one action. The
   dashed pencil outline is how this sheet marks anything not available yet. */
.page-home .page-content { max-width: 34em; }
.status { width: fit-content; padding: 10px 14px; border: 1.5px dashed var(--pencil); border-radius: 3px; font-size: .92em; line-height: 1.45; }
.page-content > .action { margin-top: 1.5em; }
.action a { display: inline-flex; align-items: center; min-height: 48px; padding: 12px 22px; border-radius: 3px; background: var(--ink); color: var(--paper); font-weight: 700; text-decoration: none; transition: background-color 120ms ease; }
.action a:hover { background: var(--red); }
.action a:active { translate: 0 1px; }

/* A beat is one heading and one paragraph. Its red-pen note is written under
   the paragraph, towards the right. */
.beat > h2 + *, .examples > h2 + * { margin-top: .6em; }
.beat-body { display: flex; flex-direction: column; }
.beat-body > .ink { align-self: flex-end; margin-top: 10px; rotate: -2.5deg; }
.beat:nth-of-type(even) .ink { rotate: 1.5deg; }

/* Examples. A picture sits in a leaf with a hard shadow and is never shown
   wider than its own 1x width (--study-w, written per slot by the build). At
   100% the whole picture fits and nothing scrolls. Zooming enlarges it inside
   the frame and the frame's own scrolling pans it. The pixels are shown as
   released, in light and dark alike: no filter, no recolouring. One caption
   sits under each picture. */
.example-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); margin-top: 1.4em; }
.study { width: 100%; max-width: calc(var(--study-w, 600) * 1px); }
.story-slot { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--leaf); box-shadow: 4px 5px 0 var(--shade); }
.story-crop { overflow: auto; overscroll-behavior-x: contain; }
.story-crop picture { display: block; }
.story-crop img { display: block; width: calc(100% * var(--zoom, 1)); max-width: none; height: auto; }
.story-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; }
.story-controls button { min-width: 44px; min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--ink); border-radius: 3px; background: transparent; color: var(--ink); cursor: pointer; font: 700 15px/1.2 var(--serif); }
.story-controls button:not([data-story-zoom="reset"]) { padding: 0; font-size: 22px; line-height: 1; }
.story-controls button:hover { background: var(--leaf); }
.story-controls button[aria-disabled="true"] { border: 1.5px dashed var(--pencil); background: transparent; color: var(--pencil); cursor: default; }
.story-zoom { color: var(--pencil); font: 14px/1.4 var(--typed); font-variant-numeric: tabular-nums; }
.story-keys { margin-top: 10px; color: var(--pencil); font-size: .86em; }
.study figcaption { margin-top: 12px; font-weight: 700; line-height: 1.35; }

/* The refund line under the examples, and the notice at the foot of Terms:
   smaller plain type, ruled off from what is above. */
.small, .notices { padding-top: 16px; border-top: 1px solid var(--edge); font-size: .86em; }
.small { color: var(--pencil); }
.page-content > .small { margin-top: var(--gap); }
.notices > * + * { margin-top: 1em; }
.notices > h2 { font-size: 1.3em; }
.notices > h4 { margin-top: 1.8em; }

/* Finished work gets ruled off, starting at the margin line. */
.site-footer { margin: clamp(64px, 10vw, 112px) 0 0 calc(-1 * var(--indent)); padding: 14px 0 40px var(--indent); border-top: 2px solid var(--ink); }
.site-footer .nav-list a { font-size: 15px; }

/* Only the logo is inverted. The maths pictures keep their released pixels. */
@media (prefers-color-scheme: dark) {
  .brand-link img { filter: invert(1); }
}
@media (min-width: 700px) {
  .ink { --ink-scale: .68; }
  .ink--heading { --ink-scale: 1.02; }
  .ink--home-heading-like-this { --ink-scale: .8; }
  /* Home text hangs further right. The band it leaves holds the section
     headings, as margin headings; the pictures take the full width again. */
  .page-home .page-content { max-width: calc(var(--notes) + 34em); padding-left: var(--notes); }
  .beat, .examples { display: grid; grid-template-columns: var(--notes) minmax(0, 1fr); align-items: baseline; margin-left: calc(-1 * var(--notes)); }
  .beat > h2, .examples > h2 { padding-right: 18px; }
  .beat > h2 + *, .examples > h2 + * { margin-top: 0; }
  .example-list { grid-column: 1 / -1; }
}
@media (min-width: 760px) {
  /* The second picture steps to the right, like a second sheet laid on the first. */
  .study + .study { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Each note's own drawn width, read from its SVG by the build. */
.ink--home-heading-like-this{--w:199}
.ink--home-hero-false-start{--w:435}
.ink--home-only-look-circle{--w:524}
.ink--how-step-own-working{--w:597}
.ink--how-step-pay-once{--w:210}
/* Each maths picture's own 1x width, read from its file by the build. */
[data-math-slot="integral-limit-clean"]{--study-w:600}
[data-math-slot="ch4-boxed-ideal-opamp"]{--study-w:600}
