/* ============================================================
   WLTRS — design system
   Palette: paper #F6F7F9 · surface #FFF · ink #101828 ·
   muted #667085 · accent #4338CA · border #E4E7EC
   Type: Space Grotesk (display/numbers) + Inter (body)
   Signature: the perforated ticket card.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --ink: #101828;
  --muted: #667085;
  --accent: #4338CA;
  --accent-soft: #EEF0FE;
  --success: #067647;
  --success-soft: #ECFDF3;
  --warn: #B54708;
  --warn-soft: #FFFAEB;
  --danger: #B42318;
  --danger-soft: #FEF3F2;
  --border: #E4E7EC;
  --radius: 14px;
  --display: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
}

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

body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 420px;
}

/* ---------- brand ---------- */
.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}
.wordmark .tag {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  vertical-align: 2px;
  margin-left: 6px;
}

/* ---------- views & cards ---------- */
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  text-align: center;
}
.card + .card { margin-top: 14px; }

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 4px;
}
.subtitle { color: var(--muted); margin-bottom: 20px; }
.intro-text, .hint-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

/* ---------- signature: the perforated ticket card ---------- */
.ticket-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  text-align: center;
  /* perforation dots down each edge, like a torn raffle stub */
  background-image:
    radial-gradient(circle at 0 50%, var(--paper) 5px, transparent 5.5px),
    radial-gradient(circle at 100% 50%, var(--paper) 5px, transparent 5.5px);
  background-size: 100% 18px;
  background-repeat: repeat-y;
}
.ticket-card .perf {
  border-top: 1.5px dashed var(--border);
  margin: 16px -8px;
}

.ticket-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 14px;
}
.ticket-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.ticket-count {
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 3.4rem;
  line-height: 1;
}
.ticket-count.earned { color: var(--ink); }
.ticket-count.max { color: var(--muted); font-size: 1.6rem; font-weight: 600; }
.ticket-divider { color: var(--border); font-size: 1.8rem; }

/* ---------- buttons ---------- */
.btn {
  display: block;
  width: 100%;
  font-family: var(--body);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #3730A3; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.btn + .btn { margin-top: 10px; }

.btn-back {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.btn-back:hover { background: var(--paper); }

/* ---------- scanner ---------- */
#qr-reader { margin: 16px 0; }
#qr-reader video {
  border-radius: 12px;
  width: 100% !important;
  border: 1px solid var(--border);
}

/* ---------- status messages ---------- */
.status {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  display: none;
  border: 1px solid transparent;
}
.status.success { background: var(--success-soft); color: var(--success); border-color: #ABEFC6; display: block; }
.status.error   { background: var(--danger-soft);  color: var(--danger);  border-color: #FECDCA; display: block; }
.status.info    { background: var(--accent-soft);  color: var(--accent);  border-color: #C7D2FE; display: block; }
.status.warning { background: var(--warn-soft);    color: var(--warn);    border-color: #FEDF89; display: block; }

/* ---------- spinner ---------- */
.spinner {
  display: none;
  margin: 18px auto;
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- stopwatch ring ---------- */
.stopwatch-container {
  position: relative;
  width: 210px; height: 210px;
  margin: 4px auto 12px;
}
.stopwatch-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.progress-bg { fill: none; stroke: var(--border); stroke-width: 9; }
.progress-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear;
}
.stopwatch-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.stopwatch-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.stopwatch-time {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 700;
  margin: 2px 0;
}

/* ---------- session status line ---------- */
.session-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
}
.session-status.active  { background: var(--accent-soft); color: var(--accent); }
.session-status.success { background: var(--success-soft); color: var(--success); }
.session-status.ended   { background: var(--paper); color: var(--muted); border: 1px solid var(--border); }

/* ---------- checkout form ---------- */
.checkout-form { text-align: left; margin: 4px 0; }
.checkout-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 14px 0 5px;
}
.checkout-form input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--body);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.checkout-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.consent-text {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 14px 0;
  text-align: left;
  line-height: 1.5;
}

/* ---------- kiosk (exit screen) ---------- */
.kiosk { max-width: 520px; text-align: center; }
.qr-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: inline-block;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.qr-frame img { display: block; width: min(70vw, 380px); height: auto; }
.rotate-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  margin: 18px auto 8px;
  max-width: 380px;
  overflow: hidden;
}
.rotate-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s linear;
}
.kiosk .error { color: var(--danger); font-weight: 600; margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .progress-fg { transition: none; }
  .btn, .btn:active { transition: none; transform: none; }
}
