/* Fast & Testimony Bingo — a sacrament meeting program that got out of hand.
   Mobile is the target: the whole card must fit one screen, one thumb, no
   scrolling, no sound, and nothing that lights up a dim chapel. */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}
@font-face {
  font-family: "Archivo Narrow";
  src: url("/fonts/archivo-narrow.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #f6f1e6;
  --paper-2: #fffdf7;
  --ink: #1b1a17;
  --ink-soft: #6f6759;
  --rule: #d9d0bd;
  --mark: #1f5e55;
  --mark-ink: #fbf8f0;
  --gold: #a8762a;
  --frame: #1b1a17;
  --shadow: 0 1px 2px rgba(27, 26, 23, 0.06), 0 8px 24px rgba(27, 26, 23, 0.07);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Archivo Narrow", "Avenir Next Condensed", "Helvetica Neue", sans-serif;

  --gap: 2px;
  --pad: 10px;
  --bar: 52px;
  --foot: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131519;
    --paper-2: #1c1f25;
    --ink: #ece6d9;
    --ink-soft: #97928a;
    --rule: #2d323a;
    --mark: #3f9d8c;
    --mark-ink: #0e1013;
    --gold: #dfa94b;
    --frame: #4a5058;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.view { flex: 1; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ---------- chooser ---------- */

#chooser {
  justify-content: center;
  gap: 28px;
  padding: 32px var(--pad) calc(28px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin-inline: auto;
  width: 100%;
}

.masthead { text-align: center; }

.kicker {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(34px, 11.6vw, 58px);
  line-height: 0.92;
  letter-spacing: -0.022em;
}

.masthead em {
  font-style: normal;
  font-weight: 300;
  letter-spacing: 0.01em;
}

.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 22px 0 0;
}

.wards { display: flex; flex-direction: column; gap: 10px; }

.ward {
  display: flex;
  user-select: none;
  -webkit-user-select: none;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.ward:active { transform: scale(0.985); border-color: var(--mark); }

.ward-name {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.005em;
  line-height: 1.15;
}

.ward-blurb {
  display: block;
  margin-top: 3px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.ward-mark {
  flex: none;
  width: 34px;
  height: 34px;
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.ward-mark i { background: var(--rule); border-radius: 1.5px; }
.ward-mark i.on { background: var(--mark); }

.colophon {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

/* ---------- the card ---------- */

.bar {
  flex: none;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.bar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.1;
}

.ward-label {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ghost {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
}

.ghost:active { background: var(--paper-2); color: var(--ink); }

.ghost svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-wrap {
  /* The card's geometry lives here so the strike-through overlay, which is a
     sibling of the grid, can share the same numbers. */
  --side: min(100vw - (var(--pad) * 2), 560px);
  --tall: min(100dvh - var(--bar) - var(--foot) - 18px, var(--side) * 1.45);
  --cell: calc((var(--side) - 4 * var(--gap)) / 5);
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0 var(--pad);
  min-height: 0;
}

.card {
  position: relative;
  width: var(--side);
  height: var(--tall);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: var(--gap);
  background: var(--rule);
  border: 1.5px solid var(--frame);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sq {
  display: grid;
  place-items: center;
  padding: 4px 3px;
  background: var(--paper-2);
  border: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(9.5px, calc(var(--cell) * 0.163), 17px);
  line-height: 1.2;
  letter-spacing: 0.004em;
  text-align: center;
  overflow-wrap: break-word;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.sq span { display: block; }

.sq.on {
  background: var(--mark);
  color: var(--mark-ink);
  font-weight: 600;
}

.sq.free {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(10px, calc(var(--cell) * 0.172), 18px);
  line-height: 1.12;
}

.sq.win { background: var(--gold); color: var(--mark-ink); }

.sq:active { filter: brightness(0.96); }

/* struck lines */

.strikes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.strike-box {
  /* Sized in script from the card's real box. */
  position: relative;
}

.strike {
  position: absolute;
  height: 3px;
  border-radius: 3px;
  background: var(--ink);
  opacity: 0.55;
  transform-origin: 50% 50%;
  animation: draw 0.45s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

@keyframes draw {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.foot {
  flex: none;
  height: var(--foot);
  display: grid;
  place-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.link {
  background: none;
  border: 0;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 10px 16px;
  cursor: pointer;
}

.link:active { color: var(--ink); }

/* ---------- celebration ---------- */

#party {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(3px);
  animation: fade 0.25s ease both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.party-card {
  position: relative;
  text-align: center;
  padding: 0 24px;
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.party-word {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(56px, 21vw, 108px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  color: var(--mark);
}

.party-sub {
  margin: 14px auto 26px;
  max-width: 20ch;
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
}

.solid {
  min-height: 48px;
  padding: 0 30px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.solid:active { transform: scale(0.97); }

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

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

@media (min-width: 700px) and (min-height: 700px) {
  :root { --gap: 3px; --bar: 60px; --foot: 56px; }
  .sq { padding: 8px 6px; }
}

/* ---------- paper ---------- */

@media print {
  :root { --paper: #fff; --paper-2: #fff; --ink: #000; --rule: #999; }
  .bar, .foot, #party, #chooser { display: none !important; }
  .card-wrap { --side: 6.5in; --tall: 8in; }
  .card { box-shadow: none; }
  .sq { font-size: 11pt; }
}
