/* PrintPuzzlePro - main stylesheet
   Look: graph paper, navy ink, highlighter yellow. */
:root {
  --ink: #1b2a4a;          /* navy pen ink: text, borders */
  --muted: #56627a;        /* pencil grey: secondary text */
  --paper: #ffffff;        /* sheet of paper: cards */
  --grid: #e4ecf6;         /* graph-paper lines */
  --wash: #f5f8fc;         /* page background */
  --line: #d3dcea;         /* card borders */
  --brand: #2e5bd8;        /* blue pen: links, main buttons */
  --brand-dark: #2148b5;
  --highlight: #ffd84d;    /* highlighter yellow */
  --highlight-2: #ffb3c4;  /* pink highlighter, used sparingly */
  --radius: 14px;
  --font-head: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.6;
  background-color: var(--wash);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -0.01em; }

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header { background: var(--paper); border-bottom: 2px solid var(--ink); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: 16px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.logo::before {
  content: ""; width: 26px; height: 26px; margin-right: 10px; border: 2px solid var(--ink); border-radius: 5px;
  background:
    linear-gradient(var(--ink), var(--ink)) 33.3% 0 / 2px 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 66.6% 0 / 2px 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 33.3% / 100% 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 66.6% / 100% 2px no-repeat,
    var(--highlight);
}
.logo span { color: var(--brand); }
.nav { display: flex; gap: 6px; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.nav a:hover { background: var(--highlight); color: var(--ink); }

/* ---------- Home: hero ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding: 64px 0 48px; }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.4rem); margin: 0 0 18px; font-weight: 800; }
.hero p { color: var(--muted); font-size: 1.15rem; margin: 0 0 28px; max-width: 34em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-big { display: inline-block; padding: 14px 22px; border-radius: 10px; font-weight: 700; text-decoration: none; border: 2px solid var(--ink); }
.btn-big.solid { background: var(--ink); color: #fff; box-shadow: 4px 4px 0 var(--highlight); }
.btn-big.solid:hover { color: #fff; transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--highlight); }
.btn-big.plain { background: var(--paper); color: var(--ink); }
.btn-big.plain:hover { background: var(--highlight); color: var(--ink); }

.hero-sheet { background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; padding: 22px; box-shadow: 8px 8px 0 var(--ink); transform: rotate(1.5deg); }
.hero-sheet table { border-collapse: collapse; margin: 0 auto; }
.hero-sheet td { width: 38px; height: 38px; text-align: center; font-family: "Courier New", monospace; font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.hero-sheet td.y { background: var(--highlight); }
.hero-sheet td.p { background: var(--highlight-2); }
.hero-sheet .y.s { border-radius: 19px 0 0 19px; } .hero-sheet .y.e { border-radius: 0 19px 19px 0; }
.hero-sheet .p.s { border-radius: 19px 19px 0 0; } .hero-sheet .p.e { border-radius: 0 0 19px 19px; }
.hero-sheet .found { display: flex; gap: 14px; justify-content: center; margin-top: 14px; font-weight: 700; }
.hero-sheet .found s { text-decoration-thickness: 2px; color: var(--muted); }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .hero-sheet { transform: none; max-width: 400px; justify-self: center; }
  .hero-sheet td { width: 32px; height: 32px; font-size: 1rem; }
}

/* ---------- Home: tools ---------- */
.section-head { margin: 24px 0 18px; }
.section-head h2 { font-size: 1.9rem; margin: 0 0 6px; }
.section-head p { margin: 0; color: var(--muted); }
.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin: 0 0 56px; }
.tool-card { display: block; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); padding: 22px; text-decoration: none; color: var(--ink); }
.tool-card:hover { color: var(--ink); background: #fffbe6; }
.tool-card h2, .tool-card h3 { margin: 14px 0 6px; font-size: 1.35rem; }
.tool-card p { margin: 0; color: var(--muted); }
.tool-card .go { display: inline-block; margin-top: 14px; font-weight: 700; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.mini { display: block; height: 64px; }

/* ---------- Home: ready-made puzzles ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0 0 56px; padding: 0; list-style: none; }
.theme-grid a { display: flex; flex-direction: column; gap: 4px; height: 100%; background: var(--paper); border: 1.5px solid var(--line); border-left: 6px solid var(--tag, var(--line)); border-radius: 10px; padding: 14px 16px; text-decoration: none; color: var(--ink); font-weight: 700; }
.theme-grid a:hover { border-color: var(--ink); border-left-color: var(--tag, var(--ink)); }
.theme-grid small { font-weight: 400; color: var(--muted); font-size: .9rem; }
.tag-season { --tag: #ff8a5c; }
.tag-kids { --tag: #3bb273; }
.tag-teach { --tag: var(--brand); }
.tag-senior { --tag: #9b6dd6; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: -6px 0 16px; padding: 0; list-style: none; color: var(--muted); font-size: .95rem; }
.legend li::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--tag); }

/* ---------- Tool page layout ---------- */
.tool-page h1 { font-size: clamp(1.8rem, 3.4vw, 2.4rem); margin: 36px 0 6px; font-weight: 800; }
.tool-page .lead { color: var(--muted); margin: 0 0 26px; font-size: 1.1rem; max-width: 46em; }
.tool-layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .tool-layout { grid-template-columns: 1fr; } }

.panel { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); padding: 20px; }
.panel label { display: block; font-weight: 700; margin: 16px 0 6px; }
.panel label:first-child { margin-top: 0; }
.panel input[type=text], .panel textarea, .panel select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
.panel input[type=text]:focus, .panel textarea:focus, .panel select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px #d6e1fb; }
.panel textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.hint { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.btn { display: inline-block; border: 2px solid var(--ink); border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); background: var(--paper); }
.btn-primary { background: var(--ink); color: #fff; width: 100%; margin-top: 20px; box-shadow: 3px 3px 0 var(--highlight); }
.btn-primary:hover { background: #24385f; }
.btn-light:hover { background: var(--highlight); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

.message { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: #fff4d1; border: 1.5px solid #e9c24a; color: #6b4e00; font-size: .95rem; display: none; }
.message.show { display: block; }

/* ---------- Puzzle sheet (what gets printed) ---------- */
.sheet { background: #fff; border: 1.5px solid var(--line); border-radius: 6px; padding: 32px 28px; box-shadow: 6px 6px 0 var(--grid); }
.sheet h2 { text-align: center; margin: 0 0 4px; font-size: 1.7rem; }
.sheet .sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
.name-line { display: flex; gap: 24px; justify-content: center; margin-bottom: 20px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 10px; }

/* Word search grid */
.ws-grid { border-collapse: collapse; margin: 0 auto; }
.ws-grid td { width: 32px; height: 32px; text-align: center; font-weight: 700; font-size: 1.1rem; font-family: "Courier New", monospace; border: 1px solid #eef1f6; }
.ws-grid td.hit { background: var(--highlight); }
.word-list { columns: 3; column-gap: 24px; margin: 22px auto 0; max-width: 560px; padding: 0; list-style: none; font-weight: 700; }
.word-list li { padding: 2px 0; }

/* Crossword grid */
.cw-grid { border-collapse: separate; border-spacing: 0; margin: 0 auto; }
.cw-grid td { width: 34px; height: 34px; padding: 0; position: relative; }
.cw-grid td.cell { border: 0; box-shadow: inset 0 0 0 1px #222, 0 0 0 0.5px #222; background: #fff; }
.cw-grid td .num { position: absolute; top: 1px; left: 3px; font-size: 10px; font-weight: 700; }
.cw-grid td .ans { display: block; text-align: center; line-height: 34px; font-weight: 700; font-size: 1.1rem; }
.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.clues h3 { margin: 0 0 6px; }
.clues ol { margin: 0; padding-left: 0; list-style: none; }
.clues li { margin-bottom: 4px; }
@media (max-width: 600px) { .clues { grid-template-columns: 1fr; } }

.answer-key { margin-top: 28px; display: none; }
.answer-key.show { display: block; }
.answer-key h2 { font-size: 1.3rem; }

/* Sudoku grid */
.sd-wrap { display: flex; justify-content: center; }
.sd-wrap.sd-many { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 16px; justify-items: center; }
.sd-item h3 { text-align: center; margin: 0 0 6px; font-size: 1rem; }
.sd-grid { border-collapse: collapse; border: 2.5px solid #222; }
.sd-grid td { width: 40px; height: 40px; border: 1px solid #999; text-align: center; font-size: 1.3rem; font-weight: 700; padding: 0; }
.sd-grid td.br { border-right: 2.5px solid #222; }
.sd-grid td.bb { border-bottom: 2.5px solid #222; }
.sd-grid td.ans { color: var(--brand); font-weight: 500; }
.sd-many .sd-grid td { width: 28px; height: 28px; font-size: 1rem; }
.sd-six.sd-many { grid-template-columns: 1fr 1fr 1fr; }
.sd-six .sd-grid td { width: 22px; height: 22px; }

/* Word scramble */
.sc-list { list-style: none; padding: 0; margin: 0 auto; max-width: 640px; }
.sc-list li { display: grid; grid-template-columns: 32px 170px 1fr; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.sc-num { font-weight: 700; color: var(--muted); }
.sc-jumble { font-family: "Courier New", monospace; font-weight: 700; font-size: 1.2rem; letter-spacing: .18em; }
.sc-boxes { display: flex; flex-wrap: wrap; gap: 4px; }
.sc-box { width: 26px; height: 30px; border-bottom: 2px solid var(--ink); text-align: center; font-weight: 700; font-size: 1.1rem; line-height: 30px; }
.sc-given { color: var(--muted); }
.sc-line { display: block; width: 100%; max-width: 260px; border-bottom: 2px solid var(--ink); height: 26px; }
.sc-answers { list-style: none; padding: 0; columns: 2; font-weight: 700; font-size: 1.1rem; }
.sc-answers li { padding: 3px 0; }
.sc-answers .sc-num { margin-right: 8px; }
@media (max-width: 600px) {
  .sc-list li { grid-template-columns: 26px 1fr; }
  .sc-boxes { grid-column: 2; }
  .sc-box { width: 20px; }
}

/* Large print pages (for seniors) */
.large-print .ws-grid td { width: 44px; height: 44px; font-size: 1.5rem; }
.large-print .word-list { font-size: 1.3rem; columns: 2; }

/* Phones */
@media (max-width: 600px) {
  .sheet { padding: 14px 6px; }
  .wrap { padding: 0 14px; }
  .ws-grid td { width: 15px; height: 19px; font-size: .74rem; }
  .large-print .ws-grid td { width: 26px; height: 26px; font-size: 1rem; }
  .word-list { columns: 2; }
  .cw-grid td { width: 24px; height: 24px; }
  .cw-grid td .ans { line-height: 24px; font-size: .85rem; }
  .cw-grid td .num { font-size: 8px; }
  .sd-grid td { width: 30px; height: 30px; font-size: 1rem; }
  .sd-wrap.sd-many { grid-template-columns: 1fr; }
  .nav a { padding: 6px 8px; }
}

/* ---------- Guide / article under the tool ---------- */
.guide { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 32px; margin: 36px 0 56px; }
.guide > * { max-width: 72ch; }
.guide h2 { margin-top: 0; font-size: 1.6rem; }
.guide h2:not(:first-child) { margin-top: 32px; }
.guide h3 { margin: 26px 0 6px; font-size: 1.2rem; }
.guide li { margin-bottom: 4px; }
.guide code { background: var(--wash); padding: 2px 6px; border-radius: 4px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 2px solid var(--ink); background: var(--paper); padding: 28px 0; color: var(--muted); font-size: .95rem; }
.site-footer a { color: var(--ink); margin-right: 18px; display: inline-block; margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Print: only the puzzle sheet ---------- */
@media print {
  @page { margin: 0; }
  body { background: #fff; padding: 1.4cm 1.6cm; font-family: Arial, sans-serif; }
  .site-header, .site-footer, .panel, .btn-row, .guide, .tool-page h1, .tool-page .lead, .no-print { display: none !important; }
  .tool-layout { display: block; }
  .sheet { border: 0; padding: 0; box-shadow: none; }
  .answer-key.print-it { display: block; page-break-before: always; break-before: page; }
  .answer-key:not(.print-it) { display: none !important; }
  .ws-grid td.hit { background: #ddd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sd-grid td.ans { color: #555 !important; }
  .sd-grid td { width: 56px; height: 56px; font-size: 1.6rem; }
  .sd-many .sd-grid td { width: 34px; height: 34px; font-size: 1.1rem; }
  .sd-six .sd-grid td { width: 26px; height: 26px; }
}
