/* html-noogram.css — lucida theme noogram.
 *
 * Identité : DARK-FIRST · stealth · moderne. Pas de bande étroite —
 * layout LARGE pleine largeur, marges généreuses, typo bold, beaucoup
 * d'espace négatif. Le matrix-rain (canvas #global-matrix-rain, z-index 0,
 * opacité ~0.07, vert phosphore dimmé) vit DERRIÈRE le contenu ; l'article
 * sit à z-index 1 sur un backdrop semi-opaque pour rester lisible.
 *
 * Deux palettes : dark (défaut, html.dark) et light (opt-in via la touche T
 * ou ?theme=light). Le système de variables porte l'identité ; les classes
 * structurelles lucida (.lucida-nav .door-cards .door-card .lucida-title
 * .lucida-author .theme-toggle) sont préservées telles quelles.
 *
 * Provenance : matrix-rain porté de pasqal/theater/teams-bg/matrix-rain.html
 * + intégration discrète de radience/wiki-site/theme.js (canvas global).
 */

/* ── Light palette (opt-in) — clean off-white, sobre. ─────────────── */
:root {
    --ink:        #14171c;   /* corps de texte */
    --ink-strong: #05070a;   /* titres */
    --dim:        #5c6573;   /* texte secondaire */
    --faint:      #e4e7ec;   /* hairlines, bordures */
    --surface:    #f4f5f3;   /* panneaux, code, blockquote */
    --page-bg:    #fcfcfa;
    --accent:     #1f8f3a;   /* vert sobre — lien, accent */
    --accent-2:   #2fae50;   /* hover, surlignage */
    --rain:       #009a32;   /* couleur du rain en thème clair (dimmé) */
    --backdrop:   rgba(252, 252, 250, 0.78);

    --maxw:       1180px;        /* layout large — pas de bande 680px */
    --gutter:     clamp(1.5rem, 6vw, 6rem);
    --base-size:  1.0625rem;     /* 17px nominal */

    color-scheme: light;
}

/* ── Dark palette (DEFAULT) — stealth near-black, vert phosphore. ─── */
html.dark {
    color-scheme: dark;
    --ink:        #d7dce3;
    --ink-strong: #f2f5f9;
    --dim:        #828c9a;
    --faint:      #1c2128;
    --surface:    #12151a;
    --page-bg:    #08090c;       /* near-black, légèrement bleuté */
    --accent:     #3fb950;       /* github-green sobre — lien, accent */
    --accent-2:   #56d364;       /* hover, plus clair */
    --rain:       #1f7a36;       /* vert dimmé pour le rain dark */
    --backdrop:   rgba(8, 9, 12, 0.82);
}

* { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--ink);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "Helvetica Neue", Arial, sans-serif;
    font-size: var(--base-size);
    line-height: 1.68;
    letter-spacing: -0.003em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    z-index: 1;
}

/* ── Matrix-rain z-index discipline ───────────────────────────────────
 * #global-matrix-rain (injecté par rain.js) vit en position:fixed
 * z-index:0 derrière tout. Le contenu sit au-dessus. */
#global-matrix-rain {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

/* ── Article — layout LARGE, marges généreuses, backdrop lisible ──── */
article {
    position: relative;
    z-index: 1;
    max-width: var(--maxw);
    margin: clamp(3rem, 9vh, 7rem) auto clamp(4rem, 12vh, 9rem);
    padding: clamp(2rem, 5vw, 4rem) var(--gutter);
    background: var(--backdrop);
    border: 1px solid var(--faint);
    border-radius: 14px;
    backdrop-filter: blur(7px) saturate(115%);
    -webkit-backdrop-filter: blur(7px) saturate(115%);
    box-shadow: 0 24px 64px -24px rgba(0, 0, 0, 0.55);
}
html:not(.dark) article {
    box-shadow: 0 18px 48px -28px rgba(20, 30, 50, 0.22);
}

/* ── Headings — bold moderne, tracking serré, espace négatif large ── */
h1, h2, h3, h4, h5, h6 {
    color: var(--ink-strong);
    font-weight: 750;
    line-height: 1.12;
    letter-spacing: -0.025em;
    margin: 2.4em 0 0.7em;
}
h1 {
    font-size: clamp(2.6rem, 6vw, 4.4rem);
    font-weight: 820;
    letter-spacing: -0.04em;
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: 1.02;
}
h2 {
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--faint);
}
h3 { font-size: clamp(1.2rem, 2vw, 1.45rem); color: var(--ink); }
h4 { font-size: 1.12rem; color: var(--dim); font-weight: 700; }
h5 { font-size: 1rem;   color: var(--dim); font-weight: 700; }
h6 { font-size: 0.9rem; color: var(--dim); font-weight: 700;
     text-transform: uppercase; letter-spacing: 0.08em; }

h1.lucida-title { margin-top: 0; }

/* ── Body text ────────────────────────────────────────────────────── */
p, ul, ol, blockquote, pre, table { margin: 0 0 1.5rem; }
p { max-width: 72ch; }
li { margin: 0.3em 0; }

p.lucida-author {
    color: var(--dim);
    font-style: normal;
    font-weight: 500;
    margin-top: -0.4rem;
    letter-spacing: 0.01em;
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 120ms ease, border-color 120ms ease;
}
a:hover {
    color: var(--accent-2);
    border-bottom-color: var(--accent-2);
}

strong { color: var(--ink-strong); font-weight: 700; }

/* ── Code (inline + block) — stealth monospace ────────────────────── */
code {
    font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Monaco,
                 "Courier New", monospace;
    font-size: 0.88em;
    color: var(--accent-2);
    background: var(--surface);
    border: 1px solid var(--faint);
    border-radius: 5px;
    padding: 0.1em 0.4em;
}
pre {
    background: var(--surface);
    border: 1px solid var(--faint);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 1.1rem 1.3rem;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.55;
}
pre code {
    border: none;
    background: transparent;
    padding: 0;
    color: var(--ink);
    font-size: inherit;
}

/* ── Blockquote ───────────────────────────────────────────────────── */
blockquote {
    border-left: 3px solid var(--accent);
    background: var(--surface);
    padding: 0.9rem 1.4rem;
    margin: 1.8em 0;
    color: var(--dim);
    border-radius: 0 8px 8px 0;
}
blockquote p { margin-bottom: 0.5rem; }
blockquote p:last-child { margin-bottom: 0; }

/* ── Horizontal rule ──────────────────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--faint);
    margin: 3.2em 0;
}

/* ── Tables ───────────────────────────────────────────────────────── */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.8em 0;
    font-size: 0.94em;
}
th {
    background: var(--surface);
    color: var(--ink-strong);
    text-align: left;
    border-bottom: 2px solid var(--accent);
    padding: 0.65rem 0.9rem;
    font-weight: 700;
}
td {
    border-bottom: 1px solid var(--faint);
    padding: 0.6rem 0.9rem;
    vertical-align: top;
}
tr:hover td { background: var(--surface); }

/* ── Images ───────────────────────────────────────────────────────── */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.8em auto;
    border: 1px solid var(--faint);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.4rem;
}

/* ── MathJax display ──────────────────────────────────────────────── */
.math-display { overflow-x: auto; margin: 1.8rem 0; }
mjx-container[display="true"] { margin: 1em 0 !important; }

/* ── lucida-nav — barre de liens (frontmatter), large, sobre ──────── */
.lucida-nav {
    position: relative;
    z-index: 1;
    max-width: var(--maxw);
    margin: clamp(1.5rem, 4vh, 3rem) auto -1rem;
    padding: 0 var(--gutter);
    color: var(--dim);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.lucida-nav a {
    color: var(--dim);
    text-decoration: none;
    border-bottom: none;
    margin-right: 0.5rem;
}
.lucida-nav a:hover { color: var(--accent); border-bottom: none; }
.lucida-nav-sep { color: var(--faint); margin-right: 0.5rem; }

/* ── door-cards — grille d'entrées, large, hover discret ──────────── */
section.door-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.4rem;
    margin: 2.8rem 0;
}
a.door-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--faint);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 1.3rem 1.4rem 1.5rem;
    transition: transform 140ms ease, box-shadow 140ms ease,
                border-color 140ms ease;
}
a.door-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px -16px rgba(0, 0, 0, 0.5);
    border-left-color: var(--accent-2);
    border-bottom: 1px solid var(--faint);
}
a.door-card h3 {
    color: var(--ink-strong);
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    line-height: 1.2;
    border: none;
    padding: 0;
}
a.door-card p {
    color: var(--dim);
    font-size: 0.94rem;
    line-height: 1.55;
    margin: 0;
    max-width: none;
}

/* ── theme-toggle — pill fixe haut-droit, dark/light ──────────────── */
.theme-toggle {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1100;
    font-family: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    color: var(--accent);
    background: var(--backdrop);
    border: 1px solid var(--faint);
    border-radius: 999px;
    padding: 7px 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: color 120ms ease, border-color 120ms ease;
}
.theme-toggle:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* ── Responsive — collapse la grille, resserre les gouttières ─────── */
@media (max-width: 880px) {
    section.door-cards { grid-template-columns: 1fr; }
    :root { --gutter: clamp(1.2rem, 6vw, 2.4rem); }
}

/* ── Reduced motion — le rain est déjà coupé côté JS ; on neutralise
 * aussi le blur coûteux pour les surfaces sensibles. */
@media (prefers-reduced-motion: reduce) {
    a.door-card { transition: none; }
    a.door-card:hover { transform: none; }
}
