/* PuzzleBind Daily Proof: a printer's proof-sheet look. Paper, ink, one vermilion accent. */
:root {
  --paper: #f2ead8;
  --paper-2: #e9dfc6;
  --card: #fbf6e9;
  --ink: #1c1813;
  --muted: #6a6252;
  --rule: rgba(28, 24, 19, .18);
  --accent: #d8401c;
  --accent-ink: #fff7ec;
  --pick: #ffd34d;
  --good: #23834a;
  --good-bg: #bfe6cc;
  --bad: #c92a2a;
  --bad-bg: #f5b9b3;
  --shadow: 5px 5px 0 var(--ink);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15120d;
    --paper-2: #1f1a12;
    --card: #1b1710;
    --ink: #efe6d2;
    --muted: #a99f8a;
    --rule: rgba(239, 230, 210, .2);
    --accent: #ff6a3d;
    --accent-ink: #1a0f08;
    --pick: #c79a1b;
    --good: #5fd08c;
    --good-bg: #1f5c38;
    --bad: #ff7b72;
    --bad-bg: #6b2420;
    --shadow: 5px 5px 0 #000;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image: radial-gradient(var(--rule) 1px, transparent 1.2px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Masthead */
.mast { border-top: 6px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 -2px var(--paper), 0 4px 0 -2px var(--ink); }
.mast-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
.brand { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.brand em { font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; border-radius: 4px; }
.issue b { color: var(--accent); font-family: var(--mono); }
.dateline { color: var(--muted); margin-left: 8px; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }

/* Hero */
.hero { padding: 18px 0 8px; }
.kicker { margin: 0 0 6px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kicker strong { color: var(--accent); letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(32px, 7vw, 54px); line-height: .98; letter-spacing: -.025em; font-weight: 800; }
h1 em { color: var(--accent); font-weight: 400; font-style: italic; }
.lede { max-width: 56ch; margin: 8px 0 0; color: var(--muted); font-size: 16px; line-height: 1.4; }
.noscript { padding: 12px; border: 2px solid var(--bad); }

/* Game */
.game { margin-top: 10px; }
.statbar { display: grid; grid-template-columns: repeat(5, 1fr); border: 2px solid var(--ink); background: var(--card); box-shadow: var(--shadow); }
.stat { padding: 8px 6px; text-align: center; border-right: 1px solid var(--rule); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat-l { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat-v { display: block; font-size: clamp(16px, 4.6vw, 24px); font-weight: 700; line-height: 1.2; }
#timer.paused { color: var(--accent); }

.play { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.side { display: contents; }
.statbar { order: 0; } .board { order: 1; } .side-h, .words, .controls { order: 2; }
@media (min-width: 900px) {
  .play { display: grid; grid-template-columns: minmax(0, 580px) minmax(280px, 1fr); gap: 0 44px; align-items: start; }
  .board { grid-column: 1; grid-row: 1 / span 4; }
  .side { display: contents; }
  .statbar, .side-h, .words, .controls { grid-column: 2; }
  .side-h { margin-top: 10px; }
}

.board { min-width: 0; }
.grid-frame { position: relative; container-type: inline-size; width: 100%; max-width: 580px; margin: 0 auto; padding: 10px; background: var(--card); border: 2px solid var(--ink); box-shadow: var(--shadow); }
/* crop marks */
.grid-frame::before, .grid-frame::after { content: ""; position: absolute; width: 18px; height: 18px; border: 0 solid var(--accent); pointer-events: none; }
.grid-frame::before { top: -9px; left: -9px; border-top-width: 3px; border-left-width: 3px; }
.grid-frame::after { bottom: -9px; right: -9px; border-bottom-width: 3px; border-right-width: 3px; }

.grid { display: grid; grid-template-rows: repeat(15, 1fr); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; outline-offset: 4px; }
.row { display: grid; grid-template-columns: repeat(15, 1fr); }
.cell {
  aspect-ratio: 1; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; text-transform: uppercase;
  font-size: calc((100cqw - 20px) / 15 * .56); font-size: clamp(11px, calc((100cqw - 20px) / 15 * .56), 24px);
  line-height: 1; border-radius: 50%; position: relative; z-index: 0;
  animation: pop .5s both; animation-delay: calc(var(--r, 0) * 28ms);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: none; } }
.cell.sel { background: var(--pick); color: #1c1813; border-radius: 6px; }
.cell.found { background: var(--good-bg); color: var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--good); }
.cell.good { background: var(--good); color: #fff; border-radius: 6px; }
.cell.miss { background: var(--bad); color: #fff; border-radius: 6px; }
.cell.missed { background: var(--bad-bg); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--bad); }
.cell.cur { box-shadow: inset 0 0 0 2px var(--ink); border-radius: 6px; }
.cell.hint { box-shadow: 0 0 0 3px var(--accent); border-radius: 6px; z-index: 1; animation: ping 1.4s ease-in-out infinite; background: var(--accent); color: var(--accent-ink); }
@keyframes ping { 50% { box-shadow: 0 0 0 6px transparent; } }
.grid.locked { cursor: default; }
.grid.dim .cell { filter: blur(5px); }

.paused-cover { position: absolute; inset: 0; border: 0; background: color-mix(in srgb, var(--paper) 86%, transparent); color: var(--ink); font: 700 18px/1.3 var(--serif); padding: 24px; cursor: pointer; z-index: 5; }
.paused-cover[hidden] { display: none; }
.live { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--muted); text-align: center; }

/* Word list */
.side-h { margin: 0 0 8px; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.words { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; }
@media (min-width: 560px) and (max-width: 899px) { .words { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.words li { font-family: var(--mono); font-weight: 700; letter-spacing: .06em; font-size: 15px; padding: 4px 0; border-bottom: 1px dotted var(--rule); display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.words li::before { content: ""; flex: none; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; }
.words li.done { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--good); }
.words li.done::before { background: var(--good); border-color: var(--good); }
.words li.missed-w { color: var(--bad); }
.words li.missed-w::before { border-color: var(--bad); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.btn { font: 700 15px/1 var(--serif); letter-spacing: .02em; padding: 12px 16px; min-height: 44px; border: 2px solid var(--ink); background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: var(--card); color: var(--ink); }

/* Results */
.results { margin-top: 30px; padding: 22px; background: var(--card); border: 2px solid var(--ink); box-shadow: var(--shadow); animation: rise .5s both; }
.results[hidden], .cta[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.res-kicker { margin: 0; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.res-stars { margin: 4px 0 12px; font-size: 40px; letter-spacing: .1em; color: var(--accent); line-height: 1.1; }
.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 16px; }
.res-grid div { border-top: 3px solid var(--ink); padding-top: 6px; }
.res-grid dt { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.res-grid dd { margin: 0; font-size: clamp(18px, 5vw, 26px); font-weight: 700; }
.share-l { display: block; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.share-box { width: 100%; max-width: 440px; resize: none; padding: 10px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); font-size: 14px; line-height: 1.5; }
.res-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.copy-status { font-weight: 700; color: var(--good); }

/* CTA (revealed only after finishing) */
.cta { margin-top: 22px; padding: 18px 20px; background: var(--ink); color: var(--paper); border: 2px solid var(--ink); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; animation: rise .6s .15s both; }
.cta-k { margin: 0; font-style: italic; font-size: 18px; }
.cta-link { display: inline-block; padding: 12px 18px; min-height: 44px; background: var(--accent); color: var(--accent-ink); font-weight: 800; text-decoration: none; border: 2px solid var(--paper); max-width: 100%; }
.cta-link:hover { background: var(--pick); color: #1c1813; }

/* Long-form copy */
.copy, .faq { max-width: 70ch; margin: 54px 0 0; }
.copy h2, .faq h2 { font-size: clamp(26px, 5vw, 38px); line-height: 1.1; margin: 0 0 12px; letter-spacing: -.01em; border-top: 6px solid var(--ink); padding-top: 14px; }
.copy h3 { margin: 24px 0 4px; font-size: 20px; color: var(--accent); }
.copy p { margin: 0 0 12px; }
.steps { padding-left: 1.3em; margin: 0 0 14px; }
.steps li { margin-bottom: 6px; padding-left: 4px; }
.steps li::marker { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.cal { margin-top: 18px; border: 1px solid var(--ink); background: var(--card); padding: 10px 14px; }
.cal summary, .faq summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.cal-list { columns: 2 220px; margin: 8px 0 0; padding-left: 2.2em; font-size: 15px; }
.cal-list li { break-inside: avoid; }
.cal-list li.today { font-weight: 800; color: var(--accent); }
.faq details { border-bottom: 1px solid var(--rule); padding: 6px 0; }
.faq details p { margin: 4px 0 10px; color: var(--muted); }
.foot { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; border-top: 1px solid var(--ink); color: var(--muted); font-size: 14px; }
.foot p { margin: 0; }

@media (max-width: 420px) {
  body { font-size: 16px; }
  .stat { padding: 6px 2px; }
  .stat-l { font-size: 9px; letter-spacing: .08em; }
  .grid-frame { padding: 6px; }
  .cell { font-size: clamp(11px, calc((100cqw - 12px) / 15 * .56), 24px); }
  .btn { padding: 12px 12px; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Print sheet: hidden on screen, the only thing shown when printing */
.print-sheet { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block !important; color: #000; font-family: var(--serif); }
  .ps-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 3px solid #000; padding-bottom: 4mm; margin-bottom: 6mm; }
  .ps-title { font-size: 22pt; font-weight: 800; letter-spacing: -.01em; color: #000; }
  .ps-head p { margin: 0; font-size: 11pt; text-align: right; }
  .ps-grid { border-collapse: collapse; table-layout: fixed; width: 150mm; margin: 0 auto 7mm; border: 2px solid #000; }
  .ps-grid td { width: 10mm; height: 10mm; padding: 0; text-align: center; vertical-align: middle; font-family: var(--mono); font-weight: 700; font-size: 14pt; border: .4pt solid #bbb; }
  .ps-words { list-style: none; columns: 3; column-gap: 8mm; margin: 0 auto; padding: 0; width: 165mm; font-family: var(--mono); font-weight: 700; font-size: 11pt; }
  .ps-words li { padding: 1.4mm 0; break-inside: avoid; }
  .ps-words li::before { content: ""; display: inline-block; width: 3.2mm; height: 3.2mm; border: .5mm solid #000; margin-right: 2.5mm; vertical-align: -.4mm; }
  .ps-foot { position: fixed; left: 0; right: 0; bottom: 0; border-top: 1.5px solid #000; padding-top: 3mm; display: flex; justify-content: space-between; font-size: 10pt; }
  .ps-foot b { letter-spacing: .04em; }
}
