/* THE SECRET REVEAL — Midnight & Champagne. Self-hosted fonts only; no third-party requests. */

@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-latin-wdth-normal.woff2') format('woff2');
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
}

/* ---------- Colour variants. A new variant = one more block of these tokens. ---------- */
:root, [data-theme='midnight-champagne'] {
  --bg: #0a0908; --bg-lift: rgba(255, 228, 182, 0.09);
  --ink: #efe6d4; --muted: rgba(239, 230, 212, 0.66);
  --gold: #cfae6d; --gold-hi: #f1dca6;
  --paper: #f3ead8; --paper-2: #e6d8bd; --paper-3: #ece0c8; --paper-ink: #2a2118; --paper-muted: #6b5a43;
  --frame: #a9853f; --gold-deep: #7a5a22; --secret-ink: #5a1622;
  --foil-1: #6f5328; --foil-2: #d8bd82; --foil-3: #a17e44; --foil-4: #f4e4b8; --foil-5: #866634; --foil-ink: rgba(66, 45, 15, 0.8);
  --wax-hi: #a3404f; --wax-mid: #6b1a27; --wax-lo: #3a0b13; --wax-ink: rgba(255, 214, 200, 0.22);
  --velvet-hi: #4a1622; --velvet: #2c0b12; --velvet-lo: #16050a;
  --tile: rgba(255, 255, 255, 0.035); --line: rgba(207, 174, 109, 0.26);
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
[data-theme='ivory-pearl'] {
  --bg: #16151a; --bg-lift: rgba(226, 222, 240, 0.10);
  --ink: #f1eef3; --muted: rgba(241, 238, 243, 0.66);
  --gold: #cfc6d6; --gold-hi: #f3eef7;
  --paper: #f7f4ef; --paper-2: #e7e1d8; --paper-3: #efeae2; --paper-ink: #24212a; --paper-muted: #5f5868;
  --frame: #a49cab; --gold-deep: #5d5468; --secret-ink: #2f2a52;
  --foil-1: #8d8a93; --foil-2: #e9e6ee; --foil-3: #b9b1c6; --foil-4: #fbf8f2; --foil-5: #a59fae; --foil-ink: rgba(55, 50, 70, 0.72);
  --wax-hi: #6e7fa8; --wax-mid: #33406a; --wax-lo: #171d38; --wax-ink: rgba(230, 236, 255, 0.24);
  --velvet-hi: #2e3150; --velvet: #1a1c33; --velvet-lo: #0c0d1b;
  --tile: rgba(255, 255, 255, 0.045); --line: rgba(207, 198, 214, 0.28);
}
[data-theme='bordeaux-velvet'] {
  --bg: #12060a; --bg-lift: rgba(255, 196, 176, 0.09);
  --ink: #f4e6de; --muted: rgba(244, 230, 222, 0.66);
  --gold: #e0b29a; --gold-hi: #f8dccb;
  --paper: #f5ebe1; --paper-2: #e8d6c6; --paper-3: #eee0d3; --paper-ink: #2c1a17; --paper-muted: #6e5248;
  --frame: #b07d68; --gold-deep: #7e4b39; --secret-ink: #5a1622;
  --foil-1: #7c4e3f; --foil-2: #e6b9a0; --foil-3: #a87361; --foil-4: #f7dccb; --foil-5: #8d5c4b; --foil-ink: rgba(70, 35, 25, 0.78);
  --wax-hi: #d9b679; --wax-mid: #9c7a3d; --wax-lo: #4f3a14; --wax-ink: rgba(255, 245, 220, 0.3);
  --velvet-hi: #5a1a28; --velvet: #350d17; --velvet-lo: #1a050b;
  --tile: rgba(255, 255, 255, 0.04); --line: rgba(224, 178, 154, 0.26);
}

/* Paper fibres and grain, drawn by the browser from tiny inline SVGs (no image files). */
:root {
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .24 0 0 0 0 .16 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  --paper-fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.008 .11' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .26 0 0 0 .9 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='.22'/%3E%3C/svg%3E");
  --film-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5;
  background:
    radial-gradient(ellipse 70% 55% at 50% 16%, var(--bg-lift), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 120%, rgba(0, 0, 0, 0.7), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 4px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.noscript { text-align: center; padding: 40px 16px; }

.grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 30; opacity: 0.06; mix-blend-mode: overlay;
  background-image: var(--film-grain);
}
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop-image img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; scale: 1.1; transition: opacity 2.6s ease, scale 12s cubic-bezier(.2, .6, .2, 1);
}
.has-backdrop .backdrop-image img { opacity: 0.8; scale: 1; }
.backdrop::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 75% 60% at 50% 40%, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.78) 80%), linear-gradient(transparent 50%, rgba(0, 0, 0, 0.6));
}

.app {
  min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(40px, env(safe-area-inset-top)) 16px 64px; gap: 28px;
}
.loading { margin: auto; }
.loading-dot {
  display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.25; transform: scale(0.6); } }

.eyebrow {
  margin: 0; font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--gold);
}

/* ---------- The card (paper, frame, light) ---------- */
.stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.card-wrap { perspective: 1400px; display: grid; place-items: center; }
.card {
  position: relative; width: min(86vw, 380px); aspect-ratio: 5 / 7; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 44px 30px; text-align: center; color: var(--paper-ink); border-radius: 5px;
  background: var(--paper-fibre), var(--paper-grain), linear-gradient(160deg, var(--paper) 0%, var(--paper-3) 55%, var(--paper-2) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    0 2px 2px rgba(0, 0, 0, 0.35), 0 26px 50px -18px rgba(0, 0, 0, 0.85), 0 60px 90px -40px rgba(0, 0, 0, 0.7);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s cubic-bezier(.2, .7, .2, 1);
}
/* Gold double frame, a little pressed into the paper. */
.card::before, .card::after { content: ''; position: absolute; pointer-events: none; border-radius: 2px; }
.card::before { inset: 12px; border: 1px solid var(--frame); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55); opacity: 0.9; }
.card::after { inset: 17px; border: 0.5px solid var(--frame); opacity: 0.45; }
.card.is-scratching { transform: none; }

/* Photographed card (plate P1): real deckled cotton with its own pressed frame, cut out along the torn edge.
   The same image is the mask, so light sweeps and sheen stay on the paper; the wrapper casts the shadow. */
.plate-card .card-secret, .plate-card .card-hint.is-tall {
  background: url('plates/card.webp') center / 100% 100% no-repeat;
  border-radius: 0; box-shadow: none; padding: 17% 15%;
  -webkit-mask: url('plates/card.webp') center / 100% 100% no-repeat;
  mask: url('plates/card.webp') center / 100% 100% no-repeat;
}
/* Landscape clue cards use the same photographed card turned a quarter. */
.plate-card .card-hint:not(.is-tall) {
  background: url('plates/card-wide.webp') center / 100% 100% no-repeat;
  border-radius: 0; box-shadow: none; padding: 9% 13%;
  -webkit-mask: url('plates/card-wide.webp') center / 100% 100% no-repeat;
  mask: url('plates/card-wide.webp') center / 100% 100% no-repeat;
}
.plate-card .card-hint::before, .plate-card .card-hint::after { display: none; }
.plate-card .env-card, .plate-card .reading:has(> .card-hint) { filter: drop-shadow(0 18px 20px rgba(0, 0, 0, 0.7)); }
.plate-card .slide-holder:focus-visible { outline: none; filter: drop-shadow(0 0 3px var(--gold-hi)) drop-shadow(0 0 10px var(--gold)); }
.plate-card .card-wrap:has(> .card-secret), .plate-card .card-wrap:has(> .card-hint.is-tall),
.plate-card .reading:has(> .card-hint.is-tall), .plate-card .slide-holder {
  filter: drop-shadow(0 22px 24px rgba(0, 0, 0, 0.8)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}
.plate-card .card-secret::before, .plate-card .card-secret::after,
.plate-card .card-hint.is-tall::before, .plate-card .card-hint.is-tall::after { display: none; }
.plate-card .card-secret .card-sheen, .plate-card .card-hint.is-tall .card-sheen { opacity: 0.6; }
.card-sheen {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit; mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--lx, 28%) var(--ly, 18%), rgba(255, 255, 255, 0.75), transparent 46%);
}
.card-sweep { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; border-radius: inherit; }
.card-sweep::before {
  content: ''; position: absolute; top: -20%; bottom: -20%; width: 55%; left: 0; translate: -130% 0; rotate: 12deg;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 214, 0.0) 20%, rgba(255, 246, 214, 0.85) 50%, rgba(255, 246, 214, 0) 80%, transparent);
  mix-blend-mode: soft-light;
}
.card.is-revealed .card-sweep::before { animation: sweep 1.9s cubic-bezier(.45, .05, .25, 1) 0.2s both; }
.card.is-revealed { animation: push 2.2s cubic-bezier(.3, .6, .2, 1) both; }
@keyframes sweep { to { translate: 260% 0; } }
@keyframes push { 40% { scale: 1.035; } 100% { scale: 1; } }

.card-eyebrow { color: var(--gold-deep); font-size: 10.5px; }
.card-opening {
  margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(25px, 7.4vw, 31px); line-height: 1.12;
  letter-spacing: 0.005em; max-width: 13ch; text-wrap: balance;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.card-rule { width: 54px; height: 1px; background: linear-gradient(90deg, transparent, var(--frame), transparent); position: relative; }
.card-rule::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; translate: -50% -50%; rotate: 45deg;
  background: var(--frame);
}
.signature { margin: 0; font-family: var(--serif); font-style: italic; font-size: 21px; color: var(--gold-deep); }

/* The well the foil sits in: debossed, so the revealed words look printed into the card. */
.foil-slot {
  position: relative; width: 100%; min-height: 124px; display: grid; place-items: center; padding: 14px 16px;
  border-radius: 12px; touch-action: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.045), rgba(255, 255, 255, 0.25));
  box-shadow: inset 0 2px 4px rgba(60, 40, 10, 0.18), inset 0 -1px 0 rgba(255, 255, 255, 0.7);
}
.secret-headline, .hint-text {
  margin: 0; font-family: var(--serif); color: var(--secret-ink); line-height: 1.12; text-wrap: balance;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.secret-headline { font-size: clamp(27px, 8vw, 34px); }
.secret-headline:focus, .hint-text:focus { outline: none; }
.foil-slot.is-pending:not(.is-covered) > :not(canvas) { visibility: hidden; }
canvas.foil {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; z-index: 1; touch-action: none;
  cursor: grab; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18), 0 6px 14px -6px rgba(60, 35, 5, 0.45);
}
canvas.foil:active { cursor: grabbing; }
canvas.foil.is-lifting {
  pointer-events: none; opacity: 0; filter: brightness(1.4); scale: 1.015;
  transition: opacity 1.2s ease 0.1s, filter 0.6s ease, scale 1.2s ease;
}
canvas.foil-flakes { position: absolute; top: 0; left: 0; width: 100%; pointer-events: none; z-index: 4; }

.below-card { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 64px; text-align: center; }
.mech-hint {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--muted);
  transition: color 0.4s;
}
.mech-hint.is-nudged { color: var(--gold-hi); animation: nudge 0.5s ease 2; }
@keyframes nudge { 50% { translate: 0 -3px; } }
.quiet-btn {
  appearance: none; border: 0; background: none; padding: 10px 12px; min-height: 44px; cursor: pointer;
  color: var(--muted); font-size: 13px; letter-spacing: 0.04em; text-decoration: underline; text-decoration-color: var(--line);
  text-underline-offset: 5px;
}
.quiet-btn:hover { color: var(--ink); }

/* Entrance: the card comes up out of the dark, like a slow dolly-in. */
.is-entering .card-wrap, .is-entering .days-header, .is-entering .days-grid li {
  animation: enter 1.9s cubic-bezier(.2, .7, .1, 1) both;
}
.is-entering .below-card { animation: fade 1s ease 1.4s both; }
.is-entering .days-grid li { animation-duration: 1.2s; }
.is-entering .days-grid li:nth-child(2) { animation-delay: 0.08s; }
.is-entering .days-grid li:nth-child(3) { animation-delay: 0.16s; }
.is-entering .days-grid li:nth-child(4) { animation-delay: 0.24s; }
.is-entering .days-grid li:nth-child(5) { animation-delay: 0.32s; }
.is-entering .days-grid li:nth-child(6) { animation-delay: 0.4s; }
.is-entering .days-grid li:nth-child(7) { animation-delay: 0.48s; }
@keyframes enter {
  from { opacity: 0; transform: translateY(34px) rotateX(14deg) scale(0.94); filter: blur(5px) brightness(0.3); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes fade { from { opacity: 0; } }

/* ---------- Finale ---------- */
.after-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.finale {
  width: min(100%, 34rem); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  opacity: 0; translate: 0 14px; transition: opacity 1.4s ease 0.2s, translate 1.4s cubic-bezier(.2, .7, .2, 1) 0.2s;
}
.finale.is-in { opacity: 1; translate: 0 0; }
.finale-message { margin: 0; font-family: var(--serif); font-size: clamp(20px, 5.4vw, 24px); line-height: 1.35; text-wrap: pretty; }
.finale-signature { color: var(--gold); font-size: 23px; }
.finale-photo {
  margin: 6px 0 8px; padding: 10px 10px 30px; background: var(--paper); rotate: -2deg; width: min(62vw, 230px);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
}
.finale-photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.btn {
  appearance: none; cursor: pointer; min-height: 46px; padding: 12px 22px; border-radius: 999px;
  border: 1px solid var(--gold); background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1b140a;
  font-size: 12px; font-weight: 650; letter-spacing: 0.2em; text-transform: uppercase;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-ghost { background: rgba(255, 255, 255, 0.03); color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn:hover { filter: brightness(1.06); }
.film-layer { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: center; transition: opacity 0.7s; }
.film-layer.is-out { opacity: 0; }
.film { width: 100%; height: 100%; object-fit: cover; }
.film-skip { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); color: #fff; }

/* ---------- Days of Secrets ---------- */
.days-header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 34rem; }
.days-title {
  margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 9.6vw, 56px); line-height: 1.02;
  letter-spacing: -0.005em; text-wrap: balance;
}
.days-opening { margin: 0; font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--muted); }
.days-meta { margin: 0; font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }
.days-zone { opacity: 0.8; }
.days-grid {
  list-style: none; margin: 0; padding: 0; width: min(100%, 720px);
  display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px;
}
.days-grid[data-count='3'], .days-grid[data-count='5'] { --cols: 2; }
.days-grid li:last-child { grid-column: 1 / -1; justify-self: center; width: min(100%, 300px); }
@media (min-width: 720px) {
  .days-grid { --cols: 4 !important; gap: 16px; }
  .days-grid[data-count='3'] { --cols: 3 !important; }
  .days-grid[data-count='3'] li:last-child { grid-column: auto; width: 100%; }
  .days-grid[data-count='5'] li:last-child { grid-column: 2 / span 2; width: 100%; }
}
.tile {
  appearance: none; width: 100%; height: 100%; min-height: 152px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--tile); text-align: center;
  color: var(--ink); position: relative;
}
button.tile { cursor: pointer; transition: transform 0.4s cubic-bezier(.2, .7, .2, 1), border-color 0.3s, background 0.3s; }
button.tile:hover { transform: translateY(-3px); border-color: var(--gold); background: rgba(255, 255, 255, 0.06); }
.tile-env {
  position: relative; width: 78%; aspect-ratio: 10 / 7; margin-bottom: 8px; border-radius: 2px;
  background: var(--paper-grain), linear-gradient(170deg, var(--paper), var(--paper-2));
  box-shadow: 0 10px 18px -10px rgba(0, 0, 0, 0.9);
}
.tile-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; transform-origin: top;
  background: linear-gradient(180deg, var(--paper-3), var(--paper-2)); clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
}
.tile-seal {
  position: absolute; left: 50%; top: 58%; width: 24%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, var(--wax-hi), var(--wax-mid) 55%, var(--wax-lo));
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}
.tile-num { font-family: var(--serif); font-size: 26px; line-height: 1; color: var(--gold); }
.tile-label { font-size: 10px; font-weight: 600; letter-spacing: 0.26em; text-transform: uppercase; color: var(--ink); }
.tile-status { font-size: 12px; color: var(--muted); line-height: 1.3; }
.tile-hint {
  margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 15px; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tile[data-state='locked'] { opacity: 0.62; border-style: dashed; }
.tile[data-state='locked'] .tile-env { filter: brightness(0.5) saturate(0.4); }
.tile[data-state='locked'] .tile-seal { background: radial-gradient(circle at 36% 30%, #6b6258, #3b352f 60%, #1d1a17); }
.tile[data-state='ready'] { border-color: var(--gold); background: rgba(207, 174, 109, 0.07); }
.tile[data-state='ready'] .tile-status { color: var(--gold-hi); }
.tile[data-state='ready'] .tile-seal { animation: glow 2.8s ease-in-out infinite; }
@keyframes glow {
  50% { box-shadow: 0 0 0 4px rgba(241, 220, 166, 0.16), 0 0 18px 4px rgba(241, 220, 166, 0.35), 0 2px 3px rgba(0, 0, 0, 0.45); }
}
.tile[data-state='opened'] .tile-flap { transform: perspective(300px) rotateX(180deg); filter: brightness(0.92); }
.tile[data-state='opened'] .tile-seal { opacity: 0; }
.tile[data-final='true'] { border-color: var(--gold); background: linear-gradient(180deg, rgba(207, 174, 109, 0.1), rgba(255, 255, 255, 0.02)); }
.tile[data-final='true'] .tile-num { font-size: 22px; }
.tile[data-final='true'] .tile-env { width: min(78%, 150px); }
.tile[data-final='true'] .tile-seal { width: 28%; }

/* ---------- Day view (dialog) ---------- */
.day-dialog {
  width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; padding: max(56px, env(safe-area-inset-top)) 16px 48px;
  color: var(--ink); overflow-x: hidden; overflow-y: auto;
  background: radial-gradient(ellipse 80% 55% at 50% 30%, var(--bg-lift), transparent 70%), transparent;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.day-dialog::backdrop { background: rgba(4, 3, 3, 0.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
body:has(.day-dialog[open]) .app, body:has(.day-dialog[open]) .footer { visibility: hidden; }
.has-backdrop .day-dialog::backdrop { background: rgba(4, 3, 3, 0.12); backdrop-filter: none; -webkit-backdrop-filter: none; }
.day-dialog[open] { animation: fade 0.6s ease both; }
.dialog-close {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); font-size: 24px; line-height: 1; cursor: pointer; z-index: 5;
}
.dialog-stage { flex: 1 0 auto; justify-content: center; }
.mech-host { display: grid; place-items: center; width: 100%; }
.mech-host > * { grid-area: 1 / 1; }
.mech { display: flex; flex-direction: column; align-items: center; gap: 14px; transition: opacity 0.6s ease; }
.reading { display: grid; place-items: center; }

.card-hint { aspect-ratio: 10 / 7; justify-content: center; gap: 12px; padding: 30px 26px; }
.reading .card-hint { width: min(88vw, 420px); }
.reading .card-hint.is-tall { width: min(80vw, 330px); aspect-ratio: 5 / 7; }
.hint-slot { width: 100%; display: grid; place-items: center; min-height: 78px; }
.hint-text { font-size: clamp(22px, 6.4vw, 28px); max-width: 18ch; }
.card-hint .signature { font-size: 18px; }
.card-hint.has-photo { gap: 10px; padding: 34px 24px 28px; }
.card-hint.has-photo .hint-text { font-size: clamp(20px, 5.6vw, 24px); }
.env-card .card.has-photo { overflow: hidden; }
/* A small glossy photo print, slightly askew, as if tucked onto the card by hand. */
.hint-photo {
  position: relative; margin: 2px 0 4px; width: 84%; padding: 7px 7px 9px; background: #fbfaf6; rotate: -1.6deg;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 12px 22px -10px rgba(40, 25, 5, 0.55);
}
.hint-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; filter: saturate(1.05) contrast(1.03); }
.hint-photo-gloss {
  position: absolute; inset: 7px 7px 9px; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.1));
}

/* Wax seal on an envelope. */
.envelope { position: relative; width: min(88vw, 400px); aspect-ratio: 10 / 7.2; margin-top: 28px; }
.env-back {
  position: absolute; inset: 0; border-radius: 3px;
  background: var(--paper-grain), linear-gradient(180deg, var(--paper-2), var(--paper));
  box-shadow: inset 0 0 30px rgba(60, 40, 10, 0.25), 0 30px 60px -24px rgba(0, 0, 0, 0.9);
}
.env-card { position: absolute; left: 4.5%; right: 4.5%; top: 5%; bottom: 5%; z-index: 3; transition: transform 1.2s cubic-bezier(.25, .7, .2, 1) 0.35s; }
.env-card .card { width: 100%; height: 100%; aspect-ratio: auto; }
.env-front {
  position: absolute; inset: 0; z-index: 4; border-radius: 0 0 3px 3px; pointer-events: none;
  background: var(--paper-grain), linear-gradient(175deg, var(--paper-3) 30%, var(--paper-2));
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 -12px 24px rgba(60, 40, 10, 0.12);
}
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 5; transform-origin: top; pointer-events: none;
  background: var(--paper-grain), linear-gradient(180deg, var(--paper), var(--paper-2));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: perspective(900px) rotateX(0deg);
}
.is-open .env-flap { animation: flap 0.9s cubic-bezier(.5, .05, .3, 1) both; }
@keyframes flap {
  0% { transform: perspective(900px) rotateX(0deg); z-index: 5; }
  49% { z-index: 5; }
  50% { z-index: 2; filter: brightness(0.8); }
  100% { transform: perspective(900px) rotateX(180deg); z-index: 2; filter: brightness(0.9); }
}
.is-open .env-card { transform: translateY(-60%); }
.mech-seal.is-leaving .envelope > :not(.env-card) { opacity: 0; transition: opacity 0.6s ease; }

.seal {
  position: absolute; left: 50%; top: 58%; width: 23%; aspect-ratio: 1; translate: -50% -50%; z-index: 6;
  appearance: none; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.5)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
  transition: scale 0.3s ease;
}
.seal-svg, .seal-cracks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.wax-hi { stop-color: var(--wax-hi); }
.wax-mid { stop-color: var(--wax-mid); }
.wax-lo { stop-color: var(--wax-lo); }
.wax-ring-lo { fill: none; stroke: rgba(0, 0, 0, 0.35); stroke-width: 3; }
.wax-ring-hi { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 1.4; }
.wax-bead { fill: none; stroke: var(--wax-ink); stroke-width: 0.8; stroke-dasharray: 1.2 2.2; }
.wax-mono, .wax-mono-lo { font-family: var(--serif); font-style: italic; font-size: 42px; }
.wax-mono { fill: var(--wax-ink); }
.wax-mono-lo { fill: rgba(0, 0, 0, 0.35); }
.crack { fill: none; stroke: rgba(20, 3, 6, 0.85); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--hold, 0)); }
.crack:not(.crack-main) { stroke-width: 1.1; stroke-dashoffset: calc(1 - max(0, var(--hold, 0) * 2 - 1)); }
.seal-ring {
  position: absolute; inset: -9px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--gold-hi) calc(var(--hold, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  opacity: 0.9;
}
.is-holding .seal { scale: 0.95; }
.is-holding .seal-svg { animation: tremble 0.12s linear infinite; }
@keyframes tremble { 25% { translate: 0.4px 0; } 75% { translate: -0.4px 0.3px; } }
/* Photographed envelope (plate P5), cut into three layers so it can still open: the body (inside and pocket),
   the flap's outside (closed) and the flap's lined inside, which takes over halfway through the turn. */
.plate-envelope .envelope { aspect-ratio: 900 / 684; }
.plate-envelope .env-back { background: url('plates/env-body.jpg') center / 100% 100%; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.9); }
.plate-envelope .env-front {
  background: url('plates/env-body.jpg') center / 100% 100%; box-shadow: none;
  clip-path: polygon(0 0, 1.8% 0, 36.7% 45.6%, 63.3% 45.6%, 98.1% 0, 100% 0, 100% 100%, 0 100%);
}
.plate-envelope .env-flap {
  height: 82%; clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(60, 40, 10, 0.12)), url('plates/env-flap-out.jpg') center / 100% 100%;
}
.plate-envelope .is-open .env-flap { animation-name: flap-photo; }
@keyframes flap-photo {
  0% { transform: perspective(900px) rotateX(0deg); z-index: 5; }
  49% { z-index: 5; }
  50% { z-index: 2; background: url('plates/env-flap-in.jpg') center / 100% 100%; }
  100% { transform: perspective(900px) rotateX(180deg); z-index: 2; background: url('plates/env-flap-in.jpg') center / 100% 100%; }
}
.plate-envelope .seal, .plate-envelope .seal-half { top: 79%; }
.plate-envelope .is-open .env-card { transform: translateY(-64%); }
.plate-envelope .tile-env { aspect-ratio: 900 / 684; background: url('plates/env-body.jpg') center / 100% 100%; }
.plate-envelope .tile-flap { height: 82%; filter: none; background: url('plates/env-flap-out.jpg') center / 100% 100%; }
.plate-envelope .tile-seal { top: 79%; }
.plate-envelope .tile[data-state='opened'] .tile-flap { background: url('plates/env-flap-in.jpg') center / 100% 100%; }

/* Photographed velvet sleeve (plate P4): it covers the whole card; only the notch shows the card inside. */
.plate-sleeve .sleeve {
  left: -4%; right: -4%; bottom: -3%; height: auto; aspect-ratio: 620 / 856; padding-bottom: 16%;
  background: url('plates/sleeve.jpg') center / 100% 100%; background-blend-mode: normal;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9);
  -webkit-mask: radial-gradient(ellipse 17.8% 10.8% at 50% 0, transparent 97%, #000 100%);
  mask: radial-gradient(ellipse 17.8% 10.8% at 50% 0, transparent 97%, #000 100%);
}
.plate-sleeve .sleeve::before { display: none; }
.plate-sleeve .sleeve-wrap { margin-top: clamp(60px, 20vh, 200px); }

/* Photographed seal (plate P3). */
.seal-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.plate-seal .seal, .plate-seal .seal-half { width: 26%; }
.seal-half .seal-photo { filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.5)); }
.is-holding .seal-photo { animation: tremble 0.12s linear infinite; }
.plate-seal .tile-seal {
  width: 30%; background: url('plates/seal.webp') center / contain no-repeat; box-shadow: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}
.plate-seal .tile[data-state='locked'] .tile-seal { background: url('plates/seal.webp') center / contain no-repeat; filter: grayscale(1) brightness(0.55); }
.plate-seal .tile[data-final='true'] .tile-seal { width: 34%; }
.seal-half { position: absolute; left: 50%; top: 58%; width: 23%; aspect-ratio: 1; translate: -50% -50%; z-index: 6; pointer-events: none; }
.seal-half .seal-svg { filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.5)); }
.seal-half-a { clip-path: polygon(0 0, 52% 0, 47% 25%, 54% 38%, 46% 52%, 53% 67%, 48% 82%, 50% 100%, 0 100%); animation: half-a 1.1s cubic-bezier(.4, 0, .7, .4) both; }
.seal-half-b { clip-path: polygon(52% 0, 100% 0, 100% 100%, 50% 100%, 48% 82%, 53% 67%, 46% 52%, 54% 38%, 47% 25%); animation: half-b 1.1s cubic-bezier(.4, 0, .7, .4) both; }
@keyframes half-a { 15% { transform: translate(-4px, -2px) rotate(-6deg); } to { transform: translate(-46px, 150px) rotate(-38deg); opacity: 0; } }
@keyframes half-b { 15% { transform: translate(4px, -1px) rotate(7deg); } to { transform: translate(40px, 160px) rotate(44deg); opacity: 0; } }

/* Card in a velvet sleeve. */
.sleeve-wrap { position: relative; width: min(66vw, 280px); margin-top: clamp(40px, 16vh, 170px); }
.slide-holder {
  position: relative; z-index: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  transform: translateY(calc(var(--pull, 0) * -46%));
}
.slide-holder:active { cursor: grabbing; }
.slide-holder .card { width: 100%; aspect-ratio: 5 / 7; }
.is-animating .slide-holder, .is-animating .sleeve { transition: transform 0.5s cubic-bezier(.2, .8, .2, 1); }
.pull-tab {
  position: absolute; z-index: 4; left: 50%; top: -14px; width: 46px; height: 26px; translate: -50% 0; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--wax-hi), var(--wax-mid)); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.sleeve {
  /* Drags pass through to the card, so pulling anywhere on the sleeve moves the card. */
  pointer-events: none;
  position: absolute; z-index: 2; left: -5%; right: -5%; bottom: -5%; height: 80%; border-radius: 4px 4px 10px 10px;
  display: grid; place-items: end center; padding-bottom: 22%;
  background:
    radial-gradient(120% 60% at 30% 0%, rgba(255, 255, 255, 0.13), transparent 55%),
    var(--paper-grain),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--velvet-hi), var(--velvet) 45%, var(--velvet-lo));
  background-blend-mode: normal, soft-light, normal, normal;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 30px 60px -20px rgba(0, 0, 0, 0.9);
  -webkit-mask: radial-gradient(circle 24px at 50% 0, transparent 98%, #000 100%);
  mask: radial-gradient(circle 24px at 50% 0, transparent 98%, #000 100%);
  transform: translateY(calc(var(--pull, 0) * 34%));
}
.sleeve::before { content: ''; position: absolute; inset: 10px; border: 1px solid var(--gold); opacity: 0.35; border-radius: 3px 3px 7px 7px; }
.sleeve-stamp {
  font-family: var(--serif); font-style: italic; font-size: 22px; letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, #8b6a30); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.mech-slide.is-out .sleeve { transform: translateY(140%); opacity: 0; transition: transform 0.8s cubic-bezier(.5, 0, .7, .4), opacity 0.8s; }
.mech-slide.is-out .pull-tab { opacity: 0; transition: opacity 0.4s; }
.mech-slide.is-leaving { opacity: 0; }

/* ---------- Notices, footer, demo clock ---------- */
.notice { width: 100%; display: grid; place-items: center; }
.card-notice { aspect-ratio: auto; min-height: 280px; gap: 16px; }
.card-ornament { width: 10px; height: 10px; rotate: 45deg; background: var(--frame); }
.notice-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.1; max-width: 14ch; }
.notice-text { margin: 0; color: var(--paper-muted); max-width: 26ch; }

.footer { text-align: center; padding: 0 16px max(28px, env(safe-area-inset-bottom)); color: var(--muted); }
.footer-note { margin: 0 auto; max-width: 30rem; font-size: 12px; }
.footer-mark { margin: 8px 0 0; font-size: 10px; letter-spacing: 0.4em; text-transform: uppercase; opacity: 0.6; }
body:has(.demo-clock) .footer { padding-bottom: 120px; }

.demo-clock {
  position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 20;
  padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(255, 255, 255, 0.3);
  background: rgba(10, 10, 12, 0.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #e9e9ee;
  font-size: 12px;
}
.demo-clock-label { margin: 0 0 6px; font-weight: 600; letter-spacing: 0.06em; }
.demo-clock-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-clock button {
  min-height: 34px; padding: 4px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06); cursor: pointer; font-size: 12px;
}
.demo-clock button[aria-pressed='true'] { background: #e9e9ee; color: #111; }

.hub-main { max-width: 640px; margin: 0 auto; padding: 56px 16px 64px; }
.hub-title { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 11vw, 64px); line-height: 1; margin: 14px 0 10px; }
.hub-sub { color: var(--muted); margin: 0 0 28px; }
.hub-sub em { font-family: var(--serif); font-size: 20px; color: var(--ink); }
.hub-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.hub-list a {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); text-decoration: none; background: var(--tile);
}
.hub-list a:hover { border-color: var(--gold); }
.hub-list strong { font-family: var(--serif); font-weight: 400; font-size: 22px; }
.hub-list span { color: var(--muted); font-size: 13px; }
.hub-note { color: var(--muted); font-size: 13px; margin-top: 24px; }

/* ---------- Reduced motion: same story, no movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .card { transform: none !important; }
  .card.is-revealed .card-sweep::before { animation: none; }
  .finale { transition: opacity 0.3s ease !important; }
}
