/* The Midnight Workshop: a candlelit bench after hours. See DESIGN.md. */
@font-face { font-family: "IM Fell English"; src: url(/fonts/im-fell-english-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell English"; font-style: italic; src: url(/fonts/im-fell-english-latin-400-italic.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya"; src: url(/fonts/alegreya-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya"; font-style: italic; src: url(/fonts/alegreya-latin-400-italic.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya"; font-weight: 700; src: url(/fonts/alegreya-latin-700-normal.woff2) format("woff2"); font-display: swap; }

/* Fallbacks tuned to the real faces so text barely moves when fonts arrive. */
@font-face { font-family: "Fell Fallback"; src: local("Georgia"); size-adjust: 92%; }
@font-face { font-family: "Alegreya Fallback"; src: local("Georgia"); size-adjust: 95%; }

:root {
  /* Type roles */
  --fs-mark: 1.3rem; --fs-price: 1.875rem; --fs-action: 1.25rem; --fs-caption: 1.125rem; --fs-small: 1rem; --fs-body: 1.1875rem; --fs-lead: 1.3rem; --fs-h3: 1.6rem;
  --fs-h2: clamp(1.9rem, 1.6rem + 1.2vw, 2.75rem); --fs-h1: clamp(2.6rem, 2rem + 3vw, 4.5rem); --fs-h1-sheet: clamp(2.1rem, 1.8rem + 1.5vw, 3rem);
  --soot: #110c09; --walnut: #1d140e; --walnut-up: #2b1e15; --line: #4d3726;
  --candle: #f0e2c8; --candle-dim: #c9b596; --flame: #f2bd5e; --brass: #cf9c3f;
  --wax: #8f1f1b; --wax-deep: #5a100f; --wax-lit: #c8412f;
  --paper: #f3e7cf; --paper-ink: #271a10; --paper-dim: #5d4631; --line-soft: rgb(240 226 200 / .14); --kraft: #b98c58;
  --display: "IM Fell English", "Fell Fallback", Georgia, serif;
  --text: "Alegreya", "Alegreya Fallback", Georgia, serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; scrollbar-color: var(--line) var(--soot); background: var(--soot); -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  display: flex; flex-direction: column; margin: 0; min-height: 100vh; color: var(--candle); font: 400 var(--fs-body)/1.6 var(--text); font-kerning: normal; text-rendering: optimizeLegibility;
  background:
    radial-gradient(70rem 42rem at 72% -6rem, #4a2f18 0%, #2a1a0f 42%, transparent 75%),
    url(/img/grain.svg),
    var(--soot);
  background-repeat: no-repeat, repeat, repeat;
}
::selection { background: var(--flame); color: var(--paper-ink); }
[hidden] { display: none !important; }
a { color: var(--flame); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: #ffd98c; text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; text-wrap: balance; }
h1 { font-size: var(--fs-h1); line-height: 1.04; margin: 0 0 1.25rem; letter-spacing: -.01em; }
h2 { font-size: var(--fs-h2); line-height: 1.12; margin: 0 0 1rem; }
p { margin: 0 0 1rem; max-width: 62ch; text-wrap: pretty; }

.bench-top { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; max-width: 76rem; margin: 0 auto; padding: 1.1rem 1.5rem; }
.mark { display: inline-flex; align-items: center; gap: .6rem; font: var(--fs-mark)/1.2 var(--display); color: var(--candle); text-decoration: none; }
.mark img { width: 2.1rem; height: 2.1rem; }
.bench-top nav { display: flex; gap: 1.25rem; }
.bench-top nav a { color: var(--candle-dim); text-decoration: none; padding: .35rem 0; }
.bench-top nav a:hover { color: var(--flame); }

.test-mode { background: rgb(0 0 0 / .25); max-width: none; margin: 0 0 1.5rem; padding: .5rem .9rem; border: 1px dashed var(--brass); color: var(--flame); font-size: var(--fs-small); }

/* Home */
.home main { width: 100%; max-width: 76rem; margin: 0 auto; padding: 0 1.5rem; }
.home .test-mode { display: inline-block; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: center; padding: 1.5rem 0 4.5rem; }
.price { font: 700 var(--fs-price)/1.2 var(--text); font-variant-numeric: lining-nums; color: var(--flame); margin: 1.5rem 0 .75rem; }
.buy {
  font: 700 var(--fs-action)/1.2 var(--text); padding: .9rem 1.8rem; min-height: 3rem; color: #fff3df; cursor: pointer;
  background: radial-gradient(circle at 35% 25%, var(--wax-lit), var(--wax) 60%, var(--wax-deep));
  border: 1px solid #d9604a; border-radius: 3px; box-shadow: inset 0 1px 0 rgb(255 220 190 / .35), 0 2px 3px rgb(0 0 0 / .5), 0 10px 22px rgb(0 0 0 / .5);
}
.buy:hover { background: radial-gradient(circle at 35% 25%, #dc5039, #a32822 60%, var(--wax)); }
.buy:disabled { opacity: .65; cursor: progress; }
#buy-error { margin-top: .75rem; color: #ffc9b3; font-weight: 700; }

.parcel { position: relative; margin: 0; max-width: 34rem; justify-self: center; width: 100%; padding-bottom: 1rem; }
.parcel .sheet-link { display: block; position: relative; z-index: 1; width: 76%; margin: 0 auto -44%; transform: rotate(-2.5deg); box-shadow: 0 2px 3px rgb(0 0 0 / .5), 0 18px 40px rgb(0 0 0 / .55); background: linear-gradient(160deg, #f8edd8, var(--paper) 45%, #e6d5b5); }
.parcel .sheet-link img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
.parcel .pocket { position: relative; z-index: 2; display: block; width: 100%; height: auto; aspect-ratio: 600 / 340; filter: drop-shadow(0 18px 24px rgb(0 0 0 / .6)); }
.parcel .wax { position: absolute; z-index: 3; left: 50%; bottom: 26%; width: 22%; transform: translateX(-50%) rotate(-8deg); filter: drop-shadow(0 4px 6px rgb(0 0 0 / .55)); }
.parcel figcaption { position: relative; z-index: 3; margin-top: .75rem; text-align: center; color: var(--candle-dim); font-style: italic; max-width: none; }

.sample { background: radial-gradient(60% 70% at 22% 50%, rgb(242 189 94 / .16), transparent 70%); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 3.5rem; align-items: center; padding: 4rem 0; border-top: 1px solid var(--line); }
.sample .big-sheet { display: block; background: linear-gradient(160deg, #f8edd8, var(--paper) 45%, #e6d5b5); box-shadow: 0 2px 3px rgb(0 0 0 / .5), 0 28px 60px rgb(0 0 0 / .65); transform: rotate(.6deg); }
.sample .big-sheet img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }

.inside { background: radial-gradient(50% 60% at 50% 20%, rgb(143 31 27 / .22), transparent 75%); padding: 4.5rem 0 5rem; border-top: 1px solid var(--line); }
.seals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; margin: 0 0 2.5rem; padding: 0; list-style: none; }
.seals li { text-align: center; font: italic var(--fs-caption)/1.25 var(--display); color: var(--candle-dim); }
.seals svg { display: block; width: 4.75rem; height: 4.75rem; margin: 0 auto .6rem; padding: 1rem; border-radius: 50%; color: #f2c3ab; background: radial-gradient(circle at 35% 28%, var(--wax-lit), var(--wax) 55%, var(--wax-deep)); box-shadow: 0 6px 12px rgb(0 0 0 / .5); }
.contents { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 2rem 4rem; padding: 0; margin: 0; list-style: none; }
.contents > li:first-child { font-size: var(--fs-lead); }
.contents > li:first-child ul { font-size: var(--fs-body); }
.key { font-size: var(--fs-lead); padding-left: 2rem; border-left: 1px solid var(--line); }
.key p { font: italic var(--fs-body)/1.5 var(--display); margin-top: 1rem; color: var(--candle-dim); }
.contents ul { padding-left: 1.1rem; margin: .5rem 0 0; }
.contents ul li { margin-bottom: .35rem; }
.contents ul li::marker { color: var(--brass); }

.delivery { margin: 0 calc(50% - 50vw); padding: 4.5rem 1.5rem; background: radial-gradient(90% 140% at 30% 0, #7d1a17, var(--wax-deep) 60%, #400b0a); box-shadow: inset 0 12px 24px -12px rgb(0 0 0 / .7), inset 0 -12px 24px -12px rgb(0 0 0 / .7); color: #f9e6d3; }
.delivery a { color: #ffd98c; }
.delivery > div { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2rem 4rem; max-width: 73rem; margin: 0 auto; }
.delivery h2 { margin: 0; }

.small-print { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; padding: 3.5rem 0; }
.small-print h2 { font-size: var(--fs-h3); }
.close { text-align: center; max-width: none; margin: 0; padding: 0 0 1rem; }

footer { background: none; width: 100%; max-width: 76rem; margin: 2rem auto 0; padding: 1.5rem; border-top: 1px solid var(--line); color: var(--candle-dim); font-size: var(--fs-small); }
footer p { max-width: none; margin-bottom: .5rem; }

/* Inner pages: a sheet of paper lying on the bench */
body:not(.home) main { width: calc(100% - 2rem); max-width: 46rem; margin: 1rem auto 3rem; padding: clamp(1.5rem, 5vw, 3.5rem); color: var(--paper-ink); background: linear-gradient(170deg, #f8edd8, var(--paper) 30%, #ecdcbe); box-shadow: 0 2px 3px rgb(0 0 0 / .5), 0 28px 60px rgb(0 0 0 / .65); }
body:not(.home) main a { color: #7c1a16; }
body:not(.home) main a:hover { color: var(--wax-deep); }
body:not(.home) .test-mode { background: rgb(143 31 27 / .08); border-color: var(--paper-dim); color: var(--paper-ink); }
body:not(.home) h1 { font-size: var(--fs-h1-sheet); line-height: 1.1; }
body:not(.home) h2 { font-size: var(--fs-h3); margin: 2.25rem 0 .4rem; }
body:not(.home) main { line-height: 1.55; }
body:not(.home) code { font-size: .9em; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .hero, .sample, .small-print { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .seals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contents, .delivery > div { grid-template-columns: minmax(0, 1fr); }
  .key { padding: 1.5rem 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

/* Phone: headline, the real puzzle, then price and action, then the pitch. */
@media (max-width: 860px) {
  .hero { display: flex; flex-direction: column; gap: 0; padding-bottom: 3rem; }
  .hero > div { display: contents; }
  .hero > div > * { order: 3; }
  .hero h1 { order: 0; }
  .hero .parcel { order: 1; margin-bottom: 1.5rem; }
  .hero .price, .hero .final, .hero #sales-off, .hero #sales-unknown, .hero #buy, .hero noscript { order: 2; }
  .hero #buy, .hero #sales-off { margin-bottom: 1.5rem; }
  .hero .price { margin-top: 0; }
}

.final { font-weight: 700; margin: 0 0 1rem; }
a.buy { display: inline-block; text-decoration: none; color: #fff3df; }
a.buy:hover { color: #fff3df; }
body:not(.home) main a.buy { color: #fff3df; overflow-wrap: anywhere; }

/* Try the sample here */
.try { margin-top: 1.75rem; padding: 1.25rem 1.5rem; background: rgb(0 0 0 / .28); border: 1px solid var(--line); border-radius: 3px; }
.try label { display: block; font: var(--fs-lead)/1.3 var(--display); margin-bottom: .75rem; }
.try-row { display: flex; flex-wrap: wrap; gap: .75rem; }
.try input { width: 5rem; min-height: 3rem; padding: 0 .75rem; font: 700 var(--fs-lead) var(--text); font-variant-numeric: lining-nums; text-align: center; color: var(--paper-ink); caret-color: var(--wax); background: var(--paper); border: 1px solid var(--brass); border-radius: 2px; }
.try button { min-height: 3rem; padding: 0 1.25rem; font: 700 var(--fs-body) var(--text); color: var(--candle); background: var(--walnut-up); border: 1px solid var(--brass); border-radius: 3px; cursor: pointer; }
.try button:hover { background: #3a2819; color: var(--flame); }
.try-out { margin: .75rem 0 0; min-height: 3.2em; }
.solved .try-out { color: var(--flame); font-weight: 700; }

/* Real kit pages, fanned on the bench */
.fan { display: flex; justify-content: center; padding: 2rem 1.5rem 1rem; }
.fan img { min-width: 0; width: 38%; height: auto; margin-inline: -4%; background: var(--paper); mix-blend-mode: normal; box-shadow: 0 2px 3px rgb(0 0 0 / .5), 0 14px 28px rgb(0 0 0 / .55); filter: sepia(.45) brightness(.95); }
.fan img:nth-child(1) { transform: rotate(-6deg); }
.fan img:nth-child(2) { transform: translateY(-6%); z-index: 1; }
.fan img:nth-child(3) { transform: rotate(6deg); }

/* Motion: one authored moment, the page rising out of the envelope as the wax presses down. */
a, .buy, .try button { transition: color .15s ease-out, background-color .15s ease-out, box-shadow .15s ease-out, transform .15s ease-out; }
.buy:active, .try button:active { transform: translateY(1px); }
body { position: relative; isolation: isolate; }
body::before { content: ""; position: absolute; z-index: -1; inset: 0 0 auto; height: 44rem; pointer-events: none; background: radial-gradient(40rem 26rem at 72% 0, rgb(242 189 94 / .13), transparent 72%); }

@media (prefers-reduced-motion: no-preference) {
  .parcel .sheet-link { animation: rise 1.1s cubic-bezier(.16, 1, .3, 1) .15s backwards; transition: translate .35s cubic-bezier(.16, 1, .3, 1); }
  .parcel .sheet-link:hover, .parcel .sheet-link:focus-visible { translate: 0 -2.5%; }
  .parcel .wax { animation: press .5s cubic-bezier(.16, 1, .3, 1) .85s backwards; }
  body::before { animation: flicker 9s ease-in-out 3; } /* ponytail: three runs then still, no offscreen loop */
  .solved .try-out { animation: settle .4s cubic-bezier(.16, 1, .3, 1); }
  @keyframes rise { from { transform: translateY(34%) rotate(0deg); } }
  @keyframes press { from { opacity: 0; transform: translateX(-50%) rotate(-20deg) scale(1.5); } }
  @keyframes flicker { 0%, 100% { opacity: 1; } 22% { opacity: .78; } 37% { opacity: .95; } 61% { opacity: .7; } 80% { opacity: .92; } }
  @keyframes settle { from { opacity: 0; transform: translateY(.3rem); } }
}

/* Phones: thumbs, notches, small screens */
:root { --gutter: max(1.5rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
.bench-top, .home main, footer { padding-inline: var(--gutter); }
.delivery { padding-inline: var(--gutter); }
footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
.bench-top nav a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0; }
.mark { min-height: 2.75rem; }
footer a { display: inline-block; padding: .6rem 0; }
.close a { display: inline-block; padding: .6rem 0; }
@media (max-width: 860px) {
  .buy, .try button { width: 100%; }
  .try input { flex: 0 0 5rem; }
  .try button { flex: 1 1 10rem; width: auto; }
  .parcel { max-width: 26rem; }
  .sample .big-sheet { max-width: 26rem; margin-inline: auto; }
  .sample { padding-block: 3rem; }
  .inside { padding-block: 3rem; }
  .delivery { padding-block: 3rem; }
  .small-print { padding-block: 2.5rem; }
  .fan { max-width: 26rem; margin-inline: auto; }
}
@media (max-width: 380px) {
  :root { --fs-body: 1.0625rem; --fs-lead: 1.1875rem; }
  .seals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bench-top nav { gap: 1rem; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .parcel { max-width: 18rem; }
}

/* Access: keyboard and system settings */
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 5; padding: .6rem 1rem; color: var(--paper-ink); background: var(--flame); }
.skip:focus { top: 1rem; color: var(--paper-ink); }
#content:focus { outline: none; }
body:not(.home) main :focus-visible, .sample .big-sheet:focus-visible, .sheet-link:focus-visible { outline-color: var(--wax); }
.parcel .sheet-link:focus-visible, .sample .big-sheet:focus-visible { outline: 3px solid var(--flame); outline-offset: 4px; }
.delivery :focus-visible { outline-color: #fff; }
.try input:focus-visible { outline-color: var(--flame); }
@media (forced-colors: active) {
  .buy, .try button, .test-mode { border: 2px solid ButtonText; }
  .parcel .sheet-link img, .sample .big-sheet img { forced-color-adjust: none; }
}
