/* ==========================================================================
   Labo IA - feuille dédiée à labo-ia.html
   Fichier séparé et non en ligne : la CSP du site (style-src 'self' + une
   empreinte) refuse tout bloc <style> dont l'empreinte n'est pas déclarée.
   Tokens repris de style.css (mêmes valeurs, mêmes thèmes) pour que la page
   appartienne au portfolio sans charger ses 1 600 lignes.
   ========================================================================== */

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('../fonts/inter.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('../fonts/space-grotesk.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap; src: url('../fonts/jetbrains-mono.woff2') format('woff2'); }

/* ---------- Tokens : thème sombre par défaut, comme le portfolio ---------- */
:root {
    color-scheme: dark;

    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f2e;
    --surface: rgba(15, 15, 46, 0.82);
    --surface-solid: #0f0f2e;
    --surface-sunken: rgba(10, 10, 26, 0.55);

    --accent-start: #6366f1;
    --accent-mid: #8b5cf6;
    --accent-end: #06b6d4;
    --accent-light: #a78bfa;
    --link-accent: #06b6d4;
    --gradient-main: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    /* Bouton : indigo-600 -> violet-600, blanc à 6,3:1 et 5,7:1 (le dégradé du site,
       #6366f1 -> #8b5cf6, tombe à 4,5:1 et 4,2:1 sous un texte blanc de 16 px). */
    --gradient-btn: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;

    --border-color: rgba(99, 102, 241, 0.22);
    --border-strong: rgba(139, 92, 246, 0.55);
    --border-soft: rgba(255, 255, 255, 0.07);

    --tag-bg: rgba(139, 92, 246, 0.1);
    --tag-text: #c4b5fd;
    --icon-bg: rgba(99, 102, 241, 0.14);
    --icon-text: #a5b4fc;

    --ok-text: #6ee7b7;
    --ok-bg: rgba(16, 185, 129, 0.12);
    --info-text: #7dd3fc;
    --info-bg: rgba(14, 165, 233, 0.12);
    --req-text: #fcd34d;
    --req-bg: rgba(245, 158, 11, 0.12);

    --shadow-hover: 0 12px 32px rgba(10, 10, 26, 0.5);
    --orb-opacity: 0.4;
    --grid-line: rgba(99, 102, 241, 0.06);

    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    color-scheme: light;

    --bg-primary: #fafbff;
    --bg-secondary: #f1f3fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --surface-sunken: #f1f3fb;

    --accent-light: #7c3aed;
    --link-accent: #0e7490;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #5a6a7e;

    --border-color: rgba(99, 102, 241, 0.22);
    --border-strong: rgba(124, 58, 237, 0.55);
    --border-soft: rgba(15, 23, 42, 0.08);

    --tag-bg: rgba(99, 102, 241, 0.08);
    --tag-text: #4338ca;
    --icon-bg: rgba(99, 102, 241, 0.1);
    --icon-text: #4f46e5;

    --ok-text: #047857;
    --ok-bg: rgba(16, 185, 129, 0.1);
    --info-text: #0369a1;
    --info-bg: rgba(14, 165, 233, 0.1);
    --req-text: #92400e;
    --req-bg: rgba(245, 158, 11, 0.14);

    --shadow-hover: 0 12px 32px rgba(99, 102, 241, 0.14);
    --orb-opacity: 0.16;
    --grid-line: rgba(99, 102, 241, 0.07);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font: 16px/1.65 var(--font-body);
    font-synthesis: none;
    overflow-x: hidden;
}
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--link-accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--link-accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent-mid); color: #fff; }
code { font-family: var(--font-mono); }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon {
    width: 1.1em; height: 1.1em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

.wrap {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem);
}

/* ---------- Fond ambiant : le décor du portfolio, figé ---------- */
.ambient { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ambient__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: var(--orb-opacity);
}
.ambient__orb--1 {
    width: 520px; height: 520px; top: -220px; left: -160px;
    background: radial-gradient(circle, var(--accent-start), transparent 70%);
}
.ambient__orb--2 {
    width: 480px; height: 480px; top: -200px; right: -180px;
    background: radial-gradient(circle, var(--accent-end), transparent 70%);
    opacity: calc(var(--orb-opacity) * 0.7);
}
.ambient__grid {
    position: absolute;
    inset: 0 0 auto;
    height: 560px;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 70% 100% at 50% 0%, #000 0%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 100% at 50% 0%, #000 0%, transparent 75%);
}
.topbar, main, .footer { position: relative; z-index: 1; }

/* ---------- Barre du haut ---------- */
.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
}
.topbar__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0 0.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
}
.topbar__back:hover { color: var(--text-primary); }
.topbar__back .icon { transition: transform 0.2s var(--ease-out); }
.topbar__back:hover .icon { transform: translateX(-3px); }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 44px; height: 44px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text-primary); }
.theme-toggle .icon { grid-area: 1 / 1; width: 18px; height: 18px; }
.theme-toggle__moon { display: none; }
[data-theme="light"] .theme-toggle__sun { display: none; }
[data-theme="light"] .theme-toggle__moon { display: block; }

/* ---------- Introduction ---------- */
.intro { padding: clamp(2rem, 6vw, 4rem) 0 0; }
.intro h1 {
    margin: 0 0 1.25rem;
    font: 700 clamp(2.5rem, 7vw, 4rem)/1.05 var(--font-heading);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
/* Le dégradé de marque vit sur un filet, pas sur le texte (contraste garanti). */
.intro h1::after {
    content: '';
    display: block;
    width: 72px; height: 4px;
    margin-top: 1.1rem;
    border-radius: var(--radius-pill);
    background: var(--gradient-main);
}
.intro__lead {
    max-width: 64ch;
    margin: 0;
    font-size: clamp(1.05rem, 1.6vw, 1.15rem);
    color: var(--text-muted);
}

.intro__nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 0.75rem;
    max-width: 760px;
    margin-top: 2rem;
}
.jump {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    transition: border-color 0.2s ease, transform 0.2s var(--ease-out);
}
.jump:hover { border-color: var(--border-strong); }
.jump__count {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--icon-bg);
    color: var(--icon-text);
    font: 700 1.15rem/1 var(--font-heading);
}
.jump__text { display: flex; flex-direction: column; line-height: 1.35; }
.jump__text strong { color: var(--text-primary); font-weight: 600; }
.jump__text span { font-size: 0.875rem; color: var(--text-muted); }

/* ---------- Familles ---------- */
.family { padding-top: clamp(3rem, 7vw, 4.5rem); scroll-margin-top: 1rem; }
.family__head {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 3px solid var(--accent-mid);
}
.family--local .family__head { border-left-color: var(--accent-end); }
.family__head h2 {
    margin: 0;
    font: 600 clamp(1.5rem, 3vw, 1.85rem)/1.2 var(--font-heading);
    color: var(--text-primary);
}
.family__head p { margin: 0; max-width: 68ch; color: var(--text-muted); }

.grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(min(310px, 100%), 1fr));
}

/* ---------- Cartes ---------- */
.card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(1.25rem, 3vw, 1.75rem);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s var(--ease-out);
}
.card:focus-within { border-color: var(--border-strong); }
@media (hover: hover) and (pointer: fine) {
    .card:hover {
        border-color: var(--border-strong);
        box-shadow: var(--shadow-hover);
        transform: translateY(-3px);
    }
    .jump:hover { transform: translateY(-2px); }
}

.card__head { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 0.9rem; }
.card__icon {
    display: grid;
    place-items: center;
    width: 46px; height: 46px;
    flex: none;
    border-radius: var(--radius-md);
    background: var(--icon-bg);
    color: var(--icon-text);
}
.card__icon svg {
    width: 24px; height: 24px;
    fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
}
.card h3 {
    margin: 0;
    font: 600 1.35rem/1.25 var(--font-heading);
    color: var(--text-primary);
}
.card__desc { margin: 0 0 1.1rem; }

.tags, .specs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.tags { margin-bottom: 1.1rem; }
.tags li {
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
    background: var(--tag-bg);
    color: var(--tag-text);
    font-size: 0.8rem;
    font-weight: 500;
}

.specs {
    align-items: center;
    gap: 0.5rem 0.9rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
    font-size: 0.875rem;
    color: var(--text-muted);
}
.specs li:not(.specs__need) + li:not(.specs__need)::before {
    content: '';
    display: inline-block;
    width: 4px; height: 4px;
    margin: 0 0.9rem 0.2em 0;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
    vertical-align: middle;
}
.specs__need {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.7rem 0.25rem 0.55rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.82rem;
    line-height: 1.35;
}
.specs__need .icon { width: 15px; height: 15px; }
.specs__need--ok { background: var(--ok-bg); color: var(--ok-text); }
.specs__need--info { background: var(--info-bg); color: var(--info-text); }
.specs__need--req { background: var(--req-bg); color: var(--req-text); }
.specs__need--opt { background: var(--tag-bg); color: var(--tag-text); }

.card__foot { display: grid; gap: 0.75rem; margin-top: 1.1rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius-pill);
    background: var(--gradient-btn);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
    text-align: center;
    transition: filter 0.15s ease, transform 0.2s var(--ease-out);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }

.hash {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.35rem 0.6rem;
    padding: 0.6rem 0.75rem 0.7rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}
.hash__label {
    font: 600 0.72rem/1.4 var(--font-mono);
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.hash__value {
    grid-column: 1 / -1;
    min-width: 0;
    /* Deux lignes de 32 caractères, jamais un caractère orphelin */
    max-width: 33ch;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
    user-select: all;
}
/* Ajouté par le script : sans lui, l'empreinte reste sélectionnable d'un clic. */
.hash__copy {
    grid-column: 2;
    grid-row: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
    margin: -0.2rem -0.3rem -0.2rem 0;
    padding: 0 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font: 500 0.78rem/1 var(--font-body);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.hash__copy:hover { border-color: var(--border-strong); color: var(--text-primary); }
.hash__copy .icon { width: 14px; height: 14px; }
.hash__copy.is-done { color: var(--ok-text); border-color: currentColor; }

/* ---------- Bon à savoir ---------- */
.notes {
    margin-top: clamp(3rem, 7vw, 4.5rem);
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.notes h2 {
    margin: 0 0 1rem;
    font: 600 1.35rem/1.25 var(--font-heading);
    color: var(--text-primary);
}
.notes__list {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.notes__list li { display: flex; gap: 0.85rem; align-items: flex-start; }
.notes__list .icon { width: 20px; height: 20px; margin-top: 0.2rem; color: var(--icon-text); }
.notes__list p { margin: 0; max-width: 78ch; }
.notes code {
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    background: var(--surface-sunken);
    border: 1px solid var(--border-soft);
    font-size: 0.85em;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* ---------- Pied de page ---------- */
.footer {
    padding-top: 2.5rem;
    padding-bottom: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer p { margin: 0; padding-top: 1.5rem; border-top: 1px solid var(--border-soft); }

/* ---------- Préférences d'affichage ---------- */
@media (prefers-reduced-motion: reduce) {
    .card, .jump, .btn, .topbar__back .icon { transition: border-color 0.15s ease, color 0.15s ease; }
    .card:hover, .jump:hover, .topbar__back:hover .icon, .btn:active { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
    .card, .jump, .notes { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
    .ambient { display: none; }
}
@media (prefers-contrast: more) {
    :root, [data-theme="light"] { --border-color: var(--text-muted); --border-soft: var(--text-muted); }
    .intro__lead, .family__head p, .specs, .footer { color: var(--text-secondary); }
}
@media print {
    .ambient, .theme-toggle, .hash__copy { display: none !important; }
    .card { break-inside: avoid; backdrop-filter: none; }
}
