/* ==================================================================
   Frugio — pages.css (outils, guides, pSEO, imprimables)
   Les jetons, polices et éléments signature vivent dans frugio-ui.css
   (chargé AVANT ce fichier). Ici : la mise en page des pages de
   contenu. Statique, léger, clair/sombre, impression soignée, CLS = 0.
   ================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- En-tête / navigation ---------------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 20px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  color: var(--text); text-decoration: none;
}
.brand .px {
  display: grid; grid-template-columns: repeat(3, 7px); grid-auto-rows: 7px; gap: 2px;
}
.brand .px i { background: var(--surface-2); }
.brand .px i.on { background: var(--violet); }
.site-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 13.5px; font-weight: 700; padding: 8px 10px 6px;
  border-bottom: 3px solid transparent;
}
.site-nav .pxi { font-size: 12px; }
.site-nav a:hover { color: var(--violet); }
.site-nav a[aria-current='page'] { color: var(--violet); border-bottom-color: var(--violet); }
.lang-switch {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 6px; padding: 8px 12px;
  border: var(--stitch); border-radius: var(--r);
  color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 700;
}

/* ---------------- Contenu ---------------- */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 20px 64px;
}
.page h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(28px, 5.4vw, 40px); line-height: 1.15;
  letter-spacing: 0.3px; margin: 18px 0 10px;
}
.page h2 { font-size: 22px; margin: 34px 0 10px; letter-spacing: -0.3px; }
.page h3 { font-size: 17px; margin: 22px 0 8px; }
.page p { margin: 10px 0; }
.page ul, .page ol { margin: 10px 0 10px 24px; }
.page li { margin: 5px 0; }
.page a { color: var(--violet); font-weight: 700; }
.lead { font-size: 17px; color: var(--text-muted); }
.breadcrumbs { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.breadcrumbs a { color: var(--text-muted); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 20px;
  font: inherit; font-weight: 700; font-size: 15px;
  border-radius: var(--r);
  cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
@media (prefers-reduced-motion: no-preference) { .btn { transition: transform 0.16s var(--spring); } }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--thread); border: 1.5px solid var(--thread); color: var(--accent-ink); }
.btn-ghost { background: transparent; border: var(--stitch-strong); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: default; }

.card-box {
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--r);
  padding: 18px 20px;
  margin: 18px 0;
}
.note {
  background: var(--accent-soft);
  border-left: 3px solid var(--thread);
  border-radius: var(--r);
  padding: 10px 14px;
  margin: 16px 0;
  font-size: 14.5px;
}

/* Grille de liens internes (maillage) */
.link-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin: 16px 0; padding: 0; list-style: none;
}
.link-grid a {
  display: block;
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--r);
  padding: 12px 14px;
  text-decoration: none; font-weight: 700; font-size: 14px; color: var(--text);
}
.link-grid a:hover { border-color: var(--thread); }
.link-grid a small { display: block; color: var(--text-muted); font-weight: 700; }

/* ---------------- Emplacements publicitaires (réservés, CLS = 0) ---- */
/* Dimensions FIXES : le bloc occupe déjà sa place, AdSense la remplira. */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100px;             /* bannière mobile 320×100 */
  margin: 26px 0;
  border: 1.5px dashed var(--surface-2);
  color: transparent;                      /* discret tant que vide */
  font-size: 11px;
  overflow: hidden;
}
@media (min-width: 760px) { .ad-slot { height: 90px; } } /* 728×90 */

/* ---------------- Pied de page ---------------- */
.site-footer {
  max-width: 860px; margin: 0 auto; padding: 22px 20px 40px;
  color: var(--text-muted); font-size: 13px;
}
.site-footer a { color: var(--text-muted); font-weight: 700; }

/* ==================================================================
   Mini-grille interactive (guides) — DOM accessible clavier/tactile
   ================================================================== */
.minigrid { margin: 18px 0; }
.mg-wrap {
  display: inline-grid; gap: 0; padding: 10px;
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--r);
}
.mg-corner { }
.mg-clue {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-data); font-size: 12px; font-weight: 700; color: var(--clue-ink);
  font-variant-numeric: tabular-nums; padding: 2px;
}
.mg-clue.col { flex-direction: column; justify-content: flex-end; gap: 1px; }
.mg-clue.row { justify-content: flex-end; gap: 5px; padding-right: 7px; }
.mg-clue.done { color: var(--clue-done); }
.mg-cell {
  width: 34px; height: 34px;
  border: none; border-radius: 0; padding: 0; cursor: pointer;
  background: var(--cell-bg);
  box-shadow: inset 0 0 0 0.5px var(--grid-line);
  position: relative;
  font: inherit;
  touch-action: manipulation;
}
.mg-cell:focus-visible { outline: 2.5px solid var(--violet); outline-offset: -2px; z-index: 2; }
.mg-cell::after {
  content: '';
  position: absolute; inset: 10%;
  border-radius: 2px; /* point cousu : à peine adouci */
  background: var(--cell-ink);
  transform: scale(0);
}
@media (prefers-reduced-motion: no-preference) { .mg-cell::after { transition: transform 0.16s var(--spring); } }
.mg-cell.fill::after { transform: scale(1); }
.mg-cell.mark { color: var(--cell-mark); }
.mg-cell.mark::before {
  content: '✕';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800;
}
.mg-cell.hl { background: var(--accent-soft); }
.mg-cell.demo::after { background: var(--cell-thread); }
.mg-line-hl { animation: mg-line 1.1s ease; }
@keyframes mg-line { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.mg-toolbar { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.mg-toolbar .btn { min-height: 40px; padding: 8px 14px; font-size: 13.5px; }
.mg-caption { font-size: 13.5px; color: var(--text-muted); margin-top: 8px; }
.mg-status { font-size: 13.5px; font-weight: 700; color: var(--ok); min-height: 1.4em; }

/* ==================================================================
   Solveur public
   ================================================================== */
.solver-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 14px 0; }
.solver-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.solver-controls select, .clue-input {
  font: inherit; font-size: 15px;
  padding: 9px 10px; border-radius: 0;
  border: 2px solid var(--grid-line-bold);
  background: var(--surface); color: var(--text);
  min-height: 44px;
}
.clue-input { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.clue-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
@media (max-width: 640px) { .clue-lists { grid-template-columns: 1fr; } }
.clue-col h3 { margin: 0 0 8px; }
.clue-row-line { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.clue-row-line span { width: 30px; text-align: right; font-family: var(--font-data); font-size: 12.5px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.clue-input { width: 100%; min-height: 40px; padding: 6px 10px; }
.clue-input.invalid { border-color: var(--signal); background: color-mix(in srgb, var(--signal) 7%, var(--surface)); }
.verdict {
  font-weight: 800; font-size: 17px; padding: 14px 16px; margin: 16px 0;
  border-radius: var(--r);
  background: var(--verdict-bg, var(--surface));
  border: var(--stitch);
}
.verdict.ok { --verdict-bg: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok); }
.verdict.multi { --verdict-bg: color-mix(in srgb, #e3b341 14%, var(--surface)); color: #e3b341; }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .verdict.multi { color: #7a6011; } }
:root[data-theme='light'] .verdict.multi { color: #7a6011; }
.verdict.none { --verdict-bg: color-mix(in srgb, var(--garance) 12%, var(--surface)); color: var(--garance); }
.step-text { min-height: 3.2em; font-size: 15px; }
.step-text strong { color: var(--violet); }
.solve-grid-scroll { overflow-x: auto; padding-bottom: 6px; }

/* ==================================================================
   Page pSEO jouable
   ================================================================== */
.play-board-wrap {
  position: relative;
  height: min(78vw, 560px);
  max-width: 620px;
  margin: 10px 0;
}
.play-board-wrap canvas { position: absolute; inset: 0; touch-action: none; display: block; }
.play-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.play-toolbar .tool-mode {
  width: 52px; height: 46px; cursor: pointer;
  background: transparent;
  border: var(--stitch); border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 800; color: var(--cell-mark);
}
.play-toolbar .tool-mode.active { background: var(--accent-soft); border-color: var(--thread); color: var(--thread); }
.play-toolbar .tool-mode .sq { width: 20px; height: 20px; border-radius: 2px; background: var(--cell-ink); }
.play-toolbar .tool-mode.active .sq { background: var(--thread); }
.play-win {
  font-weight: 800; color: var(--ok); font-size: 17px; min-height: 1.5em; margin: 6px 0;
}

/* ==================================================================
   Imprimables
   ================================================================== */
.print-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.print-controls label { display: flex; gap: 8px; align-items: center; font-size: 14.5px; font-weight: 700; }
.print-controls input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--violet); }
.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin: 20px 0; }
.sheet.big { grid-template-columns: 1fr; }
.pz { break-inside: avoid; }
.pz h3 { font-size: 14px; margin: 0 0 6px; color: var(--text-muted); }
.pz table { border-collapse: collapse; }
.pz td, .pz th {
  border: 1px solid var(--grid-line-bold);
  width: 17px; height: 17px; padding: 0;
  font-family: var(--font-data);
  font-size: 9.5px; font-weight: 700; text-align: center; vertical-align: middle;
  font-variant-numeric: tabular-nums; color: var(--clue-ink);
}
.pz th { border: none; }
.pz th.colclue { vertical-align: bottom; line-height: 1.15; padding-bottom: 2px; }
.pz th.rowclue { text-align: right; padding-right: 4px; white-space: nowrap; }
.pz td.b5 { border-left-width: 2px; }
.pz tr.b5 td { border-top-width: 2px; }
.pz td.on { background: var(--cell-ink); }
.solutions { display: none; }
.solutions.show { display: block; }
.solutions-title { page-break-before: always; }

/* ---------------- Impression : feuille propre N&B ---------------- */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .ad-slot, .print-controls, .btn,
  .breadcrumbs, .no-print, .site-nav, .link-grid { display: none !important; }
  .page { max-width: none; padding: 0; }
  .page h1 { font-family: var(--font-body); font-size: 20px; margin: 0 0 4px; }
  .lead, .prose-extra { display: none !important; }
  .sheet { gap: 18px; }
  .pz td, .pz th { border-color: #000; color: #000; }
  .pz td.on { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pz { page-break-inside: avoid; }
  .solutions.show { display: block; }
  a { color: #000; text-decoration: none; }
  .card-box, .note, .verdict, .mg-wrap { border-color: #999; background: #fff; }
}
