/*
Filename: style.css
Last Edit Date: 2026-10-24 EST
Purpose: Styles for VISIBLE Bingo: the app page, the watch page, the splash screen and printed cards.
*/

:root {
  --navy: #1f2d4d;
  --navy-2: #2c3e66;
  --gold: #c99a1e;
  --gold-light: #f6e3a6;
  --blue: #3f7fc4;
  --blue-light: #e6f0fb;
  --orange: #ff9d2f;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --red: #c62828;
  --red-light: #fdecea;
  --ink: #1d2330;
  --muted: #5d6676;
  --line: #dde2ea;
  --bg: #f5f6f9;
  --card: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.hidden { display: none !important; }
h1, h2, h3, h4 { line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 0 0 10px; }
a { color: var(--blue); }
.hint { color: var(--muted); font-size: .9rem; }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ── buttons and fields ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--blue); color: #fff;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-sm { padding: 5px 10px; font-size: .88rem; }
.btn-lg { padding: 14px 28px; font-size: 1.2rem; }
.btn-header { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }

input[type=text], input[type=number], input[type=search], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #c7ced9; border-radius: 8px;
  background: #fff; color: var(--ink); max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
label.field { display: block; font-weight: 600; margin: 10px 0 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}

/* ── header ─────────────────────────────────────────────────── */
.site-header { background: var(--navy); color: #fff; }
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; }
.brand-name { font-size: 1.2rem; font-weight: 700; }
.brand-site { font-weight: 500; opacity: .85; }
.brand-version { font-size: .8rem; font-weight: 400; opacity: .75; }
.header-theme { display: flex; align-items: center; gap: 6px; }
.header-theme select { padding: 6px 8px; min-width: 160px; }
.header-user { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.header-name { opacity: .9; }

/* ── menu (tabs) ────────────────────────────────────────────── */
.menu { background: var(--navy-2); }
.menu-inner { max-width: 1200px; margin: 0 auto; padding: 0 8px; display: flex; overflow-x: auto; }
.menu-btn {
  padding: 12px 16px; border: 0; background: transparent; color: #d7deec;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.menu-btn.active { color: #fff; border-bottom-color: var(--gold); }
.menu-btn:hover { color: #fff; }

main.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.panel { display: none; }
.panel.active { display: block; }

/* ── sign-in screen ─────────────────────────────────────────── */
.auth-wrap { max-width: 420px; margin: 40px auto; text-align: center; }
.auth-wrap img { width: min(320px, 80%); height: auto; margin: 8px auto 16px; display: block; }

/* ── splash ─────────────────────────────────────────────────── */
.splash {
  position: fixed; inset: 0; z-index: 200000; background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  transition: opacity .6s ease;
}
.splash img { max-height: 86vh; max-width: 92vw; width: auto; height: auto; }
.splash.fade { opacity: 0; pointer-events: none; }

/* ── play ───────────────────────────────────────────────────── */
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.game-tile {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.game-tile h3 { margin: 0; }
.game-tile .meta { color: var(--muted); font-size: .88rem; }
.game-tile .row { margin-top: auto; padding-top: 6px; }

.play-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.play-title { font-size: 1.15rem; font-weight: 700; }
.counts { display: flex; gap: 16px; color: var(--muted); font-weight: 600; }
.play-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.current {
  background: #fff; border: 2px solid var(--gold); border-radius: 14px; padding: 20px; min-height: 240px;
}
.current .name { font-size: 2rem; font-weight: 800; color: var(--navy); }
.current .number { color: var(--muted); font-weight: 600; margin-top: 2px; }
.current .bio { font-size: 1.15rem; margin: 12px 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--blue-light); color: var(--navy); border-radius: 999px; padding: 3px 10px; font-size: .88rem; font-weight: 600; }
.history { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; max-height: 520px; overflow-y: auto; }
.history ol { margin: 0; padding-left: 0; list-style: none; }
.history li { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.history li:hover { background: var(--bg); }
.history .h-num { color: var(--muted); font-size: .8rem; margin-right: 6px; }
.history .h-tags { color: var(--muted); font-size: .85rem; }
.play-side { display: flex; flex-direction: column; gap: 12px; }
.play-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.watch-code { font-size: 2rem; font-weight: 800; letter-spacing: .12em; color: var(--navy); }

.pattern-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pattern-diagram { display: flex; gap: 10px; align-items: center; }
.pattern-grid { display: grid; gap: 2px; width: 90px; }
.pattern-cell { aspect-ratio: 1; background: #e3e7ee; border-radius: 2px; }
.pattern-cell.on { background: var(--gold); }
.pattern-caption { font-size: .85rem; color: var(--muted); max-width: 180px; }

.deck-list { max-height: 360px; overflow-y: auto; font-size: .92rem; }
.deck-list ol { margin: 4px 0 12px; padding-left: 24px; }

/* ── build ──────────────────────────────────────────────────── */
.size-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.size-btn { min-width: 64px; }
.size-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tag-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px 16px; }
.tag-group h4 { margin: 6px 0 4px; font-size: .95rem; color: var(--navy); }
.tag-group .check { display: flex; margin: 2px 0; font-size: .92rem; }
.count-box { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--green-light); color: var(--green); font-weight: 600; }
.count-box.warn { background: var(--red-light); color: var(--red); }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { background: #eef1f6; font-size: .88rem; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #f7f9fc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eceff4; color: var(--muted); }
.badge-warn { background: var(--red-light); color: var(--red); }

/* ── themes ─────────────────────────────────────────────────── */
.themes-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.tag-editor .group { border-top: 1px solid var(--line); padding: 8px 0; }
.tag-editor .group-head { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--navy); }
.tag-editor .tag-row { display: flex; align-items: center; gap: 6px; padding: 2px 0 2px 12px; font-size: .93rem; }
.tag-editor .tag-row .n { color: var(--muted); font-size: .8rem; }
.link-btn { border: 0; background: none; color: var(--blue); cursor: pointer; font: inherit; font-size: .85rem; padding: 0 2px; }
.link-btn.danger { color: var(--red); }

/* ── modal + toast ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000; background: rgba(15, 20, 30, .55);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-title { margin: 0; flex: 1; }
.modal-close { border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9500;
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; max-width: calc(100vw - 32px);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.loading { text-align: center; padding: 40px; color: var(--muted); }

/* ── watch page ─────────────────────────────────────────────── */
.watch-entry { max-width: 420px; margin: 32px auto; text-align: center; }
.watch-entry img { width: min(300px, 80%); margin: 0 auto 12px; display: block; }
.watch-entry input { font-size: 1.6rem; width: 8rem; text-align: center; letter-spacing: .2em; }
.watch-status { text-align: center; font-weight: 600; margin-bottom: 12px; }

/* ── printed cards ──────────────────────────────────────────── */
.print-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.sample-wrap { margin-top: 16px; overflow-x: auto; }
.bingo-page { background: #fff; padding: .4in .3in; width: 8.5in; margin: 0 auto; }
.sample-wrap .bingo-page { box-shadow: 0 4px 16px rgba(0,0,0,.15); transform-origin: top left; }
.bingo-head { position: relative; text-align: center; padding-bottom: .15in; min-height: .9in; }
.bingo-head .title { width: 3.2in; height: auto; }
.bingo-head .qr { position: absolute; top: 0; right: 0; display: flex; flex-direction: column; align-items: center; width: 1in; }
.bingo-head .qr img { width: .8in; height: .8in; }
.bingo-head .qr span { font-size: 8.5px; line-height: 1.1; text-align: center; color: #333; }
table.bingo-card { table-layout: fixed; border-collapse: collapse; margin: 0 auto; }
table.bingo-card td {
  width: 1.05in; height: 1.05in; border: 2px solid #000; text-align: center; vertical-align: middle;
  font-weight: 800; font-size: 15px; line-height: 1.15; padding: .08in; overflow-wrap: break-word; hyphens: manual; color: #000;
}
table.bingo-card td.fit-sm { font-size: 12px !important; }
table.bingo-card td.fit-xs { font-size: 10px !important; letter-spacing: -.2px; }
table.bingo-card td.tag-cell {
  background: var(--orange); color: #fff; font-size: 16px;
  text-shadow: -0.6px -0.6px 0 #000, 0.6px -0.6px 0 #000, -0.6px 0.6px 0 #000, 0.6px 0.6px 0 #000;
}
table.bingo-card.size-6 td { width: .98in; height: .98in; font-size: 14px; }
table.bingo-card.size-7 td { width: .88in; height: .88in; font-size: 12.5px; padding: .06in; }
table.bingo-card.size-3 td, table.bingo-card.size-4 td { width: 1.4in; height: 1.4in; font-size: 18px; }
.bingo-foot { text-align: center; padding-top: .2in; font-size: 11px; color: #333; }
.bingo-foot img { width: .7in; height: .7in; object-fit: contain; display: block; margin: 0 auto 4px; }
.bingo-foot .game { margin-top: 3px; opacity: .8; }
#print-root { display: none; }

@media print {
  @page { size: letter; margin: 0; }
  body { background: #fff; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  .bingo-page { width: 8.5in; height: 11in; padding: .45in .35in; page-break-after: always; break-after: page; box-shadow: none; }
  .bingo-page:last-child { page-break-after: auto; break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── narrow screens ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .play-grid, .themes-grid { grid-template-columns: 1fr; }
  /* A "stack" table becomes one card per row: no sideways scrolling on a phone. */
  .table-wrap:has(table.stack) { border: 0; overflow: visible; }
  table.list.stack { background: transparent; }
  table.list.stack thead { display: none; }
  table.list.stack tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
  table.list.stack td { display: block; border: 0; padding: 2px 0; }
  table.list.stack td.g-name { font-size: 1.05rem; padding-bottom: 4px; }
  table.list.stack td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); }
  table.list.stack td.g-actions { padding-top: 8px; }
  .current .name { font-size: 1.6rem; }
  .header-user { margin-left: 0; }
}
