/*
Filename: style.css
Last Edit Date: 2026-10-24 EST
Purpose: Styles for VISIBLE Word Search: the app page and printed puzzles (the VISIBLE Bingo look, in purple).
*/

:root {
  --navy: #34184f;
  --navy-2: #4a2470;
  --gold: #f2c230;          /* with dark purple text: 9:1 contrast */
  --purple: #7347b8;
  --purple-light: #f1eafb;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --red: #c62828;
  --red-light: #fdecea;
  --ink: #1d2330;
  --muted: #5d6676;
  --line: #e0dce8;
  --bg: #f6f4f9;
  --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(--purple); }
.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(--purple); color: #fff;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--purple); border-color: var(--purple); }
.btn-gold { background: var(--gold); color: var(--navy); }
.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-header { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.choice.active { background: var(--navy); color: #fff; border-color: var(--navy); }

input[type=text], input[type=number], input[type=search], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfc8db; 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-user { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.header-name { opacity: .9; }

/* ── menu ───────────────────────────────────────────────────── */
.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: #e2d8f0;
  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; }
.viewer-note { max-width: 560px; }

/* ── make puzzles ───────────────────────────────────────────── */
.make-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row > div { min-width: 120px; }
.count-box { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--purple-light); color: var(--navy); font-weight: 600; }
.count-box.warn { background: var(--red-light); color: var(--red); }
/* The full-size page is scaled down to fit; hidden overflow keeps its original width from adding scroll bars. */
.preview-wrap { overflow: hidden; }

/* ── lists ──────────────────────────────────────────────────── */
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: #f1edf7; font-size: .88rem; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #faf8fd; }
.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: var(--purple-light); color: var(--navy); }
.badge-warn { background: var(--red-light); color: var(--red); }

.topics-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.add-word { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-word input[type=text] { flex: 1; min-width: 160px; }

/* ── modal + toast ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000; background: rgba(20, 12, 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); }

/* ── printed puzzles ────────────────────────────────────────── */
/* Always exactly one letter page; the footer is pinned to its bottom and App.js sizes the grid to fit above it. */
.puzzle-page { position: relative; background: #fff; width: 8.5in; height: 11in; overflow: hidden; padding: .45in .5in; margin: 0 auto; color: #000; display: flex; flex-direction: column; }
.preview-wrap .puzzle-page { box-shadow: 0 4px 16px rgba(0,0,0,.15); transform-origin: top left; }
.pz-head { text-align: center; }
.pz-head .vis { width: 2.6in; height: auto; }
.pz-title { font-size: 26px; font-weight: 800; margin: 2px 0 4px; }
.pz-name-line { display: flex; justify-content: space-between; font-size: 15px; margin: 10px 0 14px; }
.pz-name-line span { border-bottom: 1px solid #000; min-width: 3.2in; display: inline-block; }
/* The site logo in gray behind the grid (puzzles and answer keys): faint enough to read through, dark enough to survive a photocopy. */
.pz-grid-wrap { position: relative; width: max-content; margin: 0 auto; }
.pz-watermark { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: grayscale(1); opacity: .2; pointer-events: none; }
.pz-grid-wrap table.pz-grid { position: relative; background: transparent; }
table.pz-grid { border-collapse: collapse; margin: 0 auto; font-family: "Courier New", ui-monospace, monospace; font-weight: 700; }
table.pz-grid td { text-align: center; vertical-align: middle; border: 1px solid #b9b2c6; padding: 0; }
table.pz-grid.key td { color: #b7b0c2; font-weight: 400; }
/* Answer key: the words' letters in bold color, no fill (saves ink); the rest faded. */
table.pz-grid.key td.hit { color: #c62828; font-weight: 800; }
.pz-words { margin-top: 18px; display: grid; gap: 4px 18px; font-size: 18px; font-weight: 700; text-transform: uppercase; }
.pz-words.small { font-size: 15px; }
.pz-foot { position: absolute; left: .5in; right: .5in; bottom: .35in; text-align: center; font-size: 11px; color: #333; }
.pz-notice { font-size: 9.5px; font-style: italic; max-width: 6in; margin: 3px auto; }
.pz-key-label { display: inline-block; background: #34184f; color: #fff; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; margin-bottom: 6px; }
#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; }
  .puzzle-page { height: 11in; box-shadow: none; page-break-after: always; break-after: page; }
  .puzzle-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) {
  .make-grid, .topics-grid { grid-template-columns: 1fr; }
  .header-user { margin-left: 0; }
  /* 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.p-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.p-actions { padding-top: 8px; }
}
