/* styles.css — the crossword maker (index.html) and its Help / Privacy pages. One spacing scale: --s1…--s6. */
@font-face { font-family: "CW Serif"; src: url("fonts/LibreBaskerville-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "CW Serif"; src: url("fonts/LibreBaskerville-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "CW Serif"; src: url("fonts/LibreBaskerville-Italic.ttf") format("truetype"); font-style: italic; font-display: swap; }
@font-face { font-family: "CW Sans"; src: url("fonts/Andika-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "CW Sans"; src: url("fonts/Andika-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --ink: #1f1a17; --muted: #6f645b; --paper: #faf6f0; --band: #f1e8dc; --card: #fff; --line: #e4d9cc;
  --accent: #8e1f2f; --accent-dark: #6f1724; --ok: #1e5b45; --ok-bg: #eaf6ee; --error: #b3261e; --error-bg: #fdf0ef;
  --warn: #7a5200; --warn-bg: #fff8e6; --warn-line: #ecd9a0;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: var(--s4); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 "CW Sans", system-ui, sans-serif; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* returning buyers */
.topbar { margin: 0; padding: var(--s2) var(--s4); text-align: center; font-size: 14px; color: var(--muted); background: var(--card); border-bottom: 1px solid var(--line); }
.topbar a { font-weight: 700; }

/* hero */
.hero { background: var(--band); border-bottom: 1px solid var(--line); }
.hero-inner { max-width: 1120px; margin: 0 auto; padding: var(--s6) var(--s4); display: grid; gap: var(--s5); align-items: center; }
.hero h1 { margin: 0; font: 700 clamp(30px, 6vw, 46px)/1.12 "CW Serif", Georgia, serif; }
.lead { margin: var(--s3) 0 0; max-width: 34em; font: italic 18px/1.5 "CW Serif", Georgia, serif; color: var(--muted); }
.price-line { margin: var(--s3) 0 0; font-size: 16px; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s5); }
.hero-img { width: 100%; max-width: 350px; height: auto; justify-self: center; border-radius: var(--radius); }
@media (min-width: 860px) { .hero-inner { grid-template-columns: minmax(0, 1fr) 350px; padding: 40px var(--s4); } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); border-radius: var(--radius); padding: 13px 20px; font: 700 17px/1.2 "CW Sans", sans-serif; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { border: 0; background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.secondary { border: 1.5px solid var(--accent); background: var(--card); color: var(--accent); }
.btn.secondary:hover { background: #fbf3f4; }
.btn.small { padding: 9px 14px; font-size: 15px; }
.btn.ghost { border: 1.5px solid var(--line); background: var(--card); color: var(--muted); }
.btn.ghost:hover { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.btn.danger { border: 0; background: var(--error); color: #fff; }
.btn.danger:hover { background: #8f1d17; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn[disabled] { opacity: .65; cursor: progress; }
.btn:focus-visible, .link-btn:focus-visible, .add-row:focus-visible, .remove:focus-visible, .mode-btn:focus-visible { outline: 3px solid rgba(142, 31, 47, .35); outline-offset: 2px; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; padding: var(--s1) 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* page layout: form left, sticky preview right on wide screens */
.layout { max-width: 1120px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); display: grid; gap: var(--s5); align-items: start; }
.col-form, .col-preview { display: grid; gap: var(--s5); min-width: 0; }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); } }
#get h2, #preview-card h2 { margin-bottom: var(--s3); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: var(--s5); }
h2 { margin: 0 0 var(--s4); font: 700 19px/1.3 "CW Sans", sans-serif; display: flex; gap: var(--s3); align-items: center; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 15px; flex: none; }

/* fields */
.field { margin: 0 0 var(--s4); padding: 0; border: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
label, legend { display: block; font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 var(--s2); padding: 0; }
.opt { font-weight: 400; color: var(--muted); }
input[type="text"], textarea, select { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 170px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(142, 31, 47, .18); border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--error) !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.hint { margin: 0 0 var(--s3); font-size: 15px; color: var(--muted); }
.private { display: flex; gap: var(--s2); align-items: center; color: var(--ok); font-weight: 700; }
.field-error { margin: var(--s2) 0 0; color: var(--error); font-size: 15px; }

/* colour chips + the small live sample under them (phones: the big preview is further down) */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { position: relative; display: inline-flex; align-items: center; gap: var(--s2); margin: 0; padding: 8px 14px 8px 10px; border: 1.5px solid var(--line); border-radius: 999px; font-weight: 700; cursor: pointer; background: #fff; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip .sw { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.chip:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--ink); }
.chip:has(input:focus-visible) { outline: 3px solid rgba(142, 31, 47, .35); outline-offset: 2px; }
.look-sample { display: none; margin-top: var(--s4); padding: var(--s3); border: 1px dashed var(--line); border-radius: 10px; background: #fff; }
.look-sample svg { display: block; width: 100%; height: auto; max-width: 340px; margin: 0 auto; }
@media (max-width: 959px) { .look-sample { display: block; } }

/* answers and clues */
.mode { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; margin: 0 0 var(--s4); background: var(--paper); }
.mode-btn { border: 0; background: none; font: 700 15px/1 "CW Sans", sans-serif; color: var(--muted); padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.mode-btn[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(31, 26, 23, .15); }
.entry-head, .entry { display: grid; grid-template-columns: 30px minmax(96px, 0.8fr) minmax(0, 2fr) 40px; gap: var(--s2); align-items: center; }
.entry-head { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: var(--s2); }
.entries { display: grid; gap: var(--s2); }
.num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.entry[data-state="placed"] .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.entry[data-state="unplaced"] .num { background: var(--warn-bg); border-color: #d9b44a; color: var(--warn); }
.entry[data-state="error"] .num { background: var(--error); border-color: var(--error); color: #fff; }
.remove { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.remove:hover { color: var(--error); background: var(--error-bg); }
.row-msg { grid-column: 2 / -1; margin: 0; font-size: 14px; line-height: 1.4; }
.entry[data-state="error"] .row-msg { color: var(--error); }
.entry[data-state="unplaced"] .row-msg { color: var(--warn); }
.add-row { width: 100%; margin-top: var(--s3); padding: 12px; border: 1.5px dashed #cdbcaa; border-radius: 10px; background: var(--paper); color: var(--accent); font: 700 16px/1.2 "CW Sans", sans-serif; cursor: pointer; }
.add-row:hover { background: #f6eee4; border-color: var(--accent); }
.add-row[disabled] { color: var(--muted); cursor: default; }
.words-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2) var(--s4); margin-top: var(--s3); font-size: 15px; }
.count { margin: 0; color: var(--muted); }
.form-tools { display: flex; justify-content: flex-end; }
.form-tools.bottom { margin-top: var(--s3); }
.examples { color: var(--muted); }
#paste-box .btn { margin-top: var(--s3); }
.file-box { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.file-box .hint { margin-bottom: var(--s3); }
.file-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
#paste-box .file-actions .btn { margin-top: 0; }
@media (max-width: 559px) {
  .card { padding: var(--s4); }
  .entry-head { display: none; }
  .entry { grid-template-columns: 28px minmax(0, 1fr) 40px; padding-bottom: var(--s2); border-bottom: 1px dashed var(--line); }
  .entry .clue { grid-column: 2 / 3; }
  .entry .remove { grid-row: 1; grid-column: 3; }
  .row2 { grid-template-columns: 1fr; }
}

/* preview */
.preview-status { margin: 0 0 var(--s3); font-size: 15px; line-height: 1.35; color: var(--muted); }
.preview-status b { color: var(--ink); }
.sheet-wrap { padding: var(--s3); background: #ece4d8; border-radius: 10px; }
.sheet-row { display: grid; gap: var(--s3); }
.sheet { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 5px rgba(31, 26, 23, .22)); }
/* the preview card's buttons sit on the heading row, so the page itself gets the height */
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.card-head h2 { margin: 0 !important; }
.preview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.preview-actions .btn.small { padding: 7px 12px; font-size: 14px; }
.pages-note { margin: var(--s2) 0 0; font-size: 13px; }
.sheet-wrap { cursor: zoom-in; }
.zoom { width: min(96vw, 860px); max-height: 96vh; padding: 0; border: 0; border-radius: var(--radius); background: #ece4d8; }
.zoom::backdrop { background: rgba(31, 26, 23, .6); }
.zoom-bar { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--line); display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); background: var(--card); font-weight: 700; }
.zoom-body { display: grid; gap: var(--s4); padding: var(--s4); }
.zoom-body svg { display: block; width: 100%; height: auto; }
.confirm { width: min(92vw, 420px); padding: var(--s5); border: 0; border-radius: var(--radius); background: var(--card); color: var(--ink); }
.confirm::backdrop { background: rgba(31, 26, 23, .6); }
.confirm h2 { margin-bottom: var(--s2); }
.confirm p { margin: 0 0 var(--s5); }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s3); }
/* wide and tall enough: the preview column stays in view, the page preview takes whatever height is left */
@media (min-width: 960px) and (min-height: 640px) {
  .col-preview { position: sticky; top: var(--s4); height: calc(100vh - var(--s6)); display: flex; flex-direction: column; gap: var(--s3); overflow-y: auto; }
  .col-preview .card { padding: var(--s4) var(--s5); }
  #preview-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .sheet-wrap { flex: 1 1 auto; min-height: 300px; position: relative; }
  .sheet-row { position: absolute; inset: var(--s3); display: flex; gap: var(--s3); }
  .sheet { flex: 1 1 0; min-width: 0; width: 100%; height: 100%; }
  #get { flex: none; }
  #get h2 { margin-bottom: var(--s2); }
}
@media (min-width: 960px) and (min-height: 640px) and (max-height: 859px) {
  .col-preview .included, .col-preview .pages-note { display: none; }
}
.note { margin: var(--s3) 0 0; padding: var(--s3) var(--s4); border-radius: 10px; font-size: 15px; }
.note.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.note.ok { background: var(--ok-bg); border: 1px solid #a9d8b8; font-weight: 700; }
.col-form > .note.ok { margin: 0; }

/* get the PDF */
#get .note.ok { margin: 0 0 var(--s4); }
.fix-summary { border: 2px solid var(--error); background: var(--error-bg); border-radius: 10px; padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
.fix-summary p { margin: 0 0 var(--s2); font-weight: 700; color: var(--error); }
.fix-summary ul { margin: 0; padding-left: 20px; }
.fix-summary a { color: var(--error); }
.buy-line { margin: var(--s2) 0 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); justify-content: space-between; align-items: baseline; }
.buy-line .link-btn { font-size: 14px; }
#code-box { margin-top: var(--s3); }
.code-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); }
.code-ok { margin: 0 0 var(--s3); color: var(--ok); font-weight: 700; }
.status { margin: var(--s3) 0 0; text-align: center; }
.status a.btn { margin-top: var(--s3); }
.included { margin: var(--s3) 0 0; padding: var(--s3) 0 0; border-top: 1px solid var(--line); list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1) var(--s3); font-size: 14px; color: var(--muted); }
.included li::before { content: "✓"; color: var(--ok); font-weight: 700; margin-right: var(--s2); }

/* phones and short screens: the dock keeps the crossword and the buy button in sight; the undo toast sits above it */
.dock { position: fixed; left: var(--s2); right: var(--s2); bottom: var(--s2); z-index: 10; display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s2); border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(31, 26, 23, .22); max-width: 640px; margin: 0 auto; }
.dock-thumb { flex: none; width: 46px; height: 62px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #ece4d8; cursor: zoom-in; }
.dock-thumb svg { display: block; width: 100%; height: 100%; }
.dock-text { flex: 1 1 auto; min-width: 0; margin: 0; display: grid; font-size: 14px; line-height: 1.3; color: var(--muted); }
.dock-text b { color: var(--ink); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock .btn { flex: none; padding: 12px 14px; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: var(--s4); transform: translateX(-50%); z-index: 11; display: flex; gap: var(--s4); align-items: center; padding: 12px var(--s4); border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); max-width: calc(100% - var(--s6)); }
.toast .link-btn { color: #ffd7dc; }
@media (max-width: 959px), (max-height: 639px) { .toast { bottom: 92px; } .site-footer { padding-bottom: 110px; } }

/* footer + text pages */
.site-footer { max-width: 1120px; margin: 0 auto; padding: var(--s5) var(--s4) 90px; text-align: center; color: var(--muted); font-size: 15px; }
.site-footer p { margin: 0 0 var(--s3); }
.site-footer nav a { font-weight: 700; }
.fine { font-size: 12px; }
.page { max-width: 720px; margin: 0 auto; padding: var(--s6) var(--s4); }
.page h1 { font: 700 34px/1.2 "CW Serif", Georgia, serif; margin: 0 0 var(--s4); }
.page h2 { margin: var(--s6) 0 var(--s2); }
.page p, .page li { font-size: 17px; }
.back { display: inline-block; margin-bottom: var(--s5); font-weight: 700; }
