/* Keep Searching — styles */

:root {
  --purple: #56247F;
  --purple-deep: #3F1562;
  --purple-card: #7A5399;
  --purple-tint: #CDB9DD;
  --paper: #F6F6F6;
  --ink: #141414;
  --ink-soft: #3A3A3A;
  --gold: #F2CF6B;
  --wrong: #E03A5B;
  --white: #FFFFFF;

  --ui: 'Barlow Condensed', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --body: 'Barlow', 'Helvetica Neue', Arial, sans-serif;

  --gutter: clamp(12px, 2.2vw, 28px);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--purple);
  color: var(--white);
  font-family: var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--white); color: var(--purple); padding: 8px 12px; border-radius: 8px; z-index: 50; font-family: var(--ui); text-transform: uppercase; letter-spacing: .08em; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(var(--gutter) * .9) var(--gutter) calc(var(--gutter) * .5);
}
.lockup { color: var(--white); text-decoration: none; justify-self: start; line-height: 1; }
.lockup-pre { display: block; font-family: var(--ui); font-weight: 500; font-size: 12px; letter-spacing: .02em; opacity: .9; margin-bottom: 4px; }
.lockup-name { display: block; font-family: var(--ui); font-weight: 700; font-size: 18px; line-height: .98; text-transform: uppercase; letter-spacing: .01em; }
.lockup-name sup { font-size: .45em; vertical-align: top; }

.meter { display: flex; align-items: baseline; gap: 10px; justify-self: center; white-space: nowrap; }
.amount { font-family: var(--ui); font-weight: 700; font-size: clamp(40px, 5.4vw, 64px); line-height: 1; letter-spacing: .005em; font-variant-numeric: tabular-nums; }
.amount-label { font-family: var(--body); font-size: 13px; opacity: .9; }

.actions { display: flex; gap: 8px; justify-self: end; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .12em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  line-height: 1;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.btn-light { background: rgba(255,255,255,.14); color: var(--white); border-color: rgba(255,255,255,.55); }
.btn-light:hover { background: rgba(255,255,255,.24); }
.btn-icon { padding: 10px 11px; }

.btn-ghost { background: rgba(255,255,255,.14); color: var(--white); border-color: rgba(255,255,255,.4); padding: 8px 18px; font-size: 13px; }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.24); }

.btn-primary { background: var(--purple); color: var(--white); border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-deep); border-color: var(--purple-deep); }
.btn-big { padding: 14px 28px; font-size: 16px; }

/* ---------- "Keep Searching" set as a wordmark inside a line ---------- */
.ks {
  font-family: var(--ui);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.18em;
  line-height: 1;
}
.btn .ks { margin-left: -3px; }
.menu a .ks { font-size: 1.12em; }

/* ---------- dropdown ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--purple-deep);
  list-style: none; margin: 0; padding: 8px 0;
  min-width: 230px;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  display: none;
  z-index: 30;
}
.menu-wrap.open .menu { display: block; }
.menu a {
  display: block; padding: 12px 18px;
  color: var(--white); text-decoration: none;
  font-family: var(--ui); font-weight: 600; font-size: 17px; letter-spacing: .02em;
}
.menu a:hover, .menu a:focus-visible { background: rgba(255,255,255,.12); outline: none; }

/* ---------- board ---------- */
.stage { padding: 0 var(--gutter); flex: 1; }
.board-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  background: var(--paper);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}
.board-stack { position: relative; }
.board {
  --cell: 24px;
  --cols: 42;
  display: flex;
  flex-direction: column;
  width: calc(var(--cell) * var(--cols));
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  color: var(--ink);
  font-family: var(--ui);
  font-weight: 600;
  font-size: calc(var(--cell) * .66);
  line-height: 1;
  position: relative;
  z-index: 2;
}
.board:focus-within { outline: none; }
.row { display: flex; }
.cell {
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  position: relative;
}
.cell:focus-visible { outline: 2px solid var(--purple); outline-offset: -2px; }
.cell.anchor { color: var(--purple); font-weight: 700; }
.cell.found { color: var(--purple-deep); font-weight: 700; }
.cell.hint { animation: hintPulse 3.2s ease-out; color: var(--purple); font-weight: 700; }
@keyframes hintPulse {
  0% { background: rgba(86,36,127,.0); box-shadow: 0 0 0 0 rgba(86,36,127,.55); }
  15% { background: rgba(86,36,127,.22); box-shadow: 0 0 0 10px rgba(86,36,127,0); }
  100% { background: rgba(86,36,127,.0); box-shadow: 0 0 0 0 rgba(86,36,127,0); }
}

.overlay { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; }
.line { stroke-linecap: round; fill: none; }
.line-preview { stroke: rgba(86,36,127,.22); }
.line-answer { stroke: rgba(242,207,107,.78); animation: pop .5s ease-out; }
.line-wrong { stroke: rgba(224,58,91,.28); }
.line-wrong.flash { animation: fade .65s ease-out forwards; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- controls ---------- */
.controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--gutter) * .6) var(--gutter);
  gap: 10px;
}
.controls-left, .controls-right { display: flex; gap: 8px; }

.credit { text-align: center; font-size: 12px; opacity: .72; margin: 0 var(--gutter) var(--gutter); }
.credit a { color: inherit; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(86,36,127,.42);
  backdrop-filter: blur(10px) saturate(.9);
  -webkit-backdrop-filter: blur(10px) saturate(.9);
}
.modal.open { display: flex; }
.modal-card {
  position: relative;
  width: min(560px, 100%);
  background: var(--purple-card);
  color: var(--white);
  border-radius: 12px;
  padding: 36px 32px 30px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  animation: rise .35s ease-out;
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.modal-card-wide { width: min(680px, 100%); text-align: left; }
.modal-card-wide .modal-title { text-align: left; }
.modal-card-wide .modal-row { justify-content: flex-start; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title {
  font-family: var(--ui); font-weight: 700; text-transform: uppercase;
  font-size: clamp(28px, 4.6vw, 40px); line-height: .98; letter-spacing: .02em;
  margin: 0 0 14px;
}
.modal-copy { font-size: 15px; line-height: 1.5; margin: 0 0 18px; opacity: .95; }
.modal-copy strong { font-weight: 600; }
.modal-prose p { margin: 0 0 12px; }
.modal-how { font-size: 13px; line-height: 1.45; opacity: .8; margin: 0 0 22px; }
.modal-how span { display: block; }
.how-touch { display: none !important; }
@media (pointer: coarse) { .how-desktop { display: none !important; } .how-touch { display: block !important; } .how-kbd { display: none !important; } }
.modal-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.modal-fine { font-size: 11.5px; opacity: .7; margin: 18px 0 0; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: 0; color: var(--white); font-size: 28px; line-height: 1;
  cursor: pointer; width: 36px; height: 36px; border-radius: 50%;
}
.modal-close:hover { background: rgba(255,255,255,.15); }
.modal-close:focus-visible { outline: 2px solid var(--gold); }

.levels { border: 0; margin: 0 0 22px; padding: 0; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.levels[hidden] { display: none; }
.levels legend { width: 100%; font-family: var(--ui); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600; opacity: .85; margin-bottom: 10px; }
.levels label { position: relative; cursor: pointer; }
.levels input { position: absolute; opacity: 0; inset: 0; }
.levels span {
  display: inline-block; padding: 9px 16px; border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.55);
  font-family: var(--ui); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
  transition: background .15s;
}
.levels input:checked + span { background: var(--white); color: var(--purple); border-color: var(--white); }
.levels input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- dedication (personal intro, see js/dedications.js) ---------- */
.modal-card.has-dedication { width: min(880px, 100%); text-align: left; padding: 48px clamp(24px, 6vw, 60px) 40px; border-radius: 24px; }
.modal-card.has-dedication .modal-title { text-align: left; font-size: clamp(26px, 3.6vw, 34px); letter-spacing: .02em; }
.modal-card.has-dedication .modal-copy { font-size: 17px; line-height: 1.6; opacity: 1; }
.modal-card.has-dedication .modal-how { opacity: .75; }
.modal-card.has-dedication .levels { justify-content: flex-start; }
.modal-card.has-dedication .levels legend { text-align: left; }
.modal-card.has-dedication .btn-big { padding: 16px 48px; }
.modal-card.has-dedication .modal-fine { text-align: left; margin: 14px 0 0; }
.dedication { margin: 0 0 30px; padding: 0 0 30px; border-bottom: 1px solid rgba(255,255,255,.22); }
.dedication-eyebrow { font-family: var(--ui); font-weight: 600; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; opacity: .75; margin: 0 0 12px; }
.dedication-headline { font-family: var(--ui); font-weight: 700; font-size: clamp(30px, 4.4vw, 44px); line-height: 1.05; letter-spacing: .005em; margin: 0 0 20px; max-width: 16em; }
.dedication p.dedication-para { font-size: 17px; line-height: 1.6; margin: 0 0 14px; }
.dedication-signature { font-size: 17px; margin: 18px 0 0; }
.dedication-links { margin: 30px 0 0; padding: 26px 0 0; border-top: 1px solid rgba(255,255,255,.22); font-size: 15px; line-height: 1.5; }
.dedication-links p { margin: 0 0 10px; }
.dedication-links strong { font-weight: 600; }
.dedication-links a { color: var(--white); font-weight: 600; white-space: nowrap; }
.dedication-links a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--white);
  padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- how to play ---------- */
.help-wrap { position: relative; }
.btn-help { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 16px; letter-spacing: 0; }
.help-pop {
  position: absolute; left: 0; bottom: calc(100% + 10px);
  width: min(360px, calc(100vw - 2 * var(--gutter)));
  background: var(--purple-deep); color: var(--white);
  border-radius: 12px; padding: 16px 18px 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
  z-index: 35; text-align: left;
  animation: rise .2s ease-out;
}
.help-pop[hidden] { display: none; }
.help-title { font-family: var(--ui); font-weight: 700; text-transform: uppercase; font-size: 18px; letter-spacing: .04em; margin: 0 0 8px; }
.help-list { margin: 0; padding: 0 0 0 16px; font-size: 13.5px; line-height: 1.45; }
.help-list li { margin: 0 0 6px; }
.help-list li.how-touch { display: none; }
@media (pointer: coarse) { .help-list li.how-desktop, .help-list li.how-kbd { display: none; } .help-list li.how-touch { display: list-item; } }
.help-fine { font-size: 12px; opacity: .75; margin: 10px 0 0; }
body.kiosk .help-list li.how-kbd { display: none; }

/* ---------- kiosk mode ---------- */
.kiosk-only { display: none; }
body.kiosk .kiosk-only { display: block; font-size: 18px; opacity: 1; }
body.kiosk .actions, body.kiosk .credit, body.kiosk .modal-row, body.kiosk .levels { display: none; }
body.kiosk .modal-card { width: min(720px, 100%); }
body.kiosk .modal-title { font-size: clamp(36px, 5vw, 56px); }
body.kiosk #result-donate { pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; grid-template-areas: "lockup actions" "meter meter"; row-gap: 8px; }
  .lockup { grid-area: lockup; }
  .actions { grid-area: actions; }
  .meter { grid-area: meter; justify-self: center; }
  .lockup-name { font-size: 15px; }
  .amount { font-size: 44px; }
  .board-wrap { overflow-x: auto; }
  .modal-card { padding: 28px 20px 22px; }
}
@media (max-width: 420px) {
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-ghost { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-card, .line-answer, .cell.hint, .line-wrong.flash, .btn { animation: none !important; transition: none !important; }
}
