/* ============================================================
   Sudozen — shared styles
   Palette: ink on cool paper, single deep-indigo accent
   Type: Fraunces (display) · IBM Plex Sans (body) · IBM Plex Mono (digits)
   ============================================================ */
:root {
  --bg: #eaecf0;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --ink: #1b1e27;
  --ink-soft: #5b6273;
  --ink-faint: #8a90a0;
  --line: #d9dde4;
  --line-strong: #1b1e27;
  --accent: #3a3e8c;
  --accent-deep: #2c2f6b;
  --accent-weak: #ececf6;
  --focus: #5358c7;
  --good: #2f7d5e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(27, 30, 39, .05), 0 10px 30px rgba(27, 30, 39, .07);
  --shadow-sm: 0 1px 2px rgba(27, 30, 39, .06), 0 4px 12px rgba(27, 30, 39, .05);
  --maxw: 1180px;
  --readw: 720px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #f3f4f7 0%, var(--bg) 55%) fixed;
  line-height: 1.65;
  font-size: 17px;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 560; line-height: 1.1; color: var(--ink); letter-spacing: -.01em; }

:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(234, 236, 240, .82);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-family: "Fraunces", serif; font-weight: 600; font-size: 21px; color: var(--ink); text-decoration: none; letter-spacing: -.015em; }
.brand:hover { color: var(--ink); }
.brand .glyph { width: 26px; height: 26px; display: block; }
.brand .glyph rect { fill: none; stroke: var(--ink); stroke-width: 6; }
.brand .glyph .b { stroke: var(--accent); stroke-width: 9; }
.brand .glyph .dot { fill: var(--accent); }
.nav { display: flex; gap: 6px; align-items: center; }
.nav a { color: var(--ink-soft); text-decoration: none; font-size: 15px; padding: 8px 11px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav-toggle { display: none; }
@media (max-width: 720px) {
  .nav { gap: 2px; }
  .nav a { padding: 8px 8px; font-size: 13.5px; }
}

/* ---------- generator layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
  padding: 34px 0 8px;
}
@media (max-width: 1080px) { .app { grid-template-columns: minmax(0, 1fr); } .rail { display: none; } }

.eyebrow {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent); font-weight: 500; margin: 0 0 10px;
}
.hero-title { font-size: clamp(30px, 5vw, 46px); margin: 0 0 12px; max-width: 14ch; }
.hero-sub { color: var(--ink-soft); font-size: 18px; margin: 0 0 26px; max-width: 46ch; }

.generator {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}
@media (max-width: 760px) { .generator { grid-template-columns: 1fr; padding: 18px; gap: 22px; } }

.controls { display: flex; flex-direction: column; }
.control-block { margin-bottom: 20px; }
.control-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 9px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 4px; gap: 4px; width: 100%; }
.segmented button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 540; font-size: 15px; color: var(--ink-soft);
  padding: 9px 6px; border-radius: 8px; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button .lvl { display: block; font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .1em; color: var(--ink-faint); margin-top: 2px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.segmented button[aria-pressed="true"] .lvl { color: var(--accent); }

.btn {
  font: inherit; font-weight: 560; cursor: pointer; border-radius: 10px;
  padding: 12px 18px; border: 1px solid transparent; transition: transform .08s, background .15s, border-color .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; width: 100%; font-size: 16.5px; padding: 14px; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-faint); background: var(--surface-2); }
.btn svg { width: 17px; height: 17px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 6px; }
.actions .btn { font-size: 14.5px; padding: 11px 10px; }
.actions .full { grid-column: 1 / -1; }

.opt-row { display: flex; align-items: center; gap: 9px; margin-top: 16px; font-size: 14.5px; color: var(--ink-soft); }
.opt-row input { width: 17px; height: 17px; accent-color: var(--accent); }

.meta { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--ink-faint); margin-top: 18px; line-height: 1.9; border-top: 1px dashed var(--line); padding-top: 14px; }
.meta b { color: var(--ink-soft); font-weight: 600; }
.meta .seed-edit { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; background: none; border: 0; font: inherit; padding: 0; }

/* ---------- the board ---------- */
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.board {
  --b: var(--line-strong);
  display: grid; grid-template-columns: repeat(9, 1fr); aspect-ratio: 1;
  width: 100%; max-width: 360px;
  background: var(--line-strong);
  border: 2.5px solid var(--line-strong);
  border-radius: 8px; overflow: hidden;
  user-select: none;
}
.cell {
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-weight: 500;
  font-size: clamp(17px, 4.6vw, 23px); color: var(--ink);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cell.cr0 { border-right: 0; }            /* handled by box borders below */
.cell:nth-child(9n) { border-right: 0; }
.board .cell.box-r { border-right: 2px solid var(--line-strong); }
.board .cell.box-b { border-bottom: 2px solid var(--line-strong); }
.cell.given { color: var(--ink); }
.cell.solved { color: var(--accent); font-weight: 500; }
.cell.empty { color: transparent; }
.cell.reveal { animation: pop .32s ease both; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .cell.reveal { animation: none; } }

.board.busy { opacity: .45; transition: opacity .2s; }

/* ---------- right rail / ad slots ---------- */
.rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 20px; }
.ad-slot {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  min-height: 250px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase;
}
.ad-slot.tall { min-height: 600px; }
.ad-slot.inline { min-height: 100px; margin: 8px 0; }
/* Once you paste real AdSense code, the placeholder label is hidden automatically. */
.ad-slot:has(ins) { background: transparent; border: 0; }
.ad-note { font-size: 11px; color: var(--ink-faint); text-align: center; margin-top: -10px; }

/* ---------- prose / content ---------- */
.section { padding: 30px 0; }
.section-head { max-width: var(--readw); margin: 0 auto 4px; }
.section-head .eyebrow { margin-bottom: 8px; }
.prose { max-width: var(--readw); margin: 0 auto; }
.prose h2 { font-size: clamp(24px, 3.4vw, 31px); margin: 0 0 14px; }
.prose h3 { font-size: 20px; margin: 28px 0 8px; }
.prose p { margin: 0 0 15px; color: #2c303c; }
.prose ul { margin: 0 0 15px; padding-left: 1.2em; color: #2c303c; }
.prose li { margin: 0 0 7px; }
.prose strong { color: var(--ink); }
.prose .lead { font-size: 19px; color: var(--ink-soft); }
.divider { max-width: var(--readw); margin: 8px auto; height: 1px; background: var(--line); border: 0; }

.callout {
  max-width: var(--readw); margin: 18px auto; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.callout p { margin: 0; font-size: 15.5px; color: var(--ink-soft); }
.callout strong { color: var(--ink); }

/* mini illustrative grid used inside strategy text */
.mini {
  display: inline-grid; grid-template-columns: repeat(3, 30px); grid-auto-rows: 30px;
  border: 2px solid var(--line-strong); margin: 6px 0;
}
.mini span { display: flex; align-items: center; justify-content: center; border: .5px solid var(--line); font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.mini .hi { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

/* faq */
.faq { max-width: var(--readw); margin: 0 auto; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; font-weight: 560; padding: 13px 2px; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: "IBM Plex Mono", monospace; color: var(--accent); font-size: 20px; transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 2px 16px; color: var(--ink-soft); font-size: 16px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 34px 0 50px; color: var(--ink-soft); font-size: 14.5px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 20px 40px; justify-content: space-between; align-items: flex-start; }
.site-footer .f-brand { display: flex; flex-direction: column; gap: 6px; max-width: 320px; }
.site-footer .f-brand .brand { font-size: 18px; }
.site-footer nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site-footer nav a { color: var(--ink-soft); text-decoration: none; }
.site-footer nav a:hover { color: var(--accent); }
.site-footer .fine { width: 100%; color: var(--ink-faint); font-size: 13px; border-top: 1px dashed var(--line); padding-top: 16px; margin-top: 6px; }

/* ---------- legal/simple pages ---------- */
.page { padding: 40px 0; }
.page .prose h1 { font-size: clamp(28px, 5vw, 40px); margin: 0 0 6px; }
.page .updated { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--ink-faint); margin: 0 0 26px; }

/* ---------- print: only the puzzle ---------- */
#print-root { display: none; }
@media print {
  .site-header, .site-footer, .rail, .controls, .hero-title, .hero-sub, .eyebrow,
  .section, .actions, .opt-row, .meta, .ad-slot, .ad-note, .board-wrap > .legend { display: none !important; }
  body { background: #fff; }
  .app, .generator { display: block; padding: 0; margin: 0; border: 0; box-shadow: none; }
  #print-root { display: block; }
  .print-page { page-break-after: always; text-align: center; padding-top: 12mm; }
  .print-page:last-child { page-break-after: auto; }
  .print-title { font-family: "Fraunces", serif; font-size: 22pt; margin: 0 0 2mm; }
  .print-sub { font-family: "IBM Plex Mono", monospace; font-size: 9pt; color: #555; margin: 0 0 8mm; }
  .print-grid { display: inline-grid; grid-template-columns: repeat(9, 16mm); grid-auto-rows: 16mm; border: 1.2mm solid #000; }
  .print-grid span { display: flex; align-items: center; justify-content: center; font-family: "IBM Plex Mono", monospace; font-size: 16pt; border: .2mm solid #999; }
  .print-grid span.br { border-right: .8mm solid #000; }
  .print-grid span.bb { border-bottom: .8mm solid #000; }
  .print-grid span.sol { color: #444; }
}
