/* Vitrine : fiches gratuites imprimables et bloc « Besoin d'aide ? » (fichier séparé pour ne pas gêner les autres travaux sur style.css). */

/* Galerie des fiches gratuites */
.free-hero { text-align: center; padding: 28px 0 8px; }
.free-hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin: 6px 0 10px; }
.free-hero .lead { max-width: 40em; margin: 0 auto; color: var(--muted); font-size: 1.1rem; }
.free-kicker { margin: 0; font: 800 .8rem var(--font-title); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.free-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0 8px; }
.free-card { display: flex; flex-direction: column; gap: 8px; padding: 22px; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.free-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.free-card h2 { margin: 0; font-size: 1.25rem; }
.free-card p { margin: 0; color: var(--muted); flex: 1; }
.free-card .lvl { align-self: flex-start; font: 900 .85rem var(--font-title); color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; }
.free-go { font-weight: 700; color: var(--accent); }

/* Fin d'une fiche gratuite */
.free-end { margin-top: 22px; padding: 24px; text-align: center; background: var(--accent-soft); border-radius: var(--radius); }
.free-end h2 { margin: 0 0 6px; }
.free-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.print-foot { display: none; }
.print-brand { display: none; }

/* Vitrine sur l'accueil et les tarifs */
.free-showcase { margin: 36px auto; width: min(1100px, calc(100% - 32px)); }
.free-showcase h2 { margin: 0 0 6px; font-size: clamp(1.4rem, 3.4vw, 2rem); }
.free-showcase > p { margin: 0 0 4px; color: var(--muted); }

/* Bloc « Besoin d'aide ? » */
.help-block { width: min(1100px, calc(100% - 32px)); box-sizing: border-box; margin: 36px auto 28px; padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 18px 28px; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow); }
.help-block h2 { margin: 0 0 6px; font-size: 1.3rem; }
.help-block p { margin: 0 0 6px; }
.help-block .help-soon { color: var(--muted); font-size: .95rem; }
.help-block .btn { margin: 0; white-space: nowrap; }
.help-app { margin-top: 24px; }
@media (max-width: 640px) { .help-block { grid-template-columns: 1fr; } .help-block .btn { white-space: normal; overflow-wrap: anywhere; } .help-block .btn { text-align: center; } }

@media print {
  body.libre { background: #fff; }
  body.libre header, body.libre .site-head, body.libre .site-foot, body.libre .help-block { display: none !important; }
  .print-brand { display: flex; justify-content: space-between; align-items: center; margin: 0 0 5mm; padding: 0 0 3mm; border-bottom: 2px solid var(--accent); font: 800 11pt var(--font-title); color: var(--accent); }
  .print-brand span { font-weight: 500; color: #555; }
  body.libre .print-foot { display: block; margin: 6mm 0 0; padding-top: 3mm; border-top: 1px solid #bbb; text-align: center; font-size: 9pt; color: #555; }
  /* La fiche imprimée garde son bandeau de couleur : c'est ce qui la rend belle sur le papier. */
  body.libre .fiche-head { background: var(--grad); color: #fff; padding: 6mm 7mm; border-radius: 3mm; }
  body.libre .fiche-head h1 { color: #fff; }
  body.libre .fiche-head::after { display: block; }
}

/* ---------- Impression des fiches de cours (A4) : mise en page en blocs simples, sans grille, pour que rien ne se chevauche ---------- */
@media print {
  html, body { background: #fff !important; }
  body::before { display: none !important; }
  main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .fiche { font-size: 10.5pt; box-shadow: none; border: 0; border-radius: 0; overflow: visible; }
  .fiche-body, .sec, .essentiel, .exemple, .piege, .mc-body, .methode-card { display: block !important; }
  .fiche-body { padding: 0; }
  .fiche-body > .sec { margin-top: 7mm; }
  .sec > * + *, .sec .essentiel > * + *, .exemple > * + *, .piege > * + *, .mc-body > * + * { margin-top: 3mm; }
  .essentiel, .exemple, .piege { padding: 4mm 5mm; border-radius: 3mm; }
  .formule { font-size: 12.5pt; padding: 2.5mm 4mm; }
  .redac { display: block; padding: 2.5mm 4mm; font-size: 10.5pt; }
  .redac p + p { margin-top: 1.5mm; }
  .methode-card { overflow: visible; border-radius: 3mm; margin-top: 5mm; }
  .mc-head { border-radius: 3mm 3mm 0 0; padding: 3mm 5mm; }
  .mc-body { padding: 4mm 5mm; }
  .sec-head, .mc-head, .mini-title, .ex-label, .ex-sol { break-after: avoid; }
  .formule, .redac, .exemple, .piege, .fig, ol.steps li, .mm-node, .competences li { break-inside: avoid; }
  .competences { display: grid; }
  #carte { break-before: page; }
  .map { padding: 6mm; }
  .fiche .essentiel { display: flow-root !important; }
  .essentiel > .fig-in { float: right; clear: right; box-sizing: border-box; box-shadow: none; width: 66mm; max-width: 66mm; margin: 0 0 3mm 4mm; padding: 2.5mm; font-size: 8.5pt; }
  .sec .essentiel > .fig-in + * { margin-top: 0; }
  .fh-nav, .no-print { display: none !important; }
  a { color: inherit; text-decoration: none; }
}

/* Figures : petites, à droite du paragraphe qu'elles illustrent ; le texte coule autour. Centrées sur téléphone. */
.essentiel > .fig-in { float: right; clear: right; box-sizing: border-box; width: min(44%, 320px); margin: 2px 0 12px 20px; padding: 10px 12px; }
.sec .essentiel > .fig-in + * { margin-top: 0; }
.essentiel > .fig-in figcaption { font-size: .84rem; }
.essentiel > .formule { overflow: hidden; }
@media (max-width: 680px) {
  .essentiel > .fig-in { float: none; width: auto; max-width: 340px; margin: 12px auto; }
  .sec .essentiel > .fig-in + * { margin-top: 12px; }
}

/* Encadré « Rappel » dans la méthode */
.rappel { padding: 14px 18px; border-radius: 14px; background: color-mix(in srgb, #f08c00 10%, var(--card)); border: 1.5px dashed color-mix(in srgb, #f08c00 55%, transparent); }
.rappel-t { margin: 0 0 6px; font: 900 .95rem var(--font-title); color: #c77700; }
.rappel ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
@media (prefers-color-scheme: dark) { .rappel-t { color: #ffc069; } }
@media print { .rappel { break-inside: avoid; padding: 3mm 5mm; border-radius: 3mm; } .rappel ul { display: block; } }

/* Mise en avant des fiches offertes : menu du haut et accueil */
.nav-gift { font-weight: 800; }
.h3-gift { margin: 14px 0 0; }
.h3-gift a { display: inline-block; line-height: 1.7; padding: 8px 16px; border-radius: 18px; text-decoration: none; font-weight: 700; color: #fff; background: rgba(255, 201, 77, .16); border: 1.5px solid #ffc94d; }
.h3-gift a:hover { background: rgba(255, 201, 77, .3); }
.h3-gift span { padding: 2px 10px; border-radius: 999px; background: #ffc94d; color: #1a1a2e; font-size: .85rem; font-weight: 900; }

/* ---------- Impression : correctifs de robustesse (même rendu quelle que soit la largeur de page du navigateur) ---------- */
@media print {
  /* Carte mentale : toujours des cartes en grille 2 colonnes, sans liens dessinés, jamais coupée entre deux pages */
  #carte { break-before: auto; }
  .map { break-inside: avoid; padding: 5mm; background: none !important; border: 1px solid #ccd; }
  .mm { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 4mm !important; column-gap: 4mm !important; }
  .mm::before { display: none !important; }
  .mm-links { display: none !important; }
  .mm-col { display: contents !important; }
  .mm-centre { grid-column: 1 / -1; order: -1 !important; justify-items: center !important; }
  .mm-centre span { max-width: none !important; padding: 3mm 8mm !important; box-shadow: none !important; }
  .mm-node { margin: 0 !important; break-inside: avoid; box-shadow: none !important; }
  .mm-node::after { display: none !important; }
  /* Pied de page répété sur chaque page */
  body.libre .print-foot { display: none !important; }
  .fiche { font-size: 10pt; }
  .methode-card { break-inside: auto !important; }
  .exemple, .piege, .essentiel { padding: 3mm 4.5mm; }
  .fiche-body > .sec { margin-top: 5mm; }
}
@page { size: A4 portrait; margin: 12mm 12mm 16mm; @bottom-center { content: "La classe de maths · laclassedemaths.com · page " counter(page) " sur " counter(pages); font: 8pt sans-serif; color: #666; } }

/* ---------- Assistant « Besoin d'aide ? » ---------- */
.aide-bubble { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 12px 18px; border-radius: 999px; box-shadow: 0 6px 22px rgba(20, 30, 80, .35); font-size: .95rem; }
.aide-bubble.is-open { opacity: .0; pointer-events: none; }
.aide-panel { position: fixed; right: 16px; bottom: 16px; z-index: 61; width: min(380px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 32px)); display: flex; flex-direction: column; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 50px rgba(20, 30, 80, .4); overflow: hidden; }
.aide-panel[hidden] { display: none; }
.aide-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--grad, var(--accent)); color: #fff; }
.aide-head b { font: 800 1rem var(--font-title); }
.aide-panel button.aide-close { margin: 0; min-height: 0; width: 32px; height: 32px; padding: 0; border-radius: 50%; font-size: 1.3rem; line-height: 1; background: rgba(255,255,255,.2); border: 0; box-shadow: none; color: #fff; }
.aide-body { padding: 14px 16px 16px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.aide-q { margin: 0; line-height: 1.5; }
.aide-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.aide-list { display: grid; gap: 8px; }
.aide-panel button.aide-opt { margin: 0; min-height: 44px; padding: 8px 10px; background: var(--accent-soft); color: var(--text); border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent); box-shadow: none; font-weight: 700; text-align: left; }
.aide-panel .aide-grid button.aide-opt { text-align: center; padding: 8px 2px; }
.aide-panel button.aide-opt:hover { background: var(--accent); color: var(--accent-text); background-image: none; }
.aide-panel button.aide-back { margin: 0; min-height: 0; justify-self: start; padding: 6px 4px; background: none; border: 0; box-shadow: none; color: var(--accent); font-weight: 700; text-align: left; }
.aide-panel button.aide-back:hover { background: none; text-decoration: underline; }
.aide-card { display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.aide-card p { margin: 0; }
.aide-card .btn { margin: 4px 0 0; text-align: center; }
.aide-help { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.aide-soon, .aide-hint { font-size: .88rem; color: var(--muted); }
.aide-tip { background: color-mix(in srgb, #f08c00 12%, transparent); border-radius: 10px; padding: 6px 10px; }
.aide-more { margin: 0; font-size: .92rem; color: var(--muted); }
.aide-form { display: grid; gap: 8px; }
.aide-form label { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; }
.aide-form textarea, .aide-form input:not([type=checkbox]) { width: 100%; box-sizing: border-box; font: inherit; font-weight: 400; }
.aide-form .aide-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: .88rem; }
.aide-form .aide-check input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.aide-trap { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.aide-err { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--err-soft, #fde8e8); color: var(--err, #c92a2a); font-weight: 600; font-size: .9rem; }
.aide-form .btn, .aide-form button[type=submit] { margin: 0; }
@media (max-width: 520px) {
  .aide-bubble { right: 10px; bottom: 10px; padding: 10px 14px; }
  .aide-bubble b { display: none; }
  .aide-bubble span { font-size: 1.4rem; }
  .aide-panel { right: 8px; left: 8px; bottom: 8px; width: auto; max-height: calc(100vh - 16px); }
  .aide-grid { grid-template-columns: repeat(3, 1fr); }
}
@media print { .aide-bubble, .aide-panel { display: none !important; } }
.help-actions { display: grid; gap: 6px; justify-items: start; } .help-actions .small-link { margin: 0; }
@media (max-width: 640px) { .help-actions { justify-items: stretch; text-align: center; } }
.aide-suivi { border-color: color-mix(in srgb, var(--accent) 55%, transparent); border-width: 2px; }
.aide-suivi ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; font-size: .93rem; }
.aide-bilan { background: color-mix(in srgb, #2b8a3e 12%, transparent); border-radius: 10px; padding: 8px 10px; }

/* Pages publiques de cours (/cours-de-maths) : sommaire, classe, chapitre. */
.seo-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0; margin: 0 0 14px; font-size: .92rem; color: var(--muted); }
.seo-crumbs li + li::before { content: "›"; margin-right: 8px; }
.seo-head { margin: 0 0 18px; }
.seo-head h1 { font-family: var(--font-title); font-size: clamp(1.6rem, 3.4vw, 2.3rem); line-height: 1.15; margin: 0 0 10px; }
.seo-head .seo-answer { font-size: 1.08rem; max-width: 70ch; margin: 0; }
.seo-levels { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.seo-level h2 { margin: 0 0 2px; font-size: 1.2rem; }
.seo-level ul { margin: 8px 0 0; padding-left: 1.1em; display: grid; gap: 3px; }
.seo-chapters { display: grid; gap: 10px; padding-left: 1.6em; margin: 0 0 20px; }
.seo-chapters a { display: grid; gap: 2px; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.seo-chapters a b { color: var(--accent); }
.seo-chapters a span { color: var(--muted); font-size: .95rem; }
.seo-fiche .sec h2 { font-size: 1.25rem; margin: 0 0 10px; }
.seo-locked { border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; padding: 14px 16px; }
.seo-locked ul { margin: 0 0 12px; padding-left: 1.1em; display: grid; gap: 4px; }
.seo-locked .free-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; justify-content: flex-start; }
.seo-faq h3 { font-size: 1.02rem; margin: 14px 0 4px; }
.seo-faq p { margin: 0; }
.seo-around { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; margin: 18px 0 8px; }
.seo-author { font-size: .9rem; }
.seo-page .tex { white-space: nowrap; }
.seo-page .tex.math-block { white-space: normal; display: block; text-align: center; margin: .35em 0; }
.seo-byline, .x-byline { font-size: .95rem; color: var(--muted); margin: 0 0 14px; }
.x-byline { margin-top: 10px; color: inherit; opacity: .85; } .x-byline a { color: inherit; font-weight: 600; }
