/* Look: pans traced in pencil on baking parchment, inside a rolled-rim aluminium half-sheet pan.
   Fonts are self-hosted OFL files in fonts/ (licences beside them); nothing is loaded from any host. */
@font-face { font-family: "Caveat"; src: url(fonts/caveat-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(fonts/caveat-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Figtree"; src: url(fonts/figtree-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Figtree"; src: url(fonts/figtree-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }

/* Five palette colours: parchment, graphite pencil, batter gold, red pencil, sheet-pan aluminium. */
:root { --cream: #f4ead3; --crust: #2e2a27; --butter: #e3b04b; --berry: #9a2b2b; --steel: #5f656d; }
:root {
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --text: "Figtree", system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --graphite-soft: rgba(46, 42, 39, .55);
  --graphite-faint: rgba(46, 42, 39, .16);
  --counter: color-mix(in srgb, var(--cream) 84%, var(--steel));
  --fibre: repeating-linear-gradient(118deg, rgba(95, 101, 109, .045) 0 1px, transparent 1px 7px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--crust); font: 17px/1.6 var(--text);
  background-color: var(--counter);
  /* flour dust on the counter, decorative */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .55) 0 1.5px, transparent 2px),
    radial-gradient(circle at 72% 64%, rgba(255, 255, 255, .5) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 40% 82%, rgba(255, 255, 255, .45) 0 1px, transparent 1.6px),
    radial-gradient(circle at 88% 30%, rgba(255, 255, 255, .45) 0 1.4px, transparent 2px);
  background-size: 173px 151px, 211px 187px, 97px 131px, 263px 229px;
}
a { color: var(--berry); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-style: wavy; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--hand); font-weight: 700; line-height: 1.05; margin: 0; }
h2 { font-size: 2.3rem; }
h3 { font-size: 1.7rem; margin-top: 18px; }
p { margin: 0 0 12px; }

/* pencil glyphs of pan shapes before section heads */
.glyph { display: inline-block; width: 26px; height: 18px; margin-right: 10px; border: 2px solid currentColor; border-radius: 3px; vertical-align: 1px; opacity: .85; }
.g-square { width: 20px; height: 20px; }
.g-round { width: 22px; height: 22px; border-radius: 50%; vertical-align: -1px; }
.g-bundt { width: 23px; height: 23px; border-radius: 50%; border-style: dashed; vertical-align: -1px; background: radial-gradient(circle, currentColor 0 3px, transparent 3.5px); }

/* ---------- masthead: no band, art beside the title ---------- */
.masthead { max-width: 1240px; margin: 0 auto; padding: 16px 16px 6px; display: grid; grid-template-columns: 104px 1fr; gap: 12px; align-items: center; }
.head-art { width: 100%; height: auto; display: block; }
.mast-text h1 { font-size: clamp(2.4rem, 9vw, 4.4rem); letter-spacing: .5px; }
.mast-text p { margin: 4px 0 0; font-size: 1rem; max-width: 40em; }
.h-paper { fill: var(--cream); stroke: var(--graphite-faint); stroke-width: 1.5; }
.h-curl { fill: color-mix(in srgb, var(--cream) 80%, var(--steel)); stroke: var(--graphite-faint); stroke-width: 1.5; }
.h-fibre { stroke: rgba(95, 101, 109, .18); stroke-width: 1.5; fill: none; }
.h-cut { fill: none; stroke: var(--berry); stroke-width: 1.5; stroke-dasharray: 6 5; }
.h-wash { fill: rgba(227, 176, 75, .32); }
.h-line { fill: none; stroke: var(--crust); stroke-width: 1.5; }
.h-line2 { fill: none; stroke: var(--crust); stroke-width: 1; opacity: .45; }
.h-label { font: 700 24px var(--hand); fill: var(--crust); text-anchor: middle; }
.h-dim { stroke: var(--steel); stroke-width: 1.5; fill: none; }
.h-sc circle, .h-sc path { fill: none; stroke: var(--berry); stroke-width: 1.5; }
.h-body { fill: var(--butter); stroke: var(--crust); stroke-width: 1.5; }
.h-facet { stroke: rgba(46, 42, 39, .35); stroke-width: 1; }
.h-wood { fill: color-mix(in srgb, var(--cream) 70%, var(--butter)); stroke: var(--crust); stroke-width: 1.5; stroke-linejoin: round; }
.h-tip { fill: var(--crust); }
.h-ferrule { fill: color-mix(in srgb, var(--steel) 55%, var(--cream)); stroke: var(--crust); stroke-width: 1.5; }
.h-ferrule-l { stroke: var(--crust); stroke-width: 1; }
.h-eraser { fill: var(--berry); stroke: var(--crust); stroke-width: 1.5; }

/* ---------- the half-sheet pan and its parchment ---------- */
main { display: block; }
.sheetpan {
  max-width: 1240px; margin: 10px 8px 0; padding: 10px;
  border-radius: 22px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--steel) 55%, var(--cream)), var(--steel) 55%, color-mix(in srgb, var(--steel) 70%, var(--cream)));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .55),
    inset 0 -2px 0 rgba(0, 0, 0, .25),
    inset 0 0 0 5px rgba(255, 255, 255, .12),
    inset 0 0 0 7px rgba(0, 0, 0, .22),
    0 10px 24px rgba(46, 42, 39, .22);
}
.parchment {
  position: relative; border-radius: 6px 0 0 6px; padding: 16px 20px 20px 14px;
  background-color: var(--cream);
  background-image: var(--fibre), repeating-linear-gradient(28deg, rgba(255, 255, 255, .35) 0 1px, transparent 1px 11px);
  clip-path: polygon(0 0, calc(100% - 4px) 0.0%, calc(100% - 3px) 2.5%, calc(100% - 1px) 5.0%, calc(100% - 0px) 7.5%, calc(100% - 2px) 10.0%, calc(100% - 2px) 12.5%, calc(100% - 4px) 15.0%, calc(100% - 0px) 17.5%, calc(100% - 5px) 20.0%, calc(100% - 0px) 22.5%, calc(100% - 2px) 25.0%, calc(100% - 1px) 27.5%, calc(100% - 1px) 30.0%, calc(100% - 2px) 32.5%, calc(100% - 5px) 35.0%, calc(100% - 2px) 37.5%, calc(100% - 1px) 40.0%, calc(100% - 0px) 42.5%, calc(100% - 2px) 45.0%, calc(100% - 5px) 47.5%, calc(100% - 0px) 50.0%, calc(100% - 1px) 52.5%, calc(100% - 0px) 55.0%, calc(100% - 5px) 57.5%, calc(100% - 0px) 60.0%, calc(100% - 3px) 62.5%, calc(100% - 7px) 65.0%, calc(100% - 1px) 67.5%, calc(100% - 3px) 70.0%, calc(100% - 2px) 72.5%, calc(100% - 7px) 75.0%, calc(100% - 3px) 77.5%, calc(100% - 2px) 80.0%, calc(100% - 5px) 82.5%, calc(100% - 4px) 85.0%, calc(100% - 2px) 87.5%, calc(100% - 2px) 90.0%, calc(100% - 0px) 92.5%, calc(100% - 5px) 95.0%, calc(100% - 6px) 97.5%, calc(100% - 1px) 100.0%, 0 100%);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
  grid-template-areas: "answer" "notes" "more";
}
#results { display: contents; }
.answer { grid-area: answer; min-width: 0; }
.notes { grid-area: notes; min-width: 0; margin: 0; }
.more { grid-area: more; min-width: 0; }

/* ---------- inputs as pencil notes in the margin ---------- */
fieldset { border: 0; margin: 0 0 6px; padding: 6px 0 8px; min-width: 0; }
fieldset + fieldset { position: relative; padding-top: 20px; }
fieldset + fieldset::before { position: absolute; left: 0; right: 0; top: -2px; }
legend { font: 700 1.9rem/1.1 var(--hand); padding: 0; margin-bottom: 2px; }
label.f { display: block; font-weight: 600; margin: 10px 0 3px; font-size: .9rem; letter-spacing: .01em; }
.row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.row > div { flex: 1 1 120px; min-width: 0; }
.row > div[hidden] { display: none; }
select, input {
  width: 100%; min-height: 48px; font: 700 1.6rem/1 var(--hand); color: var(--crust);
  background: rgba(255, 255, 255, .4); border: 0; border-bottom: 2px solid var(--crust);
  border-radius: 4px 4px 0 0; padding: 6px 10px 2px;
}
input::placeholder { color: var(--steel); opacity: 1; font-size: 1.3rem; font-weight: 400; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--crust) 50%), linear-gradient(135deg, var(--crust) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  background-color: rgba(255, 255, 255, .4);
}
input:focus, select:focus { background-color: rgba(255, 255, 255, .7); border-bottom-color: var(--berry); }
.err { color: var(--berry); font-weight: 600; border: 2px dashed var(--berry); border-radius: 8px; padding: 8px 12px; margin-top: 10px; }

/* ---------- the answer: tracings, circled factor, sentence ---------- */
.answer h2 { font-size: 2rem; }
.tracing { margin: 4px 0 0; transition: opacity .2s; }
.tracing.stale { opacity: .35; }
.plan, .sectsvg { width: 100%; height: auto; display: block; overflow: visible; }
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; margin: 4px 0 10px; }
.verdict .big { flex: 1 1 16em; }
.factor {
  position: relative; flex: none; margin: 0 0 0 6px; padding: 6px 22px 2px; min-width: 7.5rem; text-align: center;
  font: 700 3.4rem/1.05 var(--hand); color: var(--crust); background: var(--butter); white-space: nowrap;
  border: 2px solid var(--crust); border-radius: 52% 48% 55% 45% / 58% 52% 48% 42%; transform: rotate(-3deg);
}
.factor::after { content: ""; position: absolute; inset: -6px -3px -3px -7px; border: 1.5px solid var(--graphite-soft); border-radius: 46% 54% 44% 56% / 50% 60% 40% 50%; transform: rotate(4deg); pointer-events: none; }
.big { margin: 0; font-size: 1.2rem; font-weight: 600; line-height: 1.45; }

/* drawing classes (the SVG is built by draw.js) */
.pencil { fill: none; stroke: var(--crust); stroke-width: 2; stroke-linejoin: round; }
.pencil.thin { stroke-width: 1.2; opacity: .7; }
.pencil2 { fill: none; stroke: var(--crust); stroke-width: 1; opacity: .4; }
.wash { fill: rgba(227, 176, 75, .3); }
.cut { fill: none; stroke: var(--berry); stroke-width: 1.5; stroke-dasharray: 7 6; }
.scissors circle, .scissors path { fill: var(--cream); stroke: var(--berry); stroke-width: 1.5; }
.dim { fill: none; stroke: var(--steel); stroke-width: 1.5; }
.arrow { fill: none; stroke: var(--crust); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hand-l, .hand-m, .hand-s { font-family: var(--hand); font-weight: 700; fill: var(--crust); }
.hand-l { font-size: 27px; }
.hand-m { font-size: 25px; }
.hand-s { font-size: 21px; }
.mid { text-anchor: middle; }
.end { text-anchor: end; }
.start { text-anchor: start; }
.red { fill: var(--berry); }
.ink { paint-order: stroke; stroke: rgba(244, 234, 211, .8); stroke-width: 4px; }
.counter { stroke: var(--graphite-soft); stroke-width: 1.5; stroke-dasharray: 2 5; }
.band { fill: rgba(95, 101, 109, .14); }
.batter { fill: var(--butter); opacity: .85; }
.pan { fill: none; stroke: var(--steel); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.rim { fill: var(--cream); stroke: var(--steel); stroke-width: 2.5; }
.tube { fill: var(--cream); stroke: var(--steel); stroke-width: 2.5; }
.unscaled { stroke: var(--berry); stroke-width: 2.5; stroke-dasharray: 8 6; }
.drip { fill: var(--butter); stroke: var(--berry); stroke-width: 1.5; }

/* ---------- the rest of the result: pencilled notes ---------- */
.sectionfig { margin: 10px 0 6px; padding-top: 14px; position: relative; }
.sectionfig::before { position: absolute; left: 0; right: 0; top: -6px; }
.sectionfig figcaption { font-size: .88rem; max-width: 46em; margin-bottom: 4px; }
.facts { margin: 8px 0 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 28px; }
.facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0 4px; border-bottom: 1.5px solid var(--graphite-faint); }
.facts dt { font-weight: 600; font-size: .92rem; }
.facts dd { margin: 0; text-align: right; font: 700 1.5rem/1.15 var(--hand); }
.warn { color: var(--berry); font-weight: 600; padding: 8px 12px 8px 40px; position: relative; border: 2px solid var(--berry); border-radius: 16px 10px 18px 8px; }
.warn::before { content: "!"; position: absolute; left: 14px; top: 1px; font: 700 1.8rem/1.2 var(--hand); }
.timebox { border-left: 4px solid var(--butter); padding: 2px 0 2px 14px; margin: 12px 0; }
.timebox p { margin: 0 0 4px; }
#time-range { font: 700 1.6rem/1.2 var(--hand); }
#time-range:empty { display: none; }
#assumptions { margin: 6px 0 14px; padding-left: 1.2em; }
#assumptions li { margin-bottom: 4px; }
.note { font-size: .93rem; }
.note.warn { color: var(--crust); font-weight: 400; border: 2px dashed var(--graphite-soft); border-radius: 10px; }
.note.warn::before { color: var(--berry); }

/* ---------- the swap table on a parchment liner strip ---------- */
#swaps {
  max-width: 1040px; margin: 30px 8px 0; padding: 20px 18px 14px;
  background: var(--cream) var(--fibre);
  border-radius: 4px; box-shadow: 0 2px 0 rgba(46, 42, 39, .12), 0 8px 18px rgba(46, 42, 39, .12);
}
#swaps > p { max-width: 52em; }
.tbl { overflow-x: auto; margin: 6px 0 12px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 560px; }
th { text-align: left; font: 700 1.35rem/1.1 var(--hand); padding: 6px 8px; border-bottom: 2px dashed var(--berry); }
td { padding: 9px 8px; border-bottom: 1.5px solid var(--graphite-faint); vertical-align: top; }
td:nth-child(3), td:nth-child(4) { font: 700 1.3rem/1 var(--hand); }
tbody tr:hover { background: rgba(227, 176, 75, .18); }

/* ---------- the bench: three parchment scraps on the counter ---------- */
.bench { max-width: 1240px; margin: 30px auto 0; padding: 0 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.scrap {
  background: var(--cream) var(--fibre); padding: 20px 20px 10px; border-radius: 3px; margin: 0;
  box-shadow: 0 2px 0 rgba(46, 42, 39, .1), 0 6px 14px rgba(46, 42, 39, .1);
}
.scrap h2 { margin-bottom: 10px; font-size: 2.1rem; }
.scrap h2::after { display: block; margin-top: 2px; }
/* hand-drawn wavy pencil rule: a run of spaces with a wavy underline */
fieldset + fieldset::before, .sectionfig::before, .scrap h2::after {
  content: "\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0\a0";
  font: 400 26px/14px var(--text); letter-spacing: 60px; height: 18px; overflow: hidden; white-space: nowrap;
  text-decoration: underline wavy rgba(46, 42, 39, .5) 1.5px; text-underline-offset: 1px; pointer-events: none;
}
details { padding: 6px 0 4px; border-bottom: 1.5px solid var(--graphite-faint); }
details:last-of-type { border-bottom: 0; }
summary { min-height: 44px; font-weight: 600; cursor: pointer; display: flex; align-items: center; list-style: none; line-height: 1.35; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "Q"; flex: none; width: 1.4em; color: var(--berry); font: 700 1.5rem/1 var(--hand); }
details p { margin: 2px 0 8px 1.75em; }

/* ---------- shop guide and footer ---------- */
.shopstrip { max-width: 1240px; margin: 30px auto 0; padding: 18px 20px 10px; background: var(--cream) var(--fibre); border-top: 4px solid var(--steel); }
.shopstrip > .disc { margin-bottom: 0; }
main .shop-guide { margin: 14px 0 6px; padding-top: 14px; border-top: 1.5px solid var(--graphite-faint); }
main .shop-guide h2 { font-size: 2.1rem; margin-bottom: 8px; }
main .shop-guide p { max-width: 62em; }
main .shop-guide a { color: var(--berry); }
footer { background: var(--crust); color: var(--cream); }
footer p { max-width: 1240px; margin: 0 auto; padding: 18px 20px 28px; font-size: .95rem; }
footer a { color: var(--butter); }

/* ---------- wider screens ---------- */
@media (min-width: 620px) {
  .masthead { grid-template-columns: 180px 1fr; gap: 22px; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .facts .wide { grid-column: 1 / -1; }
  #swaps { margin: 30px auto 0; padding: 22px 30px 16px; }
}
@media (min-width: 960px) {
  .masthead { padding-top: 24px; }
  .sheetpan { margin: 10px 20px 0; padding: 14px; border-radius: 26px; }
  .parchment { grid-template-columns: 360px minmax(0, 1fr); grid-template-areas: "notes answer" "notes more"; gap: 0 34px; padding: 26px 36px 26px 26px; }
  .notes { padding-right: 26px; border-right: 1.5px dashed var(--graphite-faint); align-self: start; }
  .bench { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; padding: 0 20px; }
  .shopstrip { padding: 22px 34px 12px; }
}
@media (min-width: 1280px) { .sheetpan { margin: 10px auto 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
