@font-face { font-family: "Caveat"; src: url("fonts/caveat-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("fonts/caveat-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #070605;
  --paper: #eee2c1;
  --pen: #1f3a8c;          /* ballpoint blue, handwriting */
  --pen-hover: #0f2266;
  --print: #6b7ca3;        /* printed postcard marks: divider, stamp box, postmark, lines */
  --qr: #1a2442;
  --card-ratio: 1650 / 1048;
  --card-w: min(88vw, calc((100svh - 15rem) * 1.5744), 770px);
  --flip: 1.15s;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
body { overflow: hidden; color: #ddd; -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- background: a dark room, one weak lamp, a little dust, film grain ---------- */
.bg, .bg > div { position: fixed; inset: 0; pointer-events: none; }
.bg { z-index: 0; }
.bg__light {
  background:
    radial-gradient(ellipse 62% 54% at 50% 48%, rgba(215, 225, 245, .06), rgba(215, 225, 245, .02) 48%, transparent 74%);
  animation: lamp 13s linear infinite;
}
.bg__dust {
  inset: -6%;
  background-image:
    radial-gradient(circle at 9% 24%,  rgba(235, 240, 250, .5) 0 .7px, transparent 1.4px),
    radial-gradient(circle at 21% 71%, rgba(235, 240, 250, .35) 0 .6px, transparent 1.3px),
    radial-gradient(circle at 33% 12%, rgba(235, 240, 250, .4) 0 .8px, transparent 1.5px),
    radial-gradient(circle at 44% 88%, rgba(235, 240, 250, .3) 0 .6px, transparent 1.3px),
    radial-gradient(circle at 58% 33%, rgba(235, 240, 250, .45) 0 .7px, transparent 1.4px),
    radial-gradient(circle at 67% 79%, rgba(235, 240, 250, .35) 0 .8px, transparent 1.5px),
    radial-gradient(circle at 78% 18%, rgba(235, 240, 250, .4) 0 .6px, transparent 1.3px),
    radial-gradient(circle at 86% 57%, rgba(235, 240, 250, .5) 0 .7px, transparent 1.4px),
    radial-gradient(circle at 93% 90%, rgba(235, 240, 250, .3) 0 .6px, transparent 1.3px),
    radial-gradient(circle at 15% 47%, rgba(235, 240, 250, .3) 0 .7px, transparent 1.4px);
  opacity: .55;
  animation: drift 90s ease-in-out infinite alternate;
}
.bg > .bg__grain { inset: -50%; background: url("assets/grain.svg") 0 0 / 280px; opacity: .17; animation: grain .9s steps(1) infinite; }
.bg__vignette { background: radial-gradient(ellipse at 50% 46%, transparent 42%, rgba(0, 0, 0, .8) 100%); }

@keyframes grain {   /* ~9 fps shimmer, small shifts: reads as film grain, not TV static */
  0%   { transform: translate(0, 0); }
  12%  { transform: translate(-1.5%, 1%); }
  25%  { transform: translate(1%, -2%); }
  37%  { transform: translate(-2%, -1%); }
  50%  { transform: translate(2%, 1.5%); }
  62%  { transform: translate(-1%, 2%); }
  75%  { transform: translate(1.5%, -1%); }
  87%  { transform: translate(-2%, 0); }
}
@keyframes lamp {    /* the bulb is a little tired */
  0%, 100% { opacity: 1; }
  30%   { opacity: 1; }   30.4% { opacity: .72; }  31.2% { opacity: .97; }  31.8% { opacity: .84; }  32.6% { opacity: 1; }
  70%   { opacity: 1; }   70.5% { opacity: .8; }   71.4% { opacity: 1; }
}
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(2.5vw, -4vh); } }

/* ---------- stage ---------- */
.stage { position: relative; z-index: 1; height: 100svh; display: grid; place-items: center; padding-bottom: 2.5rem; }
.scene { --lay: rotateZ(-1.4deg); position: relative; width: var(--card-w); perspective: 1900px; cursor: pointer; }
.tilt  { position: relative; transform: var(--lay); transform-style: preserve-3d; }
.shadow {   /* the card's shadow lies on the table: its own flat layer, always painted behind the card */
  position: absolute; inset: 1.5% -.5% -2.5% 1.2%; z-index: -1; background: #000; border-radius: 8px;
  filter: blur(20px); opacity: .85; transform: var(--lay); pointer-events: none;
  transition: opacity var(--flip) ease, filter var(--flip) ease;
}
.tilt.is-flipping + .shadow { opacity: .5; filter: blur(36px); }
.tilt.is-flipping { animation: lift var(--flip) cubic-bezier(.45,.05,.2,1); }
@keyframes lift {   /* picked up, turned, put back down */
  0%   { transform: rotateZ(-1.4deg) translateZ(0); }
  45%  { transform: rotateZ(-1.4deg) translateZ(150px); }
  100% { transform: rotateZ(-1.4deg) translateZ(0); }
}

.card {
  position: relative; width: 100%; aspect-ratio: var(--card-ratio);
  transform-style: preserve-3d;
  transition: transform var(--flip) cubic-bezier(.45,.05,.2,1);
}
.card.is-flipped { transform: rotateY(180deg); }
@media (hover: hover) {
  /* hover target is the static .scene, not the rotating card, so the tilt can't move the card out from under the cursor */
  .scene:hover .card:not(.is-flipped) { transform: rotateY(-6deg); }
}

.face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  border-radius: .4cqw;
  box-shadow: 0 0 0 1px rgba(255,255,255,.05), 0 1px 3px rgba(0,0,0,.7);
  container-type: inline-size;
}
.face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: url("assets/wear.svg") 0 0 / 100% 100%; pointer-events: none; }
.front { cursor: pointer; overflow: hidden; }
.front img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.front:focus-visible, .back:focus-visible { outline: 2px solid #b8402a; outline-offset: 6px; }
.back { transform: rotateY(180deg); cursor: pointer; background: var(--paper); outline: none; }

/* ---------- back of the postcard ---------- */
.paper {
  position: absolute; inset: 0; border-radius: inherit;
  background:
    radial-gradient(ellipse at 28% 18%, rgba(255,255,255,.40), transparent 62%),
    url("assets/paper.svg") 0 0 / 70% auto,
    var(--paper);
  box-shadow: inset 0 0 5cqw rgba(110, 80, 30, .38), inset 0 0 .6cqw rgba(90, 60, 20, .5);
}
.back > *:not(.paper) { position: absolute; }

.hand { font-family: var(--hand); font-weight: 500; color: var(--pen); line-height: 1.05; margin: 0; }
.note { left: 6.5cqw; top: 6cqw; font-size: 6.4cqw; transform: rotate(-2.5deg); transform-origin: left top; }

.qr { margin: 0; left: 7cqw; top: 26.5cqw; width: 40cqw; height: 21cqw; }
.qr__code { position: absolute; left: 0; top: 0; width: 21cqw; height: 21cqw; }
.qr__code svg { display: block; width: 100%; height: 100%; }
.qr__code path { fill: var(--qr); }
.qr__cap { position: absolute; left: 23cqw; top: 7cqw; font-size: 3.6cqw; transform: rotate(-4deg); white-space: nowrap; }

.divider {
  left: 50cqw; top: 6cqw; width: .45cqw; height: 51.5cqw;
  background: linear-gradient(180deg, var(--print) 0 21%, transparent 21% 21.7%, var(--print) 21.7% 58%, transparent 58% 58.5%, var(--print) 58.5% 83%, transparent 83% 83.6%, var(--print) 83.6%);
  opacity: .85;
}

.stamp { right: 5.5cqw; top: 4.5cqw; width: 9cqw; height: 12.5cqw; border: .32cqw dashed var(--print); opacity: .8; }
.postmark { left: 62cqw; top: 3cqw; width: 32cqw; height: auto; overflow: visible; }
.pm { fill: none; stroke: var(--print); stroke-width: 1.6; opacity: .78; }
.pm circle:last-of-type { stroke-width: 1.2; }
.pm__t { font: 700 12px var(--mono); letter-spacing: 0; fill: var(--print); stroke: none; }
.pm__c { font: 700 17px var(--mono); letter-spacing: 2px; fill: var(--print); stroke: none; }

.row { left: 55.5cqw; width: 38.5cqw; height: 7cqw; display: flex; align-items: flex-end; padding-bottom: .5cqw; }
.row::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: .32cqw;
  background: linear-gradient(90deg, var(--print) 0 17%, transparent 17% 18%, var(--print) 18% 63%, transparent 63% 64.4%, var(--print) 64.4% 90%, transparent 90% 91%, var(--print) 91%);
  opacity: .8;
}
.row--1 { top: 21cqw; width: 31cqw; }
.row--1, .row--2 { }
.row--2 { top: 28.5cqw; }
.row--3 { top: 36cqw; }
.row--4 { top: 45.5cqw; }
.row--4::after { height: .5cqw; }
.row--4 .hand { font-size: 5cqw; }

.link { white-space: nowrap; text-decoration: none; transition: color .15s, transform .15s; display: inline-block; transform-origin: left bottom; }
.hand--head { font-size: 5.4cqw; font-weight: 500; transform: rotate(-1.5deg); transform-origin: left bottom; }
.hand--big { font-size: 6.8cqw; font-weight: 700; transform: rotate(-1deg); }
.arrow { position: absolute; left: 20.5cqw; top: .4cqw; width: 4.3cqw; height: 5.7cqw; overflow: visible; fill: none; stroke: var(--pen); stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; }
.row--3 .link--small { font-size: 4.4cqw; }
.link:hover { color: var(--pen-hover); text-decoration: underline wavy; text-decoration-thickness: .2cqw; text-underline-offset: .5cqw; }
.link:focus-visible { outline: 2px solid var(--pen); outline-offset: 3px; border-radius: 2px; }

.flip-back {
  left: 2cqw; bottom: 1.5cqw; padding: .6cqw 1.2cqw; font: 500 3cqw var(--hand); color: var(--pen);
  background: var(--paper); border: 1px solid var(--pen); border-radius: 3px; cursor: pointer;
  clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}
.flip-back:focus-visible { clip-path: none; width: auto; height: auto; overflow: visible; }

/* ---------- ARG touches ---------- */
.ps { left: 6.5cqw; top: 50.3cqw; margin: 0; font: 500 3.15cqw var(--hand); color: #38363d; opacity: .78; transform: rotate(-1.2deg); transform-origin: left top; white-space: nowrap; }
.stain {
  left: 29.5cqw; top: 43.5cqw; width: 17cqw; height: 15cqw; pointer-events: none; mix-blend-mode: multiply; transform: rotate(-14deg);
  background: radial-gradient(ellipse at center, transparent 56%, rgba(112, 70, 26, .26) 61%, rgba(112, 70, 26, .13) 68%, transparent 73%);
  -webkit-mask-image: conic-gradient(from 20deg, #000 0 62%, transparent 62% 68%, #000 68% 100%);
          mask-image: conic-gradient(from 20deg, #000 0 62%, transparent 62% 68%, #000 68% 100%);
}

/* ---------- hint ---------- */
.hint {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: max(1.6rem, env(safe-area-inset-bottom));
  margin: 0; text-align: center; font: 400 .72rem var(--mono); letter-spacing: .32em; text-transform: uppercase;
  color: rgba(225, 215, 195, .62); animation: breathe 3.6s ease-in-out infinite; pointer-events: none;
}
.hint [data-state="back"] { display: none; }
body.is-flipped .hint [data-state="front"] { display: none; }
body.is-flipped .hint [data-state="back"]  { display: inline; }
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }

.noscript { position: fixed; z-index: 3; inset: auto 0 3rem; text-align: center; font: .9rem var(--mono); color: #aaa; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  .stage { padding-bottom: 3rem; }
  .hint { font-size: .66rem; letter-spacing: .26em; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .tilt { transition-duration: .01s; }
  .tilt.is-flipping { animation: none; }
  .bg__grain, .bg__light, .bg__dust, .hint { animation: none; }
  .tilt.is-flipping { animation: none; }
  .hint { opacity: .6; }
}
