/* Winter Post. One card of the same rag paper on a slightly darker sheet, the studio table. The paint
   and the pen line are on the front; the back is printed in the pen's ink, written in a blue-black
   hand, and cancelled in red. Controls are drawn in ink, as on the studio page. */

@font-face { font-family: "Shantell Sans"; src: url("fonts/shantell-sans-full.woff2") format("woff2-variations"), url("fonts/shantell-sans-full.woff2") format("woff2"); font-weight: 300 800; font-display: swap; }
@font-face { font-family: "Nothing You Could Do"; src: url("fonts/nothing-you-could-do.woff2") format("woff2"); font-display: swap; }

:root {
  --table: #e8e2d5;      /* the table the card lies on: the same paper, in shade */
  --table-2: #ddd5c5;
  --ink: #171513;
  --ink-2: #4a4540;
  --ink-3: #6b645c;
  --stock: #f3f0e8;      /* the card, as the paper model reflects it */
  --print: #171513;      /* the back is printed in the pen's ink */
  --print-soft: #17151366;
  --pen: #1c2552;        /* a blue-black pen */
  --cancel: #b0262d;     /* the postmark: scarlet ink */
  --hand: "Shantell Sans", "Comic Neue", "Segoe Print", system-ui, sans-serif;
  --script: "Nothing You Could Do", "Segoe Print", "Bradley Hand", cursive;
  --plain: "INFM" 0, "BNCE" 0, "SPAC" 0;
  --loose: "INFM" 60, "BNCE" 30, "SPAC" 0;
  --wild: "INFM" 100, "BNCE" 60, "SPAC" 0;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --flip: 1100ms;
  --pad: clamp(1rem, 2.4vw, 2.25rem);
  --card-w: min(900px, calc(100vw - 2rem));
  --card-h: calc(var(--card-w) / 1.5);
  color-scheme: light;
  scrollbar-color: var(--ink) var(--table-2);
}

* { box-sizing: border-box; }
html { background: var(--table); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: var(--ink);
  background: var(--table);
  font: 400 1rem/1.5 var(--hand);
  font-variation-settings: var(--plain);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: rgb(247 214 62 / 45%); color: var(--ink); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--table-2); }
::-webkit-scrollbar-thumb { background: var(--ink); border: 2px solid var(--table-2); border-radius: 8px 5px 9px 6px; }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 3px; border-radius: 10px 7px 11px 8px; }
.defs { position: absolute; width: 0; height: 0; }
@keyframes boil { 0% { filter: url(#ink-0); } 33% { filter: url(#ink-1); } 66% { filter: url(#ink-2); } }
a { color: inherit; text-underline-offset: 0.24em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* The top: a studio mark and one line. ------------------------------------------------------- */
.top {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto minmax(10rem, 1fr);
  align-items: start;
  gap: 1rem;
  padding: clamp(0.9rem, 2.2vh, 1.6rem) var(--pad) 0;
}
.studio { text-decoration: none; color: var(--ink); display: grid; justify-items: start; width: fit-content; }
.studio .wordmark { width: 8.6rem; height: auto; display: block; overflow: visible; margin-left: -0.3rem; }
.studio-note { order: 2; margin: -0.35rem 0 0 0.3rem; font: 400 1.15rem/1 var(--script); rotate: -3deg; }
.studio:hover .wordmark { rotate: -2deg; transition: rotate 380ms var(--spring); }
.say { text-align: center; max-width: 42rem; }
.say h1 { margin: 0; font: 800 clamp(1.9rem, 4vh + 0.6rem, 3.1rem)/1 var(--hand); font-variation-settings: var(--wild); letter-spacing: -0.02em; text-wrap: balance; }
.say p { margin: 0.45rem auto 0; max-width: 36rem; color: var(--ink-2); font-size: 0.98rem; line-height: 1.45; text-wrap: balance; }
.say.is-change { animation: say 700ms var(--ease); }
@keyframes say { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }

/* The desk and the card. --------------------------------------------------------------------- */
.desk { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: clamp(0.8rem, 2vh, 1.4rem) var(--pad) 0.6rem; gap: clamp(0.8rem, 2vh, 1.3rem); }
.card-room { position: relative; width: var(--card-w); height: var(--card-h); max-width: 100%; perspective: 2400px; flex: none; }
.card { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform var(--flip) cubic-bezier(0.6, 0.02, 0.18, 1); }
.card.is-flipped { transform: rotateY(180deg); }
.card.is-lifting { animation: lift var(--flip) cubic-bezier(0.45, 0, 0.2, 1); }
@keyframes lift { 45% { translate: 0 -2.5%; scale: 1.035; } }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; filter: drop-shadow(0 1px 1px rgb(70 50 25 / 22%)) drop-shadow(0 16px 24px rgb(70 50 25 / 20%)); }
.back { transform: rotateY(180deg); }
.leaf { position: absolute; inset: 0; background: var(--stock); -webkit-mask: var(--deckle) center / 100% 100% no-repeat; mask: var(--deckle) center / 100% 100% no-repeat; overflow: hidden; }
.back .leaf { -webkit-mask-image: var(--deckle-back); mask-image: var(--deckle-back); background: var(--stock) var(--paper-back, none) center / 100% 100% no-repeat; }

#paper { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: none; outline: none; }
body.is-replay #paper, body.is-reading #paper { cursor: default; }
.front:has(#paper:focus-visible) { outline: 2.5px solid var(--ink); outline-offset: 6px; }
.brush { position: absolute; top: 0; left: 0; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 1.5px solid var(--ink); opacity: 0; pointer-events: none; transition: opacity 260ms; }
.brush::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--brush, var(--ink)); }
.brush.is-on { opacity: 0.85; }
.brush.is-ghost { border-style: solid; border-width: 1px; opacity: 0.7; transition: opacity 400ms; }
.fail { position: absolute; inset: auto 1rem 1rem; padding: 1rem 1.1rem; background: var(--stock); color: var(--ink); font-size: 0.92rem; line-height: 1.4; border: 2px solid var(--ink); border-radius: 16px 11px 18px 10px / 11px 17px 10px 15px; }
.fail b { display: block; font: 800 1.35rem/1.05 var(--hand); font-variation-settings: var(--wild); margin-bottom: 0.4rem; }
.fail p { margin: 0; color: var(--ink-2); }

/* The back of the card. Everything is sized from the card's own width (--u = 1% of it). ------- */
.back .leaf { --u: calc(var(--card-w, 900px) / 100); color: var(--print); font-family: var(--hand); display: grid; }
.is-portrait .back .leaf { --u: calc(var(--card-w, 400px) / 66.7); }
.printed { font-family: var(--hand); text-transform: uppercase; color: var(--print); margin: 0; }
.head { position: absolute; left: 0; right: 0; top: calc(var(--u) * 3.1); text-align: center; font-weight: 800; font-variation-settings: var(--wild); font-size: calc(var(--u) * 3.6); letter-spacing: 0.32em; padding-left: 0.32em; line-height: 1; }
.printed.small { font: 650 calc(var(--u) * 1.3)/1 var(--hand); letter-spacing: 0.14em; flex: none; }

.message { position: absolute; left: 6.5%; top: 17%; width: 40%; bottom: 9%; display: flex; flex-direction: column; }
.divider { position: absolute; left: 51.2%; top: 17%; bottom: 9%; width: 0; border-left: 1px solid var(--print-soft); }
.divider span { position: absolute; left: calc(var(--u) * -0.9); top: 50%; translate: -50% -50%; rotate: -90deg; white-space: nowrap; background: var(--stock); padding: 0 0.9em; font: 500 calc(var(--u) * 1.05)/1 var(--hand); letter-spacing: 0.02em; color: var(--print); }
.address { position: absolute; left: 56%; right: 6%; top: 14.5%; bottom: 9%; display: flex; flex-direction: column; justify-content: flex-end; gap: calc(var(--u) * 4.4); }
.stamp-box { position: absolute; top: 0; right: 0; width: calc(var(--u) * 13); aspect-ratio: 220 / 264; }
.stamp { position: absolute; inset: 0; width: 100%; height: 100%; rotate: 1.4deg; filter: drop-shadow(0 1px 0.5px rgb(30 30 30 / 25%)) drop-shadow(0 3px 5px rgb(30 30 30 / 12%)); }
.postmark { position: absolute; width: 210%; top: 26%; right: 36%; mix-blend-mode: multiply; opacity: 0; transition: opacity 120ms; pointer-events: none; }
.postmark.is-on { opacity: 0.92; }
.postmark.is-stamping { animation: thump 520ms cubic-bezier(0.2, 0.9, 0.2, 1); }
@keyframes thump { 0% { opacity: 0; scale: 1.12; filter: blur(2px); } 35% { opacity: 1; scale: 0.985; filter: blur(0); } }

.to-line, .sign { display: flex; align-items: baseline; gap: calc(var(--u) * 1.4); margin: 0; border-bottom: 1px solid var(--print-soft); padding-bottom: calc(var(--u) * 0.6); }
.rule { margin: 0; border-bottom: 1px solid var(--print-soft); height: 0; }
.sign { margin-top: auto; border-bottom: 0; }
.back input, .back textarea {
  font: 400 calc(var(--u) * 2.75)/1.32 var(--script);
  color: var(--pen);
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  min-width: 0;
  caret-color: var(--cancel);
  outline: none;
  border-radius: 2px;
}
.back textarea { flex: 1; resize: none; overflow: hidden; line-height: 1.42; font-size: calc(var(--u) * 2.75); padding-top: calc(var(--u) * 0.6); }
.back input::placeholder, .back textarea::placeholder { color: rgb(28 37 82 / 34%); }
.back input:focus-visible, .back textarea:focus-visible { outline: 1px dashed rgb(28 37 82 / 28%); outline-offset: calc(var(--u) * 0.5); }
.hand-read { display: none; font: 400 calc(var(--u) * 2.75)/1.42 var(--script); color: var(--pen); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.message .hand-read { padding-top: calc(var(--u) * 0.6); }
.is-reading .back input, .is-reading .back textarea { display: none; }
.is-reading .back .hand-read { display: block; }
.is-reading .back .sign .hand-read, .is-reading .back .to-line .hand-read { display: inline; }
.count { position: absolute; left: 6.5%; bottom: 3.2%; margin: 0; font: 600 calc(var(--u) * 1.15)/1 var(--hand); letter-spacing: 0.04em; color: var(--print); opacity: 0.75; }
.is-reading .count { display: none; }

/* A tall card writes top to bottom: message above, address below. */
.is-portrait .head { top: 3.2%; font-size: calc(var(--u) * 4.4); }
.is-portrait .message { left: 8%; right: 8%; width: auto; top: 11%; bottom: 49%; }
.is-portrait .divider { left: 8%; right: 8%; top: 53%; bottom: auto; width: auto; height: 0; border-left: 0; border-top: 1px solid var(--print-soft); }
.is-portrait .divider span { left: 50%; top: 0; rotate: 0deg; }
.is-portrait .address { left: 8%; right: 8%; top: 58%; bottom: 7%; }
.is-portrait .stamp-box { width: calc(var(--u) * 15); }
.is-portrait .count { left: 8%; bottom: 2.6%; }

/* The tray: what to paint on, the paint box, the brush, and the moves. -------------------- */
.tray { width: max(var(--card-w, 900px), min(52rem, calc(100vw - 2 * var(--pad)))); max-width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "drawings actions" "pans modes" "note note"; align-items: center; gap: 0.2rem 1rem; }
.tray.back-tray, .tray.recv-tray { grid-template-columns: 1fr; grid-template-areas: "actions" "facts"; justify-items: center; }
.drawings { grid-area: drawings; display: flex; align-items: center; gap: 0.1rem; justify-content: flex-start; }
.drawings-label { font: 400 1.2rem/1 var(--script); margin-right: 0.3rem; rotate: -3deg; }
.dw { position: relative; display: grid; justify-items: center; width: 3.9rem; padding: 0.3rem 0.1rem 0.25rem; cursor: pointer; border-radius: 12px; -webkit-tap-highlight-color: transparent; }
.dw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.dw .thumb { width: 2.9rem; height: 2.3rem; overflow: visible; transition: transform 420ms var(--spring); }
.dw .thumb path { fill: none; stroke: var(--ink); stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.dw .blank { fill: none; stroke: var(--ink-3); stroke-width: 1.3px; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.dw span { font: 520 0.7rem/1 var(--hand); color: var(--ink-2); }
.dw .loop { position: absolute; inset: 0 -0.1rem 0.85rem; width: calc(100% + 0.2rem); height: calc(100% - 0.8rem); overflow: visible; pointer-events: none; }
.dw .loop path { fill: none; stroke: var(--ink); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 520ms var(--ease); }
.dw:hover .thumb { transform: rotate(-5deg) translateY(-2px) scale(1.05); }
.dw:has(input:checked) .loop path { stroke-dashoffset: 0; }
.dw:has(input:checked) span { color: var(--ink); font-weight: 700; }
.dw:has(input:focus-visible) { outline: 2.5px solid var(--ink); }
.dw:has(input:disabled) { opacity: 0.4; cursor: default; }
.pans { grid-area: pans; display: flex; gap: clamp(0.1rem, 0.6vw, 0.4rem); }
.pan { position: relative; display: grid; justify-items: center; gap: 0.15rem; width: 4rem; cursor: pointer; padding: 0.3rem 0 0.25rem; border-radius: 12px; -webkit-tap-highlight-color: transparent; }
.pan input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pan canvas { display: block; width: 2.5rem; height: 2.5rem; transition: transform 420ms var(--spring); }
.pan .well { position: absolute; top: 0.02rem; left: 50%; width: 3.2rem; height: 3.2rem; margin-left: -1.6rem; overflow: visible; pointer-events: none; }
.pan .well path { fill: none; stroke: var(--ink); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 480ms var(--ease); }
.pan:hover canvas { transform: scale(1.08) rotate(-6deg); }
.pan span { font: 560 0.72rem/1.05 var(--hand); color: var(--ink-2); text-align: center; transition: color 200ms; }
.pan small { display: block; font: 450 0.62rem/1.2 var(--hand); color: var(--ink-3); }
.pan:has(input:checked) .well path { stroke-dashoffset: 0; }
.pan:has(input:checked) span { color: var(--ink); font-weight: 750; }
.pan:has(input:focus-visible) { outline: 2.5px solid var(--ink); outline-offset: 0; }
.modes { grid-area: modes; display: flex; gap: 0.05rem; }
.mode { position: relative; display: grid; justify-items: center; gap: 0.1rem; width: 3.3rem; padding: 0.3rem 0 0.25rem; cursor: pointer; border-radius: 12px; isolation: isolate; -webkit-tap-highlight-color: transparent; }
.mode input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.mode svg { width: 1.8rem; height: 1.8rem; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 380ms var(--spring); }
.mode svg .fill { fill: var(--ink); }
.mode span { font: 560 0.72rem/1 var(--hand); color: var(--ink-2); }
.mode::before { content: ""; position: absolute; inset: 0.1rem; border-radius: 48% 52% 45% 55% / 52% 46% 54% 48%; background: var(--table-2); opacity: 0; scale: 0.7; transition: opacity 200ms, scale 380ms var(--spring); z-index: -1; }
.mode:has(input:checked)::before { opacity: 1; scale: 1; }
.mode:has(input:checked) span { color: var(--ink); font-weight: 750; }
.mode:hover svg { transform: rotate(-8deg) scale(1.08); }
.mode:has(input:focus-visible) { outline: 2.5px solid var(--ink); }
.pan-note { grid-area: note; margin: 0; min-height: 1.3em; font: 450 0.82rem/1.3 var(--hand); color: var(--ink-2); text-align: center; }
.pan-note b { color: var(--ink); font-weight: 700; margin-right: 0.45em; }

.actions { grid-area: actions; display: flex; gap: 0.45rem; flex-wrap: nowrap; justify-content: flex-end; }
.act { white-space: nowrap; }
.act {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 1rem;
  border: 0; background: none;
  font: 650 0.9rem/1 var(--hand); font-variation-settings: var(--loose); color: var(--ink); cursor: pointer;
  transition: transform 220ms var(--spring), opacity 200ms, color 200ms;
}
.act::before { content: ""; position: absolute; inset: 0; z-index: -1; border: 2px solid var(--ink); border-radius: 16px 11px 18px 10px / 11px 17px 10px 15px; background: var(--fill, transparent); filter: url(#ink-0); transition: background-color 180ms; }
.act svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.act:hover { --fill: var(--table-2); }
.act:hover::before { animation: boil 480ms steps(1) infinite; }
.act:active { transform: scale(0.97); }
.act:disabled { opacity: 0.38; cursor: default; transform: none; }
.act:disabled::before { animation: none; }
.act.go { --fill: var(--ink); color: var(--stock); }
.act.go:hover { --fill: #2d2925; }
.act.is-done, .act.go.is-done, .act.go.is-done:hover { --fill: #2c5a3c; color: var(--stock); }
.link-facts { grid-area: facts; margin: 0.15rem 0 0; font: 450 0.82rem/1.4 var(--hand); color: var(--ink-2); text-align: center; text-wrap: balance; max-width: 40rem; }
.link-facts b { color: var(--ink); font-weight: 700; }

.notice { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 0.8rem; padding: var(--pad); background: var(--table); }
.notice h2 { margin: 0; font: 800 clamp(2rem, 5vw, 3rem)/1 var(--hand); font-variation-settings: var(--wild); }
.notice p { margin: 0; max-width: 28rem; color: var(--ink-2); }

.foot { padding: 0.4rem var(--pad) clamp(0.8rem, 2vh, 1.2rem); text-align: center; }
.foot p { margin: 0 auto; max-width: 52rem; font: 450 0.78rem/1.45 var(--hand); color: var(--ink-2); text-wrap: balance; }

.toast { position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); translate: -50% 1rem; padding: 0.65rem 1.1rem; border-radius: 16px 11px 18px 10px / 11px 17px 10px 15px; background: var(--ink); color: var(--stock); font: 600 0.9rem/1.2 var(--hand); opacity: 0; pointer-events: none; transition: opacity 250ms, translate 400ms var(--spring); z-index: 20; }
.toast.is-on { opacity: 1; translate: -50% 0; }

body.is-loading .card-room { opacity: 0; }
body.is-broken .say { visibility: hidden; }
.card-room { transition: opacity 500ms; }

/* Phones: a tall card, the paint box on one line, the moves under it. ------------------------ */
@media (max-width: 720px) {
  .top { grid-template-columns: 1fr; padding-top: 0.75rem; gap: 0.2rem; }
  .studio { display: flex; gap: 0.5rem; align-items: baseline; }
  .studio .wordmark { width: 6.4rem; }
  .studio-note { margin: 0; font-size: 1rem; }
  .say { text-align: left; }
  .say h1 { font-size: 1.85rem; }
  .say p { margin-left: 0; font-size: 0.86rem; }
  .desk { justify-content: flex-start; padding-top: 0.7rem; gap: 0.7rem; }
  .tray { grid-template-columns: 1fr auto; grid-template-areas: "drawings drawings" "pans pans" "modes note" "actions actions"; gap: 0.35rem; }
  .drawings { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .drawings::-webkit-scrollbar { display: none; }
  .drawings-label { display: none; }
  .dw { flex: none; width: 3.5rem; }
  .pan-note { text-align: right; align-self: center; }
  .pans { justify-content: space-between; }
  .pan { width: auto; flex: 1; }
  .pan canvas { width: 2.2rem; height: 2.2rem; }
  .pan .well { width: 2.9rem; height: 2.9rem; margin-left: -1.45rem; }
  .pan small { display: none; }
  .pan-note { font-size: 0.75rem; }
  .actions { justify-content: center; }
  .act { padding: 0 0.75rem; font-size: 0.84rem; gap: 0.4rem; white-space: nowrap; }
  .act:not(.go) svg { display: none; }
  .actions { gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
  body.is-painting .say p { display: none; }
  body.is-painting .say h1 { font-size: 1.6rem; }
  .foot { display: none; }
}

@media (max-height: 520px) and (min-width: 721px) {
  .top { padding-top: 0.5rem; }
  .say h1 { font-size: 1.6rem; }
  .say p, .foot, .studio span { display: none; }
  .desk { flex-direction: row; padding-top: 0.5rem; gap: 1.2rem; }
  .tray, .tray.back-tray, .tray.recv-tray { width: 15rem; grid-template-columns: 1fr; grid-template-areas: "pans" "actions" "facts"; justify-items: stretch; }
  .pans { flex-wrap: wrap; justify-content: center; }
  .pan { width: 4.4rem; }
  .drawings, .modes { flex-wrap: wrap; justify-content: center; }
  .tray, .tray.back-tray, .tray.recv-tray { grid-template-areas: "drawings" "pans" "modes" "actions" "facts"; }
  .pan small, .pan-note, .link-facts, .drawings-label { display: none; }
  .actions { flex-direction: column; align-items: stretch; }
  .act { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --flip: 1ms; }
  .card { transition: none; }
  .card.is-lifting, .say.is-change, .postmark.is-stamping { animation: none; }
  .face { transition: opacity 300ms; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .dw .loop path, .pan .well path { transition: none; }
}

@media (forced-colors: active) {
  .pan canvas, #paper, .stamp { forced-color-adjust: none; }
}
.card.is-flipped .brush, body.is-reading:not(.is-replay) .brush { visibility: hidden; }
