/* Festive "photo album at a party" styling for the quiz invitation.
   Polaroid photo frames, a 50 sticker, poster-style buttons and confetti.
   Mobile first, light and dark via prefers-color-scheme, no external assets. */

:root {
  --paper: #fbf3e4;
  --card: #fffaf0;
  --ink: #1d2a29;
  --muted: #5a5246;
  --border: #e3d3b6;
  --accent: #c63f22;        /* primary buttons, white text: 5.1:1 */
  --accent-text: #ffffff;
  --link: #1f6f6b;          /* 5.4:1 on paper */
  --gold: #e8a33d;
  --teal: #1f6f6b;
  --ok: #1d7a3e;
  --ok-bg: #e2f3e6;
  --no: #b3261e;
  --no-bg: #fbe2df;
  --photo-frame: #ffffff;
  --shadow: #1d2a29;
  --dot-1: rgba(232, 163, 61, 0.28);
  --dot-2: rgba(198, 63, 34, 0.16);
  --dot-3: rgba(31, 111, 107, 0.16);
  --radius: 14px;
  --maxw: 560px;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: "Seravek", "Avenir Next", Avenir, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10201f;
    --card: #172b2a;
    --ink: #f4ecdc;
    --muted: #b9ae99;
    --border: #2f4644;
    --accent: #f0835f;
    --accent-text: #10201f;
    --link: #f2c66d;
    --gold: #f2c66d;
    --ok: #6fdc95;
    --ok-bg: #15331f;
    --no: #ff9b8f;
    --no-bg: #3b1916;
    --photo-frame: #f4ecdc;
    --shadow: #050c0c;
    --dot-1: rgba(242, 198, 109, 0.14);
    --dot-2: rgba(240, 131, 95, 0.10);
    --dot-3: rgba(143, 193, 181, 0.10);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  background-color: var(--paper);
  /* Scattered confetti dots as the page texture. */
  background-image:
    radial-gradient(circle at 12% 8%, var(--dot-1) 0 5px, transparent 6px),
    radial-gradient(circle at 78% 14%, var(--dot-2) 0 4px, transparent 5px),
    radial-gradient(circle at 42% 38%, var(--dot-3) 0 3px, transparent 4px),
    radial-gradient(circle at 88% 62%, var(--dot-1) 0 4px, transparent 5px),
    radial-gradient(circle at 20% 78%, var(--dot-2) 0 5px, transparent 6px),
    radial-gradient(circle at 60% 92%, var(--dot-3) 0 4px, transparent 5px);
  background-size: 340px 420px;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 18px 56px;
}

h1, h2, .display { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; line-height: 1.1; margin: 0.35em 0 0.25em; }
h2 { font-size: 1.45rem; line-height: 1.2; margin: 0.6em 0 0.35em; }
.display { font-style: italic; }
p { margin: 0.5em 0; }
a { color: var(--link); text-underline-offset: 3px; }
.muted { color: var(--muted); }

.eyebrow {
  display: inline-block;
  margin: 12px 0 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #1d2a29;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- staggered entrance of each view ---- */
.view:not([hidden]) > * { animation: rise 0.5s cubic-bezier(.2,.8,.2,1) both; }
.view:not([hidden]) > *:nth-child(2) { animation-delay: 0.06s; }
.view:not([hidden]) > *:nth-child(3) { animation-delay: 0.12s; }
.view:not([hidden]) > *:nth-child(4) { animation-delay: 0.18s; }
.view:not([hidden]) > *:nth-child(5) { animation-delay: 0.24s; }
.view:not([hidden]) > *:nth-child(n+6) { animation-delay: 0.3s; }
/* Uses the individual translate property so it composes with the rotate
   transforms on the photo frames instead of overriding them. */
@keyframes rise {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}

/* ---- top navigation ---- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topnav[hidden] { display: none; }
.topnav button {
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 0.95rem var(--body);
  cursor: pointer;
}
.topnav button[hidden] { display: none; }
.topnav button.active { background: var(--ink); color: var(--paper); }

/* ---- buttons ---- */
.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  margin: 16px 0 0;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font: 700 1.05rem var(--body);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--card); color: var(--ink); }
.btn:disabled { opacity: 0.6; cursor: default; }

.link-btn {
  display: inline-block;
  min-height: 48px;
  padding: 12px 0;
  background: none;
  border: 0;
  color: var(--link);
  font: 600 1rem var(--body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.top-link { margin-bottom: 4px; }

/* ---- cards and forms ---- */
.card {
  margin: 18px 0;
  padding: 16px 16px 18px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 5px 5px 0 var(--shadow);
}
.card h2:first-child { margin-top: 0; }

label { display: block; margin: 16px 0 6px; font-weight: 700; }
.card > label:first-child, form > label:first-child { margin-top: 0; }
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  font-size: 16px; /* keeps iOS from zooming on focus */
  font-family: inherit;
  padding: 13px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, button:focus-visible, .link-btn:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.field-error { color: var(--no); font-weight: 700; margin-top: 8px; }

.stepper { display: flex; align-items: stretch; gap: 10px; }
.stepper input { text-align: center; max-width: 100px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn {
  min-width: 54px;
  min-height: 54px;
  font-size: 1.5rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

/* honeypot stays out of sight and off the tab order */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- polaroid photo frames ---- */
.polaroid {
  margin: 0;
  padding: 10px 10px 34px;
  background: var(--photo-frame);
  border-radius: 4px;
  box-shadow: 0 2px 0 rgba(0,0,0,.06), 0 14px 30px -12px rgba(0,0,0,.45);
}
.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--border);
  border-radius: 2px;
}

/* ---- start ---- */
.hero { position: relative; margin: 10px 8px 6px; }
.hero-photo { transform: rotate(-2deg); }
.sticker {
  position: absolute;
  right: -6px;
  top: -10px;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--gold) 0 58%, transparent 59%),
    repeating-conic-gradient(var(--accent) 0 10deg, var(--gold) 10deg 20deg);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  transform: rotate(12deg);
  animation: pop 0.6s 0.3s cubic-bezier(.3,1.6,.5,1) both;
}
.sticker span {
  font: italic 700 2.6rem/1 var(--display);
  color: #1d2a29;
}
@keyframes pop {
  from { transform: rotate(-30deg) scale(0.2); opacity: 0; }
  to { transform: rotate(12deg) scale(1); opacity: 1; }
}
.subtitle { color: var(--muted); font-size: 1.08rem; }

/* ---- quiz ---- */
.progress-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.progress-row span { font-weight: 700; white-space: nowrap; }
.progress-bar {
  flex: 1;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(45deg, var(--accent) 0 8px, var(--gold) 8px 16px);
  transition: width 0.3s ease;
}
.quiz-frame { margin: 0 6px; transform: rotate(1.2deg); }
.question { margin-top: 18px; }

.options { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.option {
  min-height: 58px;
  padding: 14px;
  font: 700 1.2rem var(--body);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.option:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.option:disabled { cursor: default; }
.option.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ink); }
.option.wrong { background: var(--no-bg); border-color: var(--no); color: var(--ink); }
.option.correct::after { content: "  ✓"; color: var(--ok); }
.option.wrong::after { content: "  ✗"; color: var(--no); }

.feedback { font-weight: 700; font-size: 1.1rem; margin-top: 16px; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--no); }
.anecdote {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  border-left: 4px solid var(--gold);
  padding-left: 12px;
}

/* ---- score / confirmation ---- */
.score-card {
  position: relative;
  margin: 18px 0;
  padding: 26px 18px 22px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--shadow);
}
.score-card .eyebrow { margin-top: 0; }
.score-headline { font-size: 2.6rem; margin: 0.25em 0; }
.band-text { font-size: 1.15rem; }
.rank-line { font-weight: 700; font-size: 1.1rem; }

/* ---- gallery ---- */
.gallery { display: grid; gap: 30px; margin: 18px 6px 8px; }
.gallery-item:nth-child(odd) { transform: rotate(-1.5deg); }
.gallery-item:nth-child(even) { transform: rotate(1.5deg); }
.gallery-item figcaption { padding: 10px 4px 0; color: #1d2a29; }
.gallery-alt { font: italic 700 1.2rem var(--display); margin: 0 0 2px; }
.gallery-anecdote { color: #5a5246; margin: 2px 0 0; }

/* ---- ranking ---- */
.ranking { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.ranking li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto 4.2em;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
}
.ranking li:nth-child(1) { background: var(--gold); color: #1d2a29; }
.ranking li.me { outline: 3px solid var(--accent); outline-offset: 2px; }
.ranking li.gap { margin-top: 14px; }
.r-rank { font: italic 700 1.3rem var(--display); }
.r-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-score { font-weight: 700; font-size: 1.15rem; }
.r-secs { text-align: right; opacity: 0.8; font-size: 0.9rem; }

/* ---- invitation ---- */
.invitation-text p { font-size: 1.1rem; }
.invitation-text p:first-child::first-letter {
  float: left;
  font: italic 700 3.4rem/0.85 var(--display);
  color: var(--accent);
  margin: 6px 8px 0 0;
}
.inv-when { font-weight: 700; font-size: 1.1rem; margin-top: 0; }

/* ---- confetti ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation-name: fall;
  animation-timing-function: cubic-bezier(.25,.6,.4,1);
  animation-fill-mode: forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), 108vh) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
