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

:root {
  --ink:        #0c0e14;
  --ink-2:      #151925;
  --ink-3:      #1e2432;
  --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);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, "Segoe UI", Inter, system-ui, sans-serif;

  --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);
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(120% 90% at 50% -10%, #1c2233 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-size: 1.15rem; letter-spacing: 0.06em; 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.16;
}
.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; }

.hint-btn {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--cream-faint);
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--cream-faint);
  padding: 0.15rem 0.2rem;
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.hint-btn:hover:not(:disabled) { color: var(--cream); border-color: var(--cream); }
.hint-btn:disabled { opacity: 0.3; cursor: default; }

/* only glows once there is actually something new to give her */
.hint-btn--ready {
  color: var(--gold);
  border-color: var(--gold);
  animation: hint-breathe 2.6s ease-in-out infinite;
}
@keyframes hint-breathe {
  0%, 100% { opacity: 0.62; }
  50%      { opacity: 1; }
}

.hint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.hint {
  background: rgba(20, 24, 34, 0.92);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold-dim);
  border-radius: 3px;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--cream-dim);
  text-align: right;
  animation: hint-in 0.45s var(--ease) both;
  backdrop-filter: blur(6px);
}
.hint--answer { border-left-color: var(--gold); color: var(--cream); font-style: italic; }
.hint--wait   { border-left-color: transparent; opacity: 0.75; font-style: italic; }
@keyframes hint-in {
  from { opacity: 0; transform: translateY(6px); }
}

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