/*
Filename: style.css
Last Edit Date: 2026-10-25 EST
Purpose: Styles for Rising Tide Word Puzzles: the app page and printed puzzles (CrossCurrents, SafeHarbor, EquiWords, TideWords, SeaWords), in the VISIBLE look in red.
*/

:root {
  --navy: #5a1216;          /* header: deep red */
  --navy-2: #7a1d22;        /* menu bar */
  --gold: #f2c230;          /* with deep red text: about 9:1 contrast */
  --accent: #a3242b;        /* buttons and links */
  --accent-light: #fbeaea;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --red: #8e1b1b;
  --red-light: #fdecea;
  --ink: #1d2330;
  --muted: #5d6676;
  --line: #ead9d9;
  --bg: #f9f4f4;
  --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(--accent); }
.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(--accent); color: #fff;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--accent); border-color: var(--accent); }
.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 #dbc8c8; 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; }
/* The Rising Tide logo is transparent: a white tile keeps it visible on the dark header. */
.brand-logo { width: 46px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }
.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: #f0d8d8;
  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(220px, 60%); 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; }
/* The five puzzle kinds: a name with one line on what the puzzle is. */
.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kind-btn { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
.kind-btn strong { color: var(--accent); }
.kind-btn span { font-size: .82rem; color: var(--muted); line-height: 1.25; }
.kind-btn.active { background: var(--navy); border-color: var(--navy); }
.kind-btn.active strong, .kind-btn.active span { color: #fff; }
.count-box { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--accent-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: #f6eaea; font-size: .88rem; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fdf8f8; }
table.list td.clue-cell { color: var(--muted); font-size: .9rem; }
table.list td.clue-cell .kid-clue { margin-top: 4px; color: #6b4f2a; }
.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(--accent-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(30, 10, 12, .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 shrinks the squares
   (then the clue text) until everything fits above it. --cell is the square size. */
.puzzle-page { position: relative; background: #fff; width: 8.5in; height: 11in; overflow: hidden; padding: .45in .5in; margin: 0 auto; color: #000; --cell: .4in; --clue: 10.5pt; }
.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: 1.1in; height: auto; }
.pz-title { font-size: 24px; font-weight: 800; margin: 2px 0 4px; }
/* One line under the title on what the solver does. */
.pz-howto { font-size: 12.5px; font-style: italic; color: #333; margin: 0 0 2px; }
.pz-name-line { display: flex; justify-content: space-between; font-size: 15px; margin: 8px 0 12px; }
.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; }
table.pz-grid { position: relative; border-collapse: collapse; margin: 0 auto; background: transparent; }
table.pz-grid td { width: var(--cell); height: var(--cell); padding: 0; border: 0; }
/* Only the answer squares are drawn (activity-book style); the rest of the grid stays blank. */
table.pz-grid td.sq { position: relative; border: 1.5px solid #000; background: rgba(255,255,255,.55); text-align: center; vertical-align: middle;
  font: 700 calc(var(--cell) * .55) "Courier New", ui-monospace, monospace; color: #c62828; }
table.pz-grid td.sq .n { position: absolute; left: 2px; top: 1px; font: 600 calc(var(--cell) * .26) system-ui, sans-serif; color: #000; line-height: 1; }
.pz-clues { margin-top: 14px; column-count: 2; column-gap: .35in; font-size: var(--clue); line-height: 1.28; }
.pz-clues h4 { font-size: calc(var(--clue) + 2pt); margin: 0 0 4px; break-after: avoid; }
.pz-clues h4.down { margin-top: 8px; }
.pz-clue { display: flex; gap: 5px; margin-bottom: 4px; break-inside: avoid; }
.pz-clue b { min-width: 1.5em; text-align: right; }
.pz-clue .len { white-space: nowrap; }
table.pz-grid td.sq .given { color: #000; }
/* Fill-in: the answers grouped by letter count; its key lists them by number. */
.pz-fill { margin-top: 14px; column-count: 3; column-gap: .3in; font-size: calc(var(--clue) + 1pt); font-weight: 700; line-height: 1.35; }
.pz-group { break-inside: avoid; margin-bottom: 8px; }
.pz-group h4 { font-size: var(--clue); margin: 0 0 2px; color: #5a1216; text-transform: uppercase; letter-spacing: .04em; }
.pz-fill-key { margin-top: 14px; column-count: 3; column-gap: .3in; font-size: var(--clue); line-height: 1.35; }
/* EquiWords and TideWords: number, scramble, then the answer's line or boxes; the clue under it when asked for. */
.sc-wrap { position: relative; margin-top: 16px; }
.sc-list { position: relative; display: grid; grid-template-columns: auto auto 1fr; column-gap: .22in; row-gap: calc(var(--cell) * .45); align-items: end; font-size: calc(var(--clue) + 2pt); }
.sc-n { text-align: right; }
.sc-scr { font: 700 calc(var(--clue) + 3pt) "Courier New", ui-monospace, monospace; letter-spacing: .14em; white-space: nowrap; }
.sc-line { border-bottom: 1.5px solid #000; min-height: var(--cell); font: 700 calc(var(--clue) + 3pt) "Courier New", ui-monospace, monospace; color: #c62828; letter-spacing: .14em; }
.sc-clue { grid-column: 2 / -1; margin-top: calc(var(--cell) * -.3); font-size: calc(var(--clue) - .5pt); color: #333; }
/* EquiWords lists each answer as its own block, in one or two columns. */
.sc-list.eq-list { display: block; column-gap: .35in; }
.sc-list.eq-list.two { column-count: 2; }
.eq-item { break-inside: avoid; margin-bottom: calc(var(--cell) * .45); }
.eq-row { display: flex; align-items: flex-end; gap: .14in; }
.eq-row .sc-n { min-width: 1.6em; }
.eq-row .sc-line { flex: 1; min-width: 1in; display: flex; align-items: flex-end; padding: 0 0 2px 6px; line-height: 1; }
.eq-item .sc-clue { margin: 3px 0 0 calc(1.6em + .14in); }
.tw-boxes { display: flex; }
/* Outlines, not borders: every box keeps exactly one --cell of width, so the circled boxes stay in one column. */
.tw-box { flex: none; width: var(--cell); height: var(--cell); outline: 1.2px solid #000; outline-offset: -.6px; background: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center; font: 700 calc(var(--cell) * .55) "Courier New", ui-monospace, monospace; color: #c62828; }
/* The circled box: the column these line up in spells the bonus word. */
.tw-box.circled { border-radius: 50%; outline-width: 2px; background: #fbeaea; }
.tw-gap { flex: none; width: calc(var(--cell) * .5); }
/* The answers upside down in the footer: small, so they don't give themselves away at a glance. */
.pz-footkey { transform: rotate(180deg); font-size: 7pt; line-height: 1.3; color: #333; margin: 0 auto 6px; max-width: 7in; }
/* SeaWords: the letter grid and the answers to find. */
table.sea-grid { position: relative; border-collapse: collapse; margin: 0 auto; background: transparent; font-family: "Courier New", ui-monospace, monospace; font-weight: 700; }
table.sea-grid td { width: var(--cell); height: var(--cell); text-align: center; vertical-align: middle; border: 1px solid #c9b9b9; padding: 0; font-size: calc(var(--cell) * .55); }
table.sea-grid.key td { color: #bdb0b0; font-weight: 400; }
table.sea-grid.key td.hit { color: #c62828; font-weight: 800; }
.sea-words { margin-top: 16px; display: grid; gap: 4px 18px; font-size: calc(var(--clue) + 3pt); font-weight: 700; text-transform: uppercase; }
.sea-words.big { font-size: calc(var(--clue) + 6pt); }
.pz-bank { margin-top: 10px; font-size: calc(var(--clue) - .5pt); text-transform: uppercase; font-weight: 700; line-height: 1.5; }
.pz-bank span { display: inline-block; margin-right: 14px; }
.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: table; margin: 0 auto 6px; background: #5a1216; color: #fff; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
/* Pages are laid out off screen first so App.js can measure and fit them before printing. */
#print-root { position: absolute; left: -20000px; top: 0; }

@media print {
  @page { size: letter; margin: 0; }
  body { background: #fff; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { position: static; }
  .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: minmax(0, 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; }
}
