/* ── Golden Ticket Hunt — chocolatier's parlor ──────────────────────
   Cocoa pinstripes, cream envelopes with wax seals on a marble
   ledge, layered gold-foil ticket, warm amber lamp vignette. */

:root {
  --cocoa: #33201a;
  --cocoa-deep: #1f120e;
  --cream: #f3e7d3;
  --cream-bright: #fbf4e6;
  --burgundy: #7c2230;
  --gold: #c9992e;
  --gold-hi: #f3d267;
  --ink: #3a2a22;
  --ink-soft: #8a7668;
  --line: rgba(58, 42, 34, 0.16);
  --err: #b83a3a;
  --font-serif: 'Playfair Display', serif;
  --font-body: 'Lora', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(90% 60% at 50% 20%, rgba(243, 210, 103, 0.09), transparent 70%),
    repeating-linear-gradient(90deg, rgba(243, 231, 211, 0.04) 0 2px, transparent 2px 26px),
    linear-gradient(180deg, var(--cocoa) 0%, var(--cocoa-deep) 100%);
  background-attachment: fixed;
  color: var(--cream);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.page { display: flex; flex-direction: column; min-height: 100vh; }

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 20px; }

main { flex: 1 0 auto; padding-bottom: 70px; }

/* ── Hero ─────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 52px 0 24px; }

.kicker {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold-hi);
  margin-bottom: 14px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.3rem, 9vw, 3.5rem);
  line-height: 1.06;
}

.hero .sub { margin-top: 12px; color: rgba(243, 231, 211, 0.75); font-style: italic; }

/* ── Notes ────────────────────────────────────────────────────────── */
.note {
  margin: 18px 0;
  padding: 16px 20px;
  border-radius: 10px;
  background: rgba(243, 231, 211, 0.08);
  border: 1px solid rgba(201, 153, 46, 0.4);
  text-align: center;
}

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--cream-bright);
  color: var(--ink);
  border-radius: 12px;
  border: 1px solid rgba(201, 153, 46, 0.5);
  padding: 28px 26px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.card h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 18px;
}

/* Fields */
.field { margin-bottom: 14px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease;
}

input:focus { outline: none; border-color: var(--gold); }
input.error { border-color: var(--err); }
input::placeholder { color: var(--ink-soft); opacity: 0.7; }

.fine { margin-top: 12px; text-align: center; color: var(--ink-soft); font-size: 0.88rem; font-style: italic; }

.form-error { color: var(--err); font-weight: 600; text-align: center; margin-top: 12px; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  line-height: 1.2;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(120deg, var(--burgundy), #5b1722);
  color: var(--cream-bright);
  box-shadow: 0 6px 0 #3d0e16;
}

.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 0 #3d0e16; }

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 20px;
}

.btn-block { width: 100%; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(251, 244, 230, 0.4);
  border-top-color: var(--cream-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Envelope wall ────────────────────────────────────────────────── */
.pick-line {
  text-align: center;
  color: rgba(243, 231, 211, 0.8);
  margin-bottom: 22px;
  font-style: italic;
}

.pick-line strong { color: var(--gold-hi); font-style: normal; }

.envelope-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.envelope {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, var(--cream-bright) 0%, var(--cream) 100%);
  border: 1px solid rgba(58, 42, 34, 0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

/* flap */
.envelope::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(180deg, #ece0c8, var(--cream));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-bottom: 1px solid rgba(58, 42, 34, 0.15);
}

.envelope .seal {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #a03446, var(--burgundy) 70%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.envelope:hover:not(:disabled),
.envelope:focus-visible {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--gold);
}

.envelope:disabled { cursor: default; opacity: 0.4; }

.envelope.chosen {
  opacity: 1;
  animation: sealbreak 1.4s ease forwards;
}

@keyframes sealbreak {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.1) rotate(2deg); }
  60%  { transform: scale(1.05) rotate(-2deg); filter: brightness(1.25); }
  100% { transform: scale(1.12); filter: brightness(1.6) drop-shadow(0 0 26px rgba(243, 210, 103, 0.9)); }
}

.ledge {
  height: 14px;
  margin-top: 26px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.05)),
    #cfc5bb;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}

/* ── Result ───────────────────────────────────────────────────────── */
.result-card { text-align: center; margin-top: 12px; }

.gold-ticket {
  display: inline-block;
  margin-bottom: 16px;
  padding: 18px 34px;
  background: linear-gradient(115deg, #a97e1f 0%, var(--gold-hi) 30%, #e8bf4e 50%, var(--gold-hi) 70%, #a97e1f 100%);
  border-radius: 8px;
  border: 2px solid #8a6717;
  transform: rotate(-3deg);
  box-shadow: 0 12px 30px rgba(201, 153, 46, 0.45);
}

.ticket-word {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.24em;
  color: #5b4310;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.result-kicker {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.lose-kicker { color: var(--ink-soft); }

.result-card h2 { font-family: var(--font-serif); font-weight: 700; font-size: 1.7rem; }

.code-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 6px;
  flex-wrap: wrap;
}

.code {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  background: var(--cocoa-deep);
  color: var(--gold-hi);
  padding: 10px 22px;
  border-radius: 6px;
}

.qr-wrap { margin: 16px 0 6px; }

.qr-wrap img { width: 150px; height: 150px; border-radius: 6px; border: 4px solid var(--cocoa-deep); }

.qr-note { color: var(--ink-soft); font-size: 0.88rem; margin-top: 8px; }

.expiry { color: var(--burgundy); font-weight: 600; font-size: 0.9rem; margin-top: 12px; }

.result-note { color: var(--ink-soft); margin-top: 12px; font-size: 0.92rem; }

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 24px 20px;
  color: rgba(243, 231, 211, 0.55);
  font-size: 0.85rem;
}

#wbx-powered-by-slot { margin-top: 12px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .envelope-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}

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