/* Base tokens, the canvas layer, the stamp rail fallback, hints, curtains. */

/* Caveat — the handwriting. Vendored (no CDN, same rule as three.js).
   Variable weight 400-700, latin + latin-ext (the hints speak German). */
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/caveat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/caveat-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* the desk (dark) */
  --ink:        #0d0d0e;      /* legacy name: the dark backdrop (neutral grey, not blue) */
  --ink-2:      #161617;
  --ink-3:      #202022;
  --cream:      #f4efe4;
  --cream-dim:  rgba(244, 239, 228, 0.62);
  --cream-faint:rgba(244, 239, 228, 0.30);
  --gold:       #dfae63;
  --gold-dim:   rgba(223, 174, 99, 0.30);
  --rose:       #c47180;
  --line:       rgba(244, 239, 228, 0.14);

  /* the stationery (light) — postal paper the UI is printed on */
  --paper:      #f1e9d6;
  --paper-2:    #e7dcc3;
  --sepia:      #33291f;                  /* writing ink on paper */
  --ink-soft:   rgba(51, 41, 31, 0.68);   /* sepia ink, dimmed */
  --ink-faint:  rgba(51, 41, 31, 0.38);
  --post-red:   #a53c2c;                  /* postmark / wrong-answer red */
  --post-blue:  #35518c;                  /* airmail blue */
  --wax:        #8e2f23;                  /* sealing wax, primary buttons */

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, "Segoe UI", Inter, system-ui, sans-serif;
  --hand:  "Caveat", "Segoe Script", "Bradley Hand", cursive;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow-card: 0 30px 80px -20px rgba(0, 0, 0, 0.75), 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* paper text uses this; game.css sets it per component */
.stage--card, .round-result { --text: #33291f; }

* { box-sizing: border-box; }

::selection { background: rgba(165, 60, 44, 0.28); }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 90% at 50% -10%, #232324 0%, var(--ink-2) 42%, var(--ink) 100%);
  color: var(--cream);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* a faint paper grain over the whole thing, so the dark never looks like flat #000 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'>\
<filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/></filter>\
<rect width='120' height='120' filter='url(%23n)'/></svg>");
}

/* ------------------------------------------------------------------ canvas */

#envelope-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  /* Nothing in the scene is interactive, and Street View lives underneath it
     during the rounds, so the canvas must never eat a click. */
  pointer-events: none;
}

body.no-webgl #envelope-canvas { display: none; }

/* ---------------------------------------------------- curtains (load/fatal) */

.curtain {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-content: center;
  gap: 0.6rem;
  text-align: center;
  background: var(--ink);
  transition: opacity 0.6s var(--ease);
}
.curtain[hidden] { display: none; }
.curtain__text { font-family: var(--hand); font-size: 1.6rem; letter-spacing: 0.02em; color: var(--cream-dim); margin: 0; }
.curtain__sub  { font-size: 0.9rem; color: var(--cream-faint); margin: 0; }

/* ------------------------------------------- DOM stamp rail (no-WebGL path) */

.dom-rail {
  position: fixed;
  z-index: 3;
  top: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border-radius: 4px;
  background: linear-gradient(160deg, #e6dcc6, #d6cbb2);
  box-shadow: var(--shadow-card);
  max-width: min(94vw, 900px);
  flex-wrap: wrap;
  justify-content: center;
}
body.no-webgl .dom-rail { display: flex; }

.dom-stamp {
  position: relative;
  margin: 0;
  width: 74px;
  transform: rotate(var(--tilt));
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  opacity: 0;                    /* invisible until earned, like the 3D rail */
}
.dom-stamp img { width: 100%; display: block; }
.dom-stamp__mark {
  position: absolute;
  inset: -14% -14% auto auto;
  width: 86%;
  opacity: 0;
  transition: opacity 0.5s var(--ease) 0.12s;
}
.dom-stamp.earning { transform: rotate(var(--tilt)) scale(2.2); opacity: 1; }
.dom-stamp.earned  { transform: rotate(var(--tilt)) scale(1); opacity: 1; }
.dom-stamp.earned .dom-stamp__mark { opacity: 0.8; }

/* ------------------------------------------------------------------- hints */

.hint-dock {
  position: fixed;
  z-index: 30;
  right: 1.6rem;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  max-width: min(30rem, 42vw);
}
.hint-dock[hidden] { display: none; }

/* Solid red on purpose -- hints have no unlock timer, so the button must be
   findable the moment she wants one, not discovered by accident. */
.hint-btn {
  font-family: var(--hand);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: #e2543f;
  background: none;
  border: 0;
  border-bottom: 1px dashed #e2543f;
  padding: 0.15rem 0.2rem;
  cursor: pointer;
  transform: rotate(-1.2deg);
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.hint-btn:hover:not(:disabled) { color: #ff7a63; border-color: #ff7a63; }
.hint-btn:disabled { opacity: 0.3; cursor: default; }
@keyframes hint-breathe {
  0%, 100% { opacity: 0.62; }
  50%      { opacity: 1; }
}

/* Hints are scraps of paper he scribbled on, taped up one under the other. */
.hint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; justify-items: end; }
.hint {
  position: relative;
  background: linear-gradient(172deg, var(--paper), var(--paper-2));
  border-radius: 3px 5px 3px 6px;
  padding: 0.75rem 1rem 0.65rem;
  font-family: var(--hand);
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--sepia);
  text-align: right;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: hint-in 0.45s var(--ease) both;
}
.hint:nth-child(odd)  { transform: rotate(-0.7deg); }
.hint:nth-child(even) { transform: rotate(0.6deg); }
/* the bit of tape holding the scrap up */
.hint::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 3rem;
  height: 14px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(250, 246, 235, 0.5);
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.hint--answer { color: var(--post-red); }
.hint--wait   { opacity: 0.8; font-size: 1.1rem; color: var(--ink-soft); }
@keyframes hint-in {
  from { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.08s !important; }
}
