/* ============================================================
   WeWhereWhen — "evening photo album" look.
   A dark plum album page; each photo appears as a taped-down
   paper print whose caption is handwritten as you answer.
   ============================================================ */

:root {
  --album: #211a20;        /* page background */
  --album-2: #2b222a;      /* raised surfaces */
  --line: #453843;         /* hairlines on dark */
  --paper: #f6f0e6;        /* photo print paper */
  --paper-ink: #43333c;    /* handwriting on paper */
  --text: #ece2e6;
  --text-dim: #b3a3ab;
  --rose: #e08199;
  --rose-strong: #d5637f;
  --rose-ink: #2b1119;     /* text on rose fills */
  --gold: #d8b271;
  --focus: #ffd9e4;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-hand: "Caveat", "Segoe Script", "Comic Sans MS", cursive;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--album);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 50% at 50% 0%, rgba(224, 129, 153, 0.09), transparent 70%);
}

.hidden { display: none !important; }

/* ---------- top bar ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 6px;
  position: relative;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 1.3rem; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

#hud { display: flex; gap: 10px; }
.hud-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: rgba(43, 34, 42, 0.7);
}
.hud-chip.gold {
  color: var(--gold);
  border-color: rgba(216, 178, 113, 0.4);
  font-variant-numeric: tabular-nums;
}

/* ---------- screens ---------- */

main { position: relative; }

.screen {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 56px;
}

.screen.narrow {
  max-width: 680px;
  text-align: center;
  padding-top: 5vh;
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  line-height: 1.12;
  margin: 0.3em 0 0.4em;
}
h1 em {
  font-style: italic;
  font-weight: 600;
  color: var(--rose);
}

.hand { font-family: var(--font-hand); }

.lede {
  color: var(--text-dim);
  font-size: 1.06rem;
  margin: 0 auto 1.6em;
  max-width: 46ch;
}

.rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 1.6em;
  text-align: left;
}
.rule {
  background: var(--album-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.rule-ico { font-size: 1.4rem; line-height: 1.2; }
.rule b { display: block; font-size: 0.98rem; }
.rule span:not(.rule-ico) { color: var(--text-dim); font-size: 0.88rem; }

.pool-info { color: var(--text-dim); font-size: 0.9rem; margin-top: 1.2em; }
.pool-info.err { color: #e6a17a; }

/* ---------- setup: privacy, pickers, scan ---------- */

.privacy-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  background: rgba(216, 178, 113, 0.07);
  border: 1px solid rgba(216, 178, 113, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 1.6em;
}
.privacy-card span { font-size: 1.3rem; line-height: 1.2; }
.privacy-card p { margin: 0; font-size: 0.92rem; color: var(--text-dim); }
.privacy-card b { color: var(--text); }

.pick-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.2em;
}

.scan-progress { margin: 0 auto 1em; max-width: 420px; }
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--album-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--rose-strong);
  transition: width 0.15s ease;
}
.scan-progress .pool-info { margin-top: 8px; }

.scan-summary {
  margin: 0 auto 1.2em;
  max-width: 460px;
}
.scan-summary p { margin: 3px 0; font-size: 0.92rem; }
.scan-summary p.dim { color: var(--text-dim); font-size: 0.85rem; }

.btn.small { font-size: 0.84rem; padding: 7px 14px; }

.heic-prompt {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.heic-prompt p { margin: 0 0 8px; }
.heic-prompt p.dim { margin: 8px 0 0; color: var(--text-dim); font-size: 0.85rem; }

.setup-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 1.4em;
}

.opt-rounds {
  display: flex;
  gap: 12px;
  align-items: center;
}
.opt-label { color: var(--text-dim); font-size: 0.92rem; }

.custom-range {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
}
.custom-range label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.92rem;
}
.custom-range select {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--album-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.segmented button {
  font: inherit;
  font-size: 0.92rem;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 6px 18px;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.selected {
  background: var(--rose-strong);
  color: var(--rose-ink);
  font-weight: 700;
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 26px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.btn.primary {
  background: var(--rose-strong);
  color: var(--rose-ink);
}
.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(213, 99, 127, 0.35);
}
.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.big { font-size: 1.12rem; padding: 14px 34px; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}
.btn.ghost:hover { color: var(--text); border-color: var(--text-dim); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- round layout ---------- */

.round-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  padding-top: 14px;
}

/* The photo as a taped-down paper print */
.print-side { position: relative; }

.print {
  margin: 8px 0 0;
  background: var(--paper);
  border-radius: 4px;
  padding: 14px 14px 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: rotate(-1.4deg);
  transition: transform 0.25s ease;
  position: relative;
}
.print:hover { transform: rotate(-0.3deg); }

.print::before {
  /* a strip of tape holding the print to the album page */
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(246, 240, 230, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 2px;
}

.print-photo img {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  cursor: zoom-in;
  background: #e9e1d3;
}

.print.developing .print-photo img {
  animation: develop 0.7s ease both;
}
@keyframes develop {
  from { opacity: 0; filter: sepia(0.7) blur(8px); }
  to   { opacity: 1; filter: none; }
}

.print-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 4px;
}
.print-caption.center { justify-content: center; }
.cap {
  font-size: 1.45rem;
  font-weight: 500;
  color: var(--paper-ink);
}
.cap em { font-style: normal; letter-spacing: 0.06em; opacity: 0.55; }
.big-cap { font-size: 1.8rem; font-weight: 700; }

.zoom-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.84rem;
  margin-top: 16px;
}

.version {
  color: var(--text-dim);
  opacity: 0.55;
  font-size: 0.78rem;
  margin-top: 26px;
}

/* ---------- guess panel ---------- */

.panel {
  background: var(--album-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ask h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  margin: 0 0 10px;
}

#map, #reveal-map {
  height: 320px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #16121a;
}

.status {
  color: var(--text-dim);
  font-size: 0.86rem;
  margin: 8px 2px 0;
}
.status.ok { color: var(--rose); }
.status.err { color: #e6a17a; }

.year-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.year-chip {
  font: inherit;
  font-size: 0.92rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.year-chip:hover { border-color: var(--rose); color: var(--text); }
.year-chip.selected {
  background: var(--rose-strong);
  border-color: var(--rose-strong);
  color: var(--rose-ink);
  font-weight: 700;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.month-btn {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 2px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.month-btn:hover:not(:disabled) { border-color: var(--rose); color: var(--text); }
.month-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.month-btn.selected {
  background: var(--rose-strong);
  border-color: var(--rose-strong);
  color: var(--rose-ink);
  font-weight: 700;
}

/* ---------- reveal ---------- */

.scorecards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.scorecard {
  background: rgba(246, 240, 230, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.scorecard h4 {
  margin: 0 0 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.detail { margin: 0 0 8px; font-size: 0.94rem; min-height: 2.6em; }
.points {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.round-total {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--gold);
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}

/* map world-reset control */
.map-reset-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--album-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.map-reset-btn:hover { border-color: var(--rose); }

/* emoji map pins */
.pin-emoji {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}

/* ---------- end screen ---------- */

.end-hero {
  max-width: 680px;
  margin: 5vh auto 34px;
  text-align: center;
}

.end-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.4em;
}
#final-score-line { color: var(--gold); margin-bottom: 0.15em; }

.record-line {
  font-size: 1.55rem;
  color: var(--gold);
  margin: 0 0 0.4em;
}

/* letter grade, stamped on the report card */
.grade-stamp {
  display: inline-grid;
  place-items: center;
  width: 96px;
  height: 74px;
  margin: 4px auto 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.3rem;
  letter-spacing: 0.1em;
  border: 3px solid currentColor;
  border-radius: 12px;
  transform: rotate(-4deg);
  color: var(--gold);
}
.grade-stamp.grade-good { color: var(--gold); }
.grade-stamp.grade-mid { color: var(--rose); }
.grade-stamp.grade-fail { color: #e6a17a; }

.pool-info.best { color: var(--gold); margin-top: 6px; }

/* recap: all rounds on one map + list */

.recap, .history {
  max-width: 940px;
  margin: 0 auto;
}
.history { margin-top: 34px; }

.recap-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  text-align: center;
  margin: 0 0 14px;
}

#recap-map {
  height: 360px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #16121a;
}

.recap-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
}

.recap-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--album-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.12s ease;
}
.recap-item:hover { border-color: var(--rose); }

.recap-num {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-dim);
  min-width: 1.3em;
  text-align: center;
}

.recap-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: #e9e1d3;
  cursor: zoom-in;
  flex-shrink: 0;
}

.recap-meta { min-width: 0; }
.recap-meta b { display: block; font-size: 0.96rem; }
.recap-meta span { color: var(--text-dim); font-size: 0.83rem; }

.recap-pts {
  margin-left: auto;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold);
  font-size: 1.05rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* numbered map pins */
.recap-pin-wrap { background: none; border: none; }
.recap-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--rose-strong);
  color: var(--rose-ink);
  font-weight: 700;
  font-size: 13px;
  border: 2px solid rgba(246, 240, 230, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* score history */

.score-history {
  list-style: none;
  max-width: 460px;
  margin: 0 auto;
  padding: 0;
}
.history-best {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold);
  font-size: 1.15rem;
  text-align: center;
  padding: 2px 0 10px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 2px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.history-item.current { color: var(--rose); }

/* ---------- footer ---------- */

#pagefoot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 24px 26px;
  text-align: center;
}
#pagefoot p {
  color: var(--text-dim);
  opacity: 0.7;
  font-size: 0.8rem;
  margin: 0;
}

/* ---------- lightbox ---------- */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(18, 12, 17, 0.93);
  display: grid;
  place-items: center;
  cursor: zoom-out;
}
#lightbox img {
  max-width: 93vw;
  max-height: 93vh;
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .round-grid { grid-template-columns: 1fr; gap: 22px; }
  .print { transform: none; }
  .print:hover { transform: none; }
  #map, #reveal-map { height: 260px; }
  #recap-map { height: 280px; }
  .recap-list { grid-template-columns: 1fr; }
  .rules { grid-template-columns: 1fr; }
  .month-grid { grid-template-columns: repeat(4, 1fr); }
  .print-photo img { max-height: 48vh; }
}

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