/*
  Tuteur IA NSI Tle

  Auteur : Laurent Abbal (© 2026)
  Site : https://lfitokyo-nsi.codeberg.page/tuteur-ia-nsi-tle/
  Code source : https://codeberg.org/lfitokyo-nsi/tuteur-ia-nsi-tle

  Licence(s) :
  - code : AGPL-3.0-or-later (LICENSE)
*/

  /* Même charte que l'Inspecteur PEP 8 : police Consolas, fond gris-bleu,
     cadres fins bleu nuit avec ombre décalée nette. */
  :root {
    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #0f172a;        /* bleu nuit : bordures, ombres, boutons */
    --text: #1e293b;       /* slate-800 */
    --text-2: #334155;     /* slate-700 */
    --muted: #64748b;      /* slate-500 */
    --line: #cbd5e1;       /* slate-300 */
    --shadow-grey: #94a3b8;/* slate-400 */
    --accent: #2563eb;     /* blue-600 */
    --accent-light: #93c5fd; /* blue-300 */
    --ok: #16a34a;
    --code-text: #e2e8f0;
    --font: Consolas, ui-monospace, SFMono-Regular, Menlo, monospace;
  }

  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0; min-height: 100vh; padding-top: 16px;
    background: var(--bg); color: var(--text);
    font-family: var(--font); font-size: 14px; line-height: 1.6;
  }
  .wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
  button { -webkit-appearance: none; appearance: none; font-family: inherit; }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

  /* En-tête */
  header.hero { text-align: center; padding-bottom: 8px; }
  h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 800; letter-spacing: -.025em; color: var(--ink); margin: 0 0 12px; }
  h1 span { color: var(--accent); }
  .title-emoji { width: 1.1em; height: 1.1em; vertical-align: baseline; }
  .lead { color: #475569; max-width: 42rem; margin: 0 auto; font-size: .875rem; line-height: 1.25rem; }

  .steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin: 32px 0 0; padding: 0; list-style: none; counter-reset: step; text-align: left; }
  .steps li { position: relative; background: var(--surface); border: 1px solid var(--ink); border-radius: 6px; box-shadow: 5px 5px 0 var(--shadow-grey); padding: 14px 16px 14px 56px; font-size: 12px; }
  .steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 6px; background: var(--ink); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
  .steps strong { display: block; color: var(--ink); font-size: 13px; }
  .steps span { color: var(--text-2); }
  .astuce { display: flex; align-items: flex-start; justify-content: center; gap: 8px; margin: 22px 0 0; font-size: 12px; color: var(--text-2); text-align: left; }
  .astuce svg { flex: none; margin-top: -1px; }
  .astuce strong { color: var(--text); }
  .legende { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-top: 10px; }
  .legende .icones { display: flex; justify-content: flex-end; gap: 5px; }
  .legende .icones + span { color: var(--text); font-weight: 600; }

  /* Chapitres */
  main.wrap { padding-top: 8px; padding-bottom: 64px; }
  section.chapitre { padding-top: 44px; }
  .ch-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
  .ch-num { flex: none; width: 36px; height: 36px; border-radius: 6px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
  .ch-head h2 { margin: 4px 0 4px; font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.35; }
  .ch-head p { margin: 0; color: var(--text-2); font-size: 12px; }
  .notions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
  .notions li { font-size: 11px; background: var(--surface); color: #475569; border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; }

  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
  .grid-communs { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 20px; }

  /* Sections d'un chapitre (PRÉPARER LE BAC) : titre, modalités, cartes */
  .sous-section + .sous-section { margin-top: 36px; }
  .sous-section h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--accent); }
  .sous-section .ss-intro { margin: 0 0 12px; color: var(--text-2); font-size: 12px; }
  .modalites { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 20px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; line-height: 1.5; }
  .modalites dt { font-weight: 700; color: var(--text); }
  .modalites dd { margin: 0; color: var(--text-2); }

  /* Cartes : cadre fin + ombre décalée */
  .card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--ink); border-radius: 6px; box-shadow: 5px 5px 0 var(--ink); }
  .card.commun { background: var(--surface-2); box-shadow: 5px 5px 0 var(--shadow-grey); }
  .corps { display: flex; flex-direction: column; gap: 4px; padding: 16px 54px 10px 16px; }
  .titre { font-weight: 700; font-size: 14px; color: var(--ink); }
  .desc { color: #475569; font-size: 12px; }

  .voir { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--ink); background: var(--surface); color: var(--text-2); cursor: pointer; display: grid; place-items: center; transition: background .12s, color .12s; }
  .voir:hover { background: var(--ink); color: var(--accent-light); }

  /* Rangée d'icônes : ouvrir dans une IA + copier */
  .actions { display: flex; align-items: center; gap: 6px; margin-top: auto; padding: 0 16px 14px; }
  .aide { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .card.principal .aide { color: var(--line); }
  .act { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 1px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--text-2); cursor: pointer; box-shadow: 2px 2px 0 var(--ink); transition: background .12s, color .12s, transform .08s, box-shadow .08s; }
  .act:hover { background: var(--ink); color: var(--accent-light); }
  .act:active { transform: translate(2px, 2px); box-shadow: none; }
  .act svg { width: 14px; height: 14px; flex: none; }
  .act.copier { color: var(--accent); }
  .act.copier:hover { color: var(--accent-light); }
  .act.copier.ok { color: var(--ok); border-color: var(--ok); }

  /* Boutons IA avec leur nom (fenêtre d'aperçu) */
  .ia { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
  .ia button svg { width: 13px; height: 13px; flex: none; }
  .ia button { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border: 1px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--text-2); cursor: pointer; transition: background .12s, color .12s; }
  .ia button:hover { background: var(--ink); color: var(--accent-light); }

  /* Icônes dans le mode d'emploi */
  .mini { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--text-2); box-shadow: 2px 2px 0 var(--ink); }
  .mini svg { width: 13px; height: 13px; }
  .mini.bleu { color: var(--accent); }

  /* Carte mise en avant (Tuteur Python) : fond bleu nuit, comme l'éditeur */
  .card.principal { grid-column: 1 / -1; background: var(--ink); box-shadow: 5px 5px 0 var(--shadow-grey); }
  .card.principal .corps { padding: 20px 60px 12px 20px; }
  .card.principal .actions { padding: 0 20px 18px; }
  .card.principal .titre { color: #fff; font-size: 16px; }
  .card.principal .desc { color: var(--line); font-size: 13px; }
  .card.principal .act { background: #1e293b; border-color: #475569; color: var(--line); box-shadow: 2px 2px 0 #475569; }
  .card.principal .act:hover { background: #334155; color: var(--accent-light); }
  .card.principal .act.copier { color: var(--accent-light); }
  .card.principal .act.copier.ok { color: #4ade80; border-color: #4ade80; }
  .card.principal .voir { background: transparent; border-color: #475569; color: var(--line); top: 16px; right: 16px; }
  .card.principal .voir:hover { background: #1e293b; color: var(--accent-light); }

  svg.ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  /* Fenêtre modale */
  dialog { width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--ink); border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 5px 5px 0 var(--ink); font-family: var(--font); }
  dialog::backdrop { background: rgba(2, 6, 23, .75); backdrop-filter: blur(4px); }
  dialog[open] { display: flex; flex-direction: column; }
  .m-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; }
  .m-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
  .m-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
  .m-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 4px; }
  .m-close:hover { color: var(--ink); background: var(--bg); }
  .m-body { overflow: auto; margin: 0 20px; background: var(--ink); border-radius: 6px; padding: 16px; }
  .m-body pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font-family: var(--font); font-size: 12.5px; line-height: 1.65; color: var(--code-text); }
  .m-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 18px; flex-wrap: wrap; }
  .btn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 11px 22px; border-radius: 6px; border: 0; background: var(--ink); color: #fff; cursor: pointer; box-shadow: 4px 4px 0 var(--shadow-grey); transition: color .12s; }
  .btn:hover { color: var(--accent-light); }

  /* Fenêtre « Prompt trop long » : consigne de collage et bouton d'ouverture de l'IA */
  dialog.petit { width: min(480px, calc(100vw - 32px)); }
  .c-etapes { margin: 4px 20px 0; padding-left: 20px; font-size: 13px; line-height: 1.8; color: var(--text-2); }
  .c-etapes strong { color: var(--ink); }
  .c-foot { justify-content: flex-end; }
  .btn svg { width: 16px; height: 16px; flex: none; }
  .btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--shadow-grey); }

  /* Notification */
  .toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 4px 4px 0 var(--shadow-grey); font-weight: 600; font-size: 13px; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  footer { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 0 48px; }
  footer p { margin: 0 auto 6px; max-width: 46rem; }
  footer strong { color: var(--text-2); }

  @media (min-width: 768px) {
    body { padding-top: 32px; }
    h1 { font-size: 1.875rem; line-height: 2.25rem; }
  }
  @media (max-width: 640px) {
    .grid { grid-template-columns: 1fr; }
    .modalites { grid-template-columns: 1fr; gap: 2px; }
    .modalites dd + dt { margin-top: 8px; }
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .act, .toast, .btn { transition: none; }
  }

.forge-footer { margin: 100px auto 10px; text-align: center; color: #b5bac3; }
.forge-footer .forge-name { font-size: 12px; }
.forge-footer .forge-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; font-size: 11px; }
.forge-footer a { color: inherit; text-decoration: none; }
.forge-footer a:hover, .forge-footer a:focus-visible { color: #0D6EFD; }
.forge-footer .forge-links a { display: inline-flex; align-items: center; gap: 4px; }
.forge-footer .forge-credits { font-size: 11px; color: #ccd0d6; }
footer { padding-bottom: 0; }
