/* =========================================================================
   demo.css — pages de démonstration des projets d'école
   (/projets/qr-code, /projets/traitement-image).

   S'appuie sur portfolio.css (cartes, titres, mesures, puces) comme
   audit.css : seuls la mise en page et les contrôles communs aux démos sont
   ici. Couleurs tirées des jetons du thème, les deux thèmes fonctionnent
   donc sans règle dédiée.
   ========================================================================= */

.demo {
    --demo-largeur: 1040px;
    padding-bottom: 80px;
}
.demo-entete,
.demo-section {
    width: min(var(--demo-largeur), 100% - 2 * var(--gutter));
    margin-inline: auto;
}
/* Les scripts masquent des blocs avec l'attribut hidden : il doit l'emporter
   sur les display: grid / flex posés plus bas. */
.demo [hidden] { display: none !important; }

/* --- En-tête (même gabarit que le rapport d'audit) ------------------------ */
.demo-entete { padding-top: calc(var(--nav-height) + clamp(32px, 6vw, 72px)); }
.demo-retour {
    display: flex;
    width: fit-content;
    margin-bottom: 1.4rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}
.demo-retour:hover,
.demo-retour:focus-visible { color: var(--accent-color); }
.demo-entete h1 {
    font-size: clamp(2.1rem, 5.5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.05;
    margin-bottom: 1.1rem;
}
.demo-chapo {
    font-size: clamp(1.02rem, 1.7vw, 1.15rem);
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 44em;
    margin-bottom: 1.1rem;
}

/* --- Sections et cartes --------------------------------------------------- */
.demo-section { padding-top: 56px; }
.demo-intro { color: var(--text-secondary); line-height: 1.7; max-width: 46em; margin: -0.6rem 0 1.2rem; }
.demo-carte { padding: 22px 24px; }
.demo-carte h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.7rem; }
.demo-grille { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.demo-suite { margin-top: 1.4rem; color: var(--text-secondary); line-height: 1.6; }
.demo-suite a { color: var(--accent-color); font-weight: 600; text-decoration: none; }
.demo-suite a:hover,
.demo-suite a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

.demo-texte p { color: var(--text-secondary); line-height: 1.65; font-size: 0.95rem; }
.demo-texte p + p { margin-top: 0.7rem; }
.demo-texte strong { color: var(--text-color); }
.demo-texte code,
.demo-code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--text-color);
    overflow-wrap: anywhere;
}

/* --- Champs de formulaire ------------------------------------------------- */
.demo-champ { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 7px; align-content: start; }
.demo-champ > label,
.demo-champ > legend { font-size: 0.85rem; font-weight: 700; padding: 0; }
.demo-champ > legend { margin-bottom: 7px; }
.demo-champ textarea,
.demo-champ select,
.demo-champ input[type="number"],
.demo-champ input[type="text"] {
    width: 100%;
    font: inherit;
    color: var(--text-color);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
}
.demo-champ textarea { font-family: var(--font-mono); font-size: 0.92rem; resize: vertical; min-height: 4.5em; }
.demo-champ select { cursor: pointer; }
.demo-champ textarea:focus-visible,
.demo-champ select:focus-visible,
.demo-champ input:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; border-radius: 10px; }
.demo-aide { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }

/* Boutons radio présentés en segments. L'input reste dans le flux (hors
   écran) : clavier et lecteurs d'écran le trouvent normalement. */
.demo-segments { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-segment { position: relative; cursor: pointer; }
.demo-segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.demo-segment span {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    font-size: 0.9rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.demo-segment small { font-size: 0.78rem; color: var(--text-secondary); }
.demo-segment input:checked + span { background: var(--accent-soft); border-color: var(--accent-color); }
.demo-segment input:focus-visible + span { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* --- Onglets -------------------------------------------------------------- */
.demo-onglets {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 1.2rem;
    scrollbar-width: thin;
}
.demo-onglet {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.demo-onglet:hover { color: var(--text-color); background: var(--submenu-hover); }
.demo-onglet[aria-selected="true"] { color: var(--text-color); background: var(--accent-soft); border-color: var(--accent-color); }
.demo-onglet__num {
    display: inline-grid;
    place-items: center;
    width: 1.5em; height: 1.5em;
    border-radius: 50%;
    font-size: 0.78rem;
    background: var(--border-color);
}
.demo-onglet[aria-selected="true"] .demo-onglet__num { background: var(--accent-color); color: var(--bg-color); }

/* --- Actions -------------------------------------------------------------- */
.demo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-btn-petit { padding: 8px 14px; font-size: 0.88rem; border-radius: 10px; }
.demo-btn-petit[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.demo-noscript {
    width: min(var(--demo-largeur), 100% - 2 * var(--gutter));
    margin: 2rem auto 0;
    color: var(--text-secondary);
}

/* --- Écrans intermédiaires ------------------------------------------------ */
@media (max-width: 860px) {
    .demo-grille { grid-template-columns: 1fr; }
}

/* --- Téléphone ------------------------------------------------------------ */
@media (max-width: 560px) {
    .demo-carte { padding: 18px; }
}
