/* ==========================================================================
   PhoboSpawn — feuille de style principale
   1. Base       2. Menu de gauche   3. Contenu    4. DoorScape (habillage sombre)
   5. Fiche de cours              6. Mobile (tiroir + ascenseur)
   ========================================================================== */

/* ---------------------------- 1. BASE ----------------------------------- */
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    background: #ecf0f1;
    color: #1c2430;
    line-height: 1.6;
}

/* ------------------------ 2. MENU DE GAUCHE ----------------------------- */
.left-menu {
    width: 250px;
    flex: none;
    background: #2c3e50;
    color: white;
    min-height: 100vh;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.left-menu a { color: white; text-decoration: none; }
.left-menu ul { list-style: none; padding: 0; }
.left-menu li { margin: 10px 0; }

.left-menu .logo { font-size: 22px; margin: 0 0 14px; }
.left-menu .logo a { color: #fff; }

.menu-section {
    margin-top: 20px;
    font-size: 18px;
    border-bottom: 1px solid #aaa;
}

.menu-lang {
    margin: 22px 0 0;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .2);
    font-size: 14px;
}
.menu-lang a { color: #7fc4ec; }

/* -------------------------- 3. CONTENU ---------------------------------- */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
}

.top-banner {
    background: #3498db;
    color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
}
.top-banner h1 { margin: 0 0 6px; }
.top-banner p  { margin: 0; }

.footer {
    margin-top: 30px;
    font-size: 12px;
    opacity: .8;
}

/* ============ 4. DOORSCAPE — habillage sombre PhoboSpawn ==================
   doorscape.js injecte lui-même son CSS clair dans <head>. On repasse par-dessus
   en préfixant par .left-menu (spécificité plus forte) pour le fond bleu nuit.
   ------------------------------------------------------------------------ */
.left-menu #c2o-ds {
    --ds-accent: #5dade2;
    --ds-accent-2: #3498db;
    --ds-hover: rgba(255, 255, 255, .10);
    --ds-hover-bd: rgba(255, 255, 255, .22);
    --ds-sub-bg: rgba(255, 255, 255, .05);
    --ds-text: #ffffff;
    --ds-muted: #9fb3c8;
}
.left-menu #c2o-ds .ds-title { color: #9fb3c8; }

.left-menu #c2o-ds .ds-row > a,
.left-menu #c2o-ds .ds-row > .ds-lbl { color: #dce9f5; font-size: 14.5px; }
.left-menu #c2o-ds .ds-row.ds-block > a,
.left-menu #c2o-ds .ds-row.ds-block > .ds-lbl { color: #ffffff; }
.left-menu #c2o-ds .ds-row.ds-muted > a { color: #7f8fa0; }
.left-menu #c2o-ds .ds-row .ds-soon { color: #7f8fa0; }

.left-menu #c2o-ds .ds-toggle:hover {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .28);
    color: #ffffff;
}

/* La PORTE : le bouton qui remplace le menu par le sous-menu */
.left-menu #c2o-ds .ds-door {
    background: rgba(52, 152, 219, .22);
    border-color: rgba(93, 173, 226, .55);
    color: #7fc4ec;
}
.left-menu #c2o-ds .ds-door:hover {
    background: linear-gradient(145deg, #5dade2, #3498db);
    color: #ffffff;
    border-color: transparent;
}

.left-menu #c2o-ds .ds-collapse { border-left-color: rgba(255, 255, 255, .22); }

/* La SORTIE : on quitte le sous-menu */
.left-menu #c2o-ds .ds-exit {
    background: rgba(52, 152, 219, .22);
    border-color: rgba(93, 173, 226, .55);
    color: #cfe6f7;
}
.left-menu #c2o-ds .ds-exit:hover {
    background: linear-gradient(145deg, #5dade2, #3498db);
    color: #ffffff;
}
.left-menu #c2o-ds .ds-exit .ds-depth {
    background: #2c3e50;
    color: #7fc4ec;
    border-color: rgba(93, 173, 226, .55);
}

/* Fil d'Ariane */
.left-menu #c2o-ds .ds-crumb { color: #9fb3c8; }
.left-menu #c2o-ds .ds-crumb button { color: #7fc4ec; }
.left-menu #c2o-ds .ds-crumb button:hover { background: rgba(255, 255, 255, .10); }
.left-menu #c2o-ds .ds-crumb .ds-sep { color: #6b7d8f; }
.left-menu #c2o-ds .ds-crumb .ds-cur { color: #ffffff; }

/* CATÉGORIE : gros titre statique, séparateur entre les blocs du menu */
.left-menu #c2o-ds .ds-cat {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, .35);
}

/* --------------------- 5. FICHE DE COURS -------------------------------- */
.lecon { max-width: 760px; }
.lecon h2 { margin-top: 0; }
.lecon h3 { margin-top: 28px; color: #2c3e50; }

.lecon-age {
    display: inline-block;
    background: #e8f4fc;
    border: 1px solid #bcd9ea;
    color: #21618c;
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.encadre {
    background: #fff;
    border-left: 4px solid #3498db;
    border-radius: 0 10px 10px 0;
    padding: 14px 18px;
    margin: 18px 0;
}
.encadre.astuce { border-left-color: #f1c40f; background: #fffdf3; }
.encadre.danger { border-left-color: #e74c3c; background: #fef6f5; }
.encadre h4 { margin: 0 0 8px; }
.encadre p:first-of-type { margin-top: 0; }
.encadre p:last-child, .encadre ul:last-child { margin-bottom: 0; }

/* ---- Formules et équations ---- */
.molecule { white-space: nowrap; font-weight: 600; }

/* Vecteur : la flèche est dessinée en CSS au-dessus de la lettre.
   Ne JAMAIS utiliser le caractère combinant U+20D7 (F⃗) : la plupart des polices
   ne le combinent pas et l'affichent comme un carré vide à côté de la lettre. */
.vec {
    position: relative;
    display: inline-block;
    font-weight: 700;
    font-style: italic;
}
.vec::after {
    content: "→";
    position: absolute;
    left: 0;
    right: 0;
    top: -.66em;
    font-size: .6em;
    line-height: 1;
    text-align: center;
    font-style: normal;
    font-weight: 400;
}

.equation {
    background: #fff;
    border: 1px solid #d5dde3;
    border-radius: 10px;
    padding: 16px 14px;
    margin: 18px 0;
    text-align: center;
    font-size: 1.3em;
    font-weight: 600;
    overflow-x: auto;
}
.equation.fausse { border-color: #e0b4b0; background: #fef6f5; }
.equation .commentaire { display: block; font-size: .62em; font-weight: 400; color: #7f8c8d; margin-top: 6px; }

/* Pastilles chaud / froid */
.exo, .endo {
    display: inline-block;
    border-radius: 999px;
    padding: 1px 10px;
    font-size: .85em;
    font-weight: 700;
}
.exo  { background: #fdecea; color: #c0392b; }
.endo { background: #e8f4fc; color: #21618c; }

/* ---- Onglets, sans une ligne de JavaScript ----
   Astuce : les volets sont places JUSTE APRES leur etiquette, donc
   `input:checked + label + .volet` suffit — aucun identifiant a enumerer dans
   le CSS, on peut ajouter un onglet sans y toucher. C'est `order` qui remet
   toutes les etiquettes sur la premiere ligne et les volets en dessous. */
.onglets { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 26px; }

.onglets > input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.onglets > label {
    order: 1;
    background: #fff;
    border: 1px solid #d5dde3;
    border-radius: 999px;
    padding: 10px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    user-select: none;
    transition: background .15s, border-color .15s;
}
.onglets > label:hover { background: #eaf3f9; border-color: #bcd9ea; }

.onglets > input:checked + label {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
    font-weight: 700;
}
.onglets > input:focus-visible + label { outline: 3px solid #5dade2; outline-offset: 2px; }

.onglets > .volet {
    order: 2;
    width: 100%;
    display: none;
    background: #fff;
    border: 1px solid #d5dde3;
    border-radius: 12px;
    padding: 18px;
}
.onglets > input:checked + label + .volet { display: block; }
.onglets > .volet > :first-child { margin-top: 0; }
.onglets > .volet > :last-child { margin-bottom: 0; }
.onglets > .volet h4 { margin: 0 0 10px; font-size: 17px; }

/* ---- Deuxième niveau : les pages DANS un onglet ----
   Exactement la même mécanique que .onglets, avec un habillage plus discret :
   l'onglet dit « quel concept », la page dit « quelle étape ». */
.pages { display: flex; flex-wrap: wrap; gap: 6px; }

.pages > input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.pages > label {
    order: 1;
    background: #f4f7fa;
    border: 1px solid #d5dde3;
    border-radius: 8px;
    padding: 8px 13px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    color: #5c6a78;
    user-select: none;
    transition: background .15s;
}
.pages > label:hover { background: #eaf3f9; }
.pages > input:checked + label {
    background: #2c3e50;
    border-color: #2c3e50;
    color: #fff;
    font-weight: 700;
}
.pages > input:focus-visible + label { outline: 3px solid #5dade2; outline-offset: 2px; }

.pages > .page {
    order: 2;
    width: 100%;
    display: none;
    padding: 18px 0 0;
    margin-top: 12px;
    border-top: 1px solid #d5dde3;
}
.pages > input:checked + label + .page { display: block; }
.pages > .page > :first-child { margin-top: 0; }

/* Précédent / Suivant : ce sont des <label>, pas des boutons */
.pas {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid #d5dde3;
}
.pas label {
    background: #3498db;
    color: #fff;
    border-radius: 8px;
    padding: 10px 15px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}
.pas label:hover { background: #5dade2; }
.pas .vide { visibility: hidden; }

/* Un lien vers un autre concept : « ceci PARCE QUE cela » */
.lien-vers {
    background: #f4f7fa;
    border-left: 3px solid #3498db;
    border-radius: 0 8px 8px 0;
    padding: 11px 14px;
    margin: 10px 0;
}

/* Niveau d'un exercice */
.niv {
    font-size: .8em;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 9px;
    margin-right: 6px;
    white-space: nowrap;
}
.n1 { background: #e8f8f0; color: #1e8449; }
.n2 { background: #fef5e7; color: #b9770e; }
.n3 { background: #fdecea; color: #c0392b; }

/* Corrigé replié : on ne le voit pas avant d'avoir cherché */
.lecon details {
    background: #f4f7fa;
    border-radius: 8px;
    padding: 11px 14px;
    margin: 8px 0 18px;
}
.lecon summary {
    cursor: pointer;
    font-weight: 600;
    color: #3498db;
    min-height: 24px;
}
.lecon details[open] summary { margin-bottom: 8px; }
.lecon details > :last-child { margin-bottom: 0; }

.lecon table {
    border-collapse: collapse;
    width: 100%;
    margin: 18px 0;
    background: #fff;
}
.lecon th, .lecon td {
    border: 1px solid #d5dde3;
    padding: 8px 10px;
    text-align: left;
}
.lecon th { background: #eaf3f9; }

.table-scroll { overflow-x: auto; }

/* ---- Schémas SVG animés ----
   Un schéma large (900x400) devient illisible sur un téléphone : les lettres
   tombent sous 5 px. Chaque schéma existe donc en deux dispositions, et c'est
   le CSS qui choisit. Voir SpawnBase-MDs/50-chimie/50.03. */
.schema { margin: 22px 0; text-align: center; }
.schema svg { width: 100%; height: auto; }
.schema-large  { max-width: 820px; }
.schema-etroit { display: none; max-width: 400px; }
.schema figcaption {
    color: #5c6a78;
    font-size: 14.5px;
    line-height: 1.5;
    margin: 10px auto 0;
    max-width: 620px;
}

@media (max-width: 640px) {
    .schema-large  { display: none; }
    .schema-etroit { display: block; }
}

.lecon-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #ccd6dd;
    font-size: 14px;
}

/* ------------- 6. MOBILE : barre, tiroir, ascenseur ---------------------- */
.pw-mobile-bar { display: none; }

.pw-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1100;
}
.pw-scrim.is-open { display: block; }

.pw-elevator {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #3498db;
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 60;
    transition: transform .18s ease;
}
.pw-elevator:hover { transform: translateY(-2px); }
.pw-elevator.is-visible { display: inline-flex; }

@media (max-width: 980px) {
    body { display: block; }

    .pw-mobile-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 50;
        background: linear-gradient(145deg, #34495e, #2c3e50);
        color: #fff;
        padding: 8px 12px;
        margin: 0 0 12px;
    }
    .pw-mobile-title { font-weight: 600; font-size: 15px; }

    .left-menu {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(88%, 300px);
        min-height: 0;
        transform: translateX(-100%);
        transition: transform .26s ease;
        box-shadow: 4px 0 26px rgba(0, 0, 0, .28);
        z-index: 1200;
    }
    .left-menu.is-open { transform: translateX(0); }

    .main-content { padding: 0 12px 40px; }
    .pw-elevator { right: 12px; bottom: 12px; }
}

/* Bouton burger animé (halo tournant + pulsation, jusqu'au premier clic) */
@property --pw-beam { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.pw-burger {
    position: relative;
    z-index: 0;
    background: linear-gradient(145deg, #5dade2, #3498db);
    border: none;
    border-radius: 11px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 8px rgba(52, 152, 219, .4);
    animation: pwPulse 2.1s ease-out infinite;
}
.pw-burger::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 13px;
    padding: 3px;
    background: conic-gradient(from var(--pw-beam), transparent 0deg, transparent 250deg, #d6f4ff 300deg, #ffffff 332deg, transparent 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: pwBeam 2.4s linear infinite;
    pointer-events: none;
}
.pw-burger span {
    display: block;
    width: 20px;
    height: 2.5px;
    background: #fff;
    position: relative;
    border-radius: 2px;
}
.pw-burger span::before,
.pw-burger span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 2.5px;
    background: #fff;
    border-radius: 2px;
}
.pw-burger span::before { top: -6px; }
.pw-burger span::after  { top:  6px; }

/* Une fois le menu découvert, on calme l'animation */
.pw-burger.pw-tamed,
.pw-burger.pw-tamed::before { animation: none; }

@keyframes pwBeam { to { --pw-beam: 360deg; } }
@keyframes pwPulse {
    0%   { box-shadow: 0 2px 8px rgba(52,152,219,.4), 0 0 0 0    rgba(52,152,219,.55); }
    70%  { box-shadow: 0 2px 8px rgba(52,152,219,.4), 0 0 0 13px rgba(52,152,219,0); }
    100% { box-shadow: 0 2px 8px rgba(52,152,219,.4), 0 0 0 0    rgba(52,152,219,0); }
}

@media (prefers-reduced-motion: reduce) {
    .pw-burger, .pw-burger::before { animation: none !important; }
}
