/* ---------- colours and fonts ---------- */
:root {
  color-scheme: light dark;
  --paper:   light-dark(#f5f0e3, #1b1a17);
  --paper-2: light-dark(#ece5d4, #262420);
  --ink:     light-dark(#1f1c16, #f5f0e3);
  --soft:    light-dark(#5a523f, #cfc7b4);
  --accent:  light-dark(#a8301a, #ff9e85);
  --line:    light-dark(#7a7260, #8f897a);
  --grid:    light-dark(#cfc6ad, #33312c);
  --sun:     light-dark(#e8a33d, #f2d49a);
  --band-1:  light-dark(#cfc3a8, #2c3140);
  --band-2:  light-dark(#b0a888, #363c48);
  --band-3:  light-dark(#8e9a6e, #36443a);
  --band-4:  light-dark(#6c7a52, #2a3730);
  --road-fill: light-dark(#efe6cf, #55503f);
  --leaf:    light-dark(#46543a, #1f2a22);
  --trunk:   light-dark(#3b3526, #15140f);
  --moon:    light-dark(#f0ddb4, #e7dcc0);
  --rb-1: #b3472c; --rb-2: #d08a2e; --rb-3: #bda53a;
  --rb-4: #6f8b4a; --rb-5: #3f7a8c; --rb-6: #5f5a94;
  --note-1:  light-dark(#f7dc8e, #d8bb70);
  --note-2:  light-dark(#f3b8b0, #d9a49c);
  --note-3:  light-dark(#bfe0a8, #a8c893);
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --body: Georgia, "Times New Roman", serif;
  --round: 14px 5px 16px 6px / 6px 16px 5px 14px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }
:root[data-text="large"]  { font-size: 112.5%; }
:root[data-text="larger"] { font-size: 125%; }
:root[data-font="plain"] { --hand: system-ui, sans-serif; --body: system-ui, sans-serif; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background-color: var(--paper); color: var(--ink); font: 1rem/1.6 var(--body); }
html:not([data-grid="off"]) body {
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.5rem 1.5rem;
}
html:not([data-grid="off"]) body.again {
  background-image: radial-gradient(var(--grid) 1.5px, transparent 1.6px);
  background-size: 1.25rem 1.25rem;
}
html { scroll-padding-top: 6rem; }
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem; }
.wide { max-width: 62rem; }
p, li, blockquote, dd, figcaption { max-width: 65ch; overflow-wrap: break-word; }
h1, h2, h3 { font-family: var(--hand); font-weight: 700; line-height: 1.05; margin: 0 0 .5rem; }
h1 { font-size: clamp(2.5rem, 10vw, 6rem); }
h2 { font-size: clamp(2rem, 7vw, 2.75rem); }
h3 { font-size: clamp(1.5rem, 5vw, 2rem); }
.soft, small, figcaption { color: var(--soft); }
a { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
.skip { position: absolute; left: -100vw; top: 0; padding: .75rem 1rem; background: var(--ink); color: var(--paper); }
.skip:focus { left: 1rem; top: 1rem; z-index: 20; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- header ---------- */
header { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 2px solid var(--ink); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem; padding-block: .25rem; }
.logo { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.5rem; margin-right: auto; color: var(--ink); text-decoration: none; font: 700 1.4rem/1 var(--hand); }
.logo svg { width: 1.7rem; height: 1.7rem; flex: none; fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
nav ul { display: flex; flex-wrap: wrap; gap: 0 1.1rem; list-style: none; margin: 0; padding: 0; }
nav a { display: inline-flex; align-items: center; min-height: 2.5rem; font: 700 1.15rem var(--hand); color: var(--ink); text-decoration: none; border-bottom: 3px solid transparent; }
nav a:hover { border-bottom-color: var(--line); }
nav a[aria-current] { border-bottom-color: var(--accent); }
nav a[aria-current]::before { content: "\2022\00a0"; color: var(--accent); }

/* ---------- one button shape for everything ---------- */
.btn, .pill {
  font-family: var(--hand); font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block;
  color: var(--ink); background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--round);
}
.btn { font-size: 1.3rem; min-height: 3rem; padding: .6rem 1.3rem; box-shadow: 4px 4px 0 var(--ink); }
.pill { font-size: 1.05rem; min-height: 2.5rem; padding: .35rem .8rem; }
.btn:hover, .pill:hover, .pill[aria-pressed="true"], .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.pill[aria-pressed="true"]::before { content: "\2713\00a0"; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

/* ---------- display panel ---------- */
.panel { background: var(--paper-2); border-bottom: 2px solid var(--ink); }
.panel .wrap { display: grid; gap: .75rem 1.5rem; padding-block: 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.panel fieldset { margin: 0; padding: 0; border: 0; }
.panel legend { padding: 0 0 .35rem; font-weight: bold; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; display: grid; align-content: start; background: var(--paper); text-align: center; min-height: 100svh; padding: clamp(1.5rem, 7vh, 6rem) 0 3rem; }
.hero > .wrap { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 1rem; }
.tag { font: 700 clamp(1.3rem, 5vw, 2.1rem)/1.15 var(--hand); margin: 0 auto 1.25rem; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.sun { fill: var(--sun); }
.moon { fill: var(--moon); }
.sunray { fill: none; stroke: var(--sun); stroke-width: 3.5; stroke-linecap: round; }
.r1 { stroke: var(--rb-1); } .r2 { stroke: var(--rb-2); } .r3 { stroke: var(--rb-3); }
.r4 { stroke: var(--rb-4); } .r5 { stroke: var(--rb-5); } .r6 { stroke: var(--rb-6); }
.b1 { fill: var(--band-1); } .b2 { fill: var(--band-2); } .b3 { fill: var(--band-3); } .b4 { fill: var(--band-4); }
.road-fill { fill: var(--road-fill); }
.leaf { fill: var(--leaf); } .trunk { fill: var(--trunk); }
.pupil { fill: var(--ink); }
.glint { fill: var(--paper); }
.horizon { fill: none; stroke: var(--ink); stroke-width: 2; opacity: .55; }
.rays { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 7 9; opacity: .4; }
.stroke { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.hatch { fill: none; stroke: var(--soft); stroke-width: 1.5; stroke-linecap: round; }

/* ---------- sections ---------- */
section { padding: 2.5rem 0; }
.entry { background: var(--paper-2); border: 2px solid var(--ink); border-left: 8px double var(--accent); border-radius: var(--round); padding: 1rem 1.5rem 1.5rem; margin-top: 2.5rem; }
.entry .word { font: 700 clamp(2.25rem, 10vw, 3.25rem)/1 var(--hand); margin: 0; }
.entry p, .entry dd { font-size: 1.125rem; }
.entry .word + .soft { margin: .35rem 0 0; font-size: 1rem; }
.senses { display: grid; gap: 1.25rem 2.5rem; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px dashed var(--line); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.senses dt { margin: 0 0 .35rem; }
figure { margin: 1rem 0; }
figure svg, .beat > svg { display: block; width: 100%; max-width: 28rem; height: auto; margin-inline: auto; }
figcaption { font-size: .95rem; margin-top: .5rem; }
.draw { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.guide { fill: none; stroke: var(--soft); stroke-width: 1.25; stroke-dasharray: 5 5; }
.dot { fill: var(--accent); stroke: var(--paper); stroke-width: 1.5; }
.ctl { display: block; max-width: 28rem; margin: 1rem auto 0; font-weight: bold; }
.ctl small { display: block; font-weight: normal; }
.ctl input { display: block; width: 100%; min-height: 2.75rem; accent-color: var(--accent); }
.beat { display: grid; gap: 1.25rem 3rem; align-items: center; padding: 2.5rem 0; border-top: 1px dashed var(--line); }
.beat:first-of-type { border-top: 0; }
dl { margin: 0; }
dt { font: 700 1.6rem/1.1 var(--hand); margin-top: 1.25rem; color: var(--accent); }
dd { margin: 0; }
.art { max-width: 24rem; margin: 0 auto; }
.art.wide-art { max-width: 28rem; }
.art img { display: block; width: 100%; height: auto; background: var(--paper-2); border: 2px solid var(--ink); }
.art figcaption { margin-top: .5rem; }
.closing { background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--round); padding: 1.25rem 1.5rem; }
.closing p:last-child { margin-bottom: 0; }
.turn { text-align: center; padding: 4rem 0; }
.turn h2 { font-size: clamp(2.25rem, 10vw, 4rem); }
.back { text-align: center; padding: 3rem 0 4rem; }
footer { border-top: 2px solid var(--ink); padding: 1.5rem 0 2.5rem; }

/* ---------- sticky notes ---------- */
.notes { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); list-style: none; margin: 1.5rem 0 0; padding: 0; }
.note { display: flex; flex-direction: column; gap: .5rem; min-height: 11rem; margin: 0; padding: 1rem; color: #231f18; background: var(--note-1); border-radius: 2px 2px 16px 2px; box-shadow: 3px 3px 0 rgb(0 0 0 / .25); }
.note:nth-child(3n+2) { background: var(--note-2); rotate: -1.5deg; }
.note:nth-child(3n) { background: var(--note-3); rotate: 1.5deg; }
.note p { margin: 0; max-width: none; font: 1.1rem/1.4 var(--hand); word-break: break-word; }
.note .who { margin-top: auto; font: 1rem var(--body); }
.note .who::before { content: "\2014\00a0"; }
.note button { align-self: flex-end; min-height: 2.5rem; padding: .25rem .7rem; font: 1rem var(--body); color: #231f18; background: transparent; border: 2px solid #231f18; border-radius: var(--round); cursor: pointer; }
.note button:hover { background: #231f18; color: #f5f0e3; }
.board .notes:empty { display: none; }
.post-form { max-width: 34rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px dashed var(--line); }
.post-form label { display: block; font-weight: bold; margin-bottom: .35rem; }
.post-form textarea { display: block; width: 100%; min-height: 5.5rem; padding: .6rem; font: 1rem/1.5 var(--body); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; resize: vertical; }
.err { color: var(--accent); font-weight: bold; min-height: 1.5em; margin: .35rem 0 .75rem; }
.err:not(:empty)::before { content: "\26A0\00a0"; }

/* ---------- small drawings ---------- */
.vp { display: block; width: min(11rem, 70%); aspect-ratio: 1; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 .4rem, transparent .45rem), repeating-radial-gradient(circle, transparent 0 .5rem, var(--line) .5rem .56rem); }
.card { position: relative; display: grid; place-items: center; width: min(11rem, 60%); aspect-ratio: 5/7; margin: 0 auto; background: var(--paper-2); border: 3px solid var(--ink); border-radius: .9rem; box-shadow: 6px 6px 0 var(--ink); }
.card .big { font: 700 6.5rem/1 var(--hand); }
.card .ci { position: absolute; top: .4rem; left: .7rem; font: 700 1.5rem/1 var(--hand); }
.card .ci + .ci { top: auto; left: auto; bottom: .4rem; right: .7rem; rotate: 180deg; }
.card.turned { rotate: 180deg; }
.night { display: none; }
.is-night .night { display: block; }
.is-night .day { display: none; }
.arc { fill: none; stroke-width: 11; stroke-linecap: butt; opacity: 0; }
.rain { stroke: var(--rb-5); stroke-width: 3; stroke-linecap: round; }
.sun-only { display: none; }
.sunny .arc { opacity: 1; }
.sunny .rain, .sunny .cloud { display: none; }
.sunny .sun-only { display: block; }
.msg { min-height: 3em; font-weight: bold; }

/* ---------- process page ---------- */
.mood, .swatches { display: grid; gap: 1.25rem; list-style: none; padding: 0; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.mood figure { margin: 0; background: var(--paper-2); border: 2px solid var(--ink); padding: .5rem .5rem .25rem; }
.mood picture { display: block; }
.mood img { display: block; width: 100%; height: auto; background: var(--paper); }
.mood figcaption { margin-top: .5rem; font-size: .9rem; }
.swatch span { display: block; height: 3rem; border: 2px solid var(--ink); margin-bottom: .25rem; }
.swatch p { margin: 0 0 .5rem; max-width: none; font-size: .9rem; }

/* ---------- narrow screens: the nav scrolls sideways ---------- */
@media (max-width: 47.99rem) {
  nav { order: 3; flex-basis: 100%; }
  nav ul { flex-wrap: nowrap; overflow-x: auto; gap: 0 1rem; padding-bottom: .2rem; }
  nav li { flex: none; }
  .wrap { padding: 0 1rem; }
}

/* ---------- narrow, upright screens: a smaller scene, so trees and moon stay in the picture ---------- */
@media (max-width: 47.99rem) {
  nav { min-width: 0; }
}
@media (max-width: 47.99rem) and (min-height: 40rem) and (orientation: portrait) {
  .hero { min-height: calc(100svh - 5.5rem); }
  .scene { inset: auto 0 0; height: 60%; }
}

/* ---------- bigger screens ---------- */
@media (min-width: 48rem) {
  .logo { order: -1; }
  nav { order: 0; }
  .disc { order: 1; }
  .beat { grid-template-columns: 1fr 1fr; }
  .beat:nth-of-type(even) > :first-child { order: 2; }
}

/* ---------- short or zoomed-in windows: let the header scroll away ---------- */
@media (max-height: 30rem) {
  header { position: static; }
  .hero { min-height: 0; padding-bottom: 2rem; }
}

/* ---------- user preferences ---------- */
html[data-motion="off"] *, html[data-motion="off"] *::before {
  animation: none !important; transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) *, html:not([data-motion="full"]) *::before {
    animation: none !important; transition: none !important;
  }
}
main > article:not([hidden]) { animation: fade .5s ease-out; }
.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.2s ease-out .2s forwards; }
.btn, .pill { transition: background .15s, color .15s; }
.card { transition: rotate .9s ease-out; }
.arc { transition: opacity 1s; }
html.js .reveal { opacity: 0; transition: opacity .6s; }
html.js .reveal.in { opacity: 1; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-contrast: more) {
  :root { --soft: var(--ink); --line: var(--ink); --grid: transparent; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --grid: transparent; }
  .note { box-shadow: none; border: 2px solid #231f18; }
}
@media (forced-colors: active) {
  .btn, .pill, .note, .note button { border: 2px solid ButtonBorder; box-shadow: none; }
  .btn:hover, .pill[aria-pressed="true"] { background: Highlight; color: HighlightText; }
  .note { background: Canvas; color: CanvasText; }
  .scene, .vp { forced-color-adjust: none; }
}
@media (pointer: coarse) {
  nav a, .pill { min-height: 2.75rem; }
}
@media print {
  header, .panel, .scene, .btn, .ctl, .post-form { display: none !important; }
  [hidden] { display: revert !important; }
  body { background: #fff; color: #000; }
  .hero { min-height: 0; }
}
