/* agreg_calculnum — feuille de style unique, sans dépendance externe. */

:root {
    --bg: #0a0d12;
    --bg-soft: #0e131a;
    --surface: rgba(255, 255, 255, 0.028);
    --surface-hover: rgba(255, 255, 255, 0.055);
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --accent: #5eead4;
    --accent-2: #7aa2ff;
    --warn: #fbbf24;
    --ok: #34d399;
    --text: #e8eef6;
    --muted: #8b98a8;
    --radius: 14px;
    --radius-sm: 9px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image:
        radial-gradient(55rem 40rem at 15% -12rem, rgba(94, 234, 212, 0.10), transparent 62%),
        radial-gradient(48rem 40rem at 100% 0%, rgba(122, 162, 255, 0.09), transparent 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.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;
}

/* ---------- Structure ---------- */

.layout {
    max-width: 66rem;
    margin: 0 auto;
    padding: 0 clamp(1.1rem, 4vw, 2.5rem);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.view {
    flex: 1;
    padding: clamp(2rem, 5vw, 3.5rem) 0 3rem;
}

/* ---------- Barre supérieure ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 0;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.brand__logo { display: block; width: 28px; height: 28px; }

.brand__name {
    font-family: var(--mono);
    font-size: 0.86rem;
    letter-spacing: 0.02em;
    color: var(--text);
}

.topbar__nav {
    display: flex;
    gap: 1.15rem;
    font-size: 0.84rem;
}

.topbar__nav a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.topbar__nav a:hover { color: var(--accent); }

/* ---------- En-tête de la page d'accueil ---------- */

.eyebrow {
    margin: 0 0 0.55rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.hero { padding-bottom: clamp(2.2rem, 5vw, 3.2rem); }

.hero__title {
    margin: 0;
    font-size: clamp(2rem, 5.2vw, 3.35rem);
    line-height: 1.06;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.hero__dash {
    display: inline-block;
    margin: 0 0.55rem;
    color: var(--line-strong);
    font-weight: 400;
}

.hero__accent {
    background: linear-gradient(100deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero__lede {
    max-width: 46rem;
    margin: 1.05rem 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.stats {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.9rem 0 0;
    padding: 0;
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.stat__value {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
}

.stat__label {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ---------- Catalogue ---------- */

.catalog__head {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.catalog__head h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 600;
    flex: 0 0 auto;
}

.catalog__count {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--muted);
}

.search { flex: 1 1 16rem; min-width: 12rem; }

.search input {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); outline: none; }

.docs {
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs__item + .docs__item { border-top: 1px solid var(--line); }

.doc {
    display: grid;
    grid-template-columns: 4.2rem 1fr auto;
    gap: 0.35rem 1rem;
    align-items: start;
    padding: 1.05rem 0.7rem;
    margin: 0 -0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.doc:hover { background: var(--surface-hover); }

.doc__year {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--muted);
    padding-top: 0.15rem;
}

.doc__main {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    min-width: 0;
}

.doc__title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.doc__summary {
    color: var(--muted);
    font-size: 0.885rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc__keywords {
    font-family: var(--mono);
    font-size: 0.714rem;
    color: var(--muted);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Pastilles d'état ---------- */

.pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.pill--wip { border-color: rgba(251, 191, 36, 0.45); color: var(--warn); }
.pill--done { border-color: rgba(52, 211, 153, 0.45); color: var(--ok); }
.pill--lg { padding: 0.35rem 0.8rem; font-size: 0.72rem; }

/* ---------- États ---------- */

.state {
    margin: 1.75rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.state--error {
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    background: rgba(248, 113, 113, 0.06);
}

.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Page d'un sujet ---------- */

.crumbs { margin-bottom: 1.6rem; font-size: 0.85rem; }

.crumbs a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.crumbs a:hover { color: var(--accent); }

.subject__title {
    margin: 0;
    font-size: clamp(1.55rem, 3.6vw, 2.3rem);
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.subject__summary {
    max-width: 48rem;
    margin: 0.9rem 0 0;
    color: var(--text);
    opacity: 0.86;
}

.subject__keywords {
    margin: 0.75rem 0 0;
    font-size: 0.86rem;
    color: var(--muted);
}

.label {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 0.4rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--surface-hover); border-color: var(--accent); }

.btn--accent {
    border-color: rgba(94, 234, 212, 0.5);
    color: var(--accent);
    background: rgba(94, 234, 212, 0.08);
}

.block {
    margin-top: clamp(2.4rem, 5vw, 3.4rem);
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.block h2 {
    margin: 0 0 0.6rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.block__lede { margin: 0; color: var(--muted); max-width: 48rem; }

.block--pending {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    background: var(--surface);
}

.toc {
    list-style: none;
    counter-reset: none;
    margin: 1.3rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc a {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.toc a:hover {
    background: var(--surface-hover);
    border-color: rgba(94, 234, 212, 0.35);
    transform: translateX(2px);
}

.toc__num {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent);
}

.toc__title { font-weight: 600; font-size: 0.95rem; }

.toc__hint {
    grid-column: 2;
    font-size: 0.82rem;
    color: var(--muted);
}

.viewer {
    width: 100%;
    height: min(78vh, 720px);
    margin-top: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}

/* ---------- Pied de page ---------- */

.footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0 1.75rem;
    border-top: 1px solid var(--line);
    font-size: 0.78rem;
    color: var(--muted);
}

.footer__sep { opacity: 0.5; }

/* ---------- Adaptations ---------- */

@media (max-width: 640px) {
    .doc {
        grid-template-columns: 3.4rem 1fr;
        grid-template-areas: "year main" "badge badge";
    }
    .doc__year { grid-area: year; }
    .doc__main { grid-area: main; }
    .doc .pill {
        grid-area: badge;
        justify-self: start;
        margin-top: 0.35rem;
    }
    .topbar__nav a:first-child { display: none; }
    .viewer { height: 60vh; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}

/* ---------- Résolution (article long) ---------- */

.resolution { max-width: 52rem; }

.res-head { margin-bottom: 2rem; }

.res-title {
    margin: 0;
    font-size: clamp(1.5rem, 3.4vw, 2.05rem);
    line-height: 1.2;
    letter-spacing: -0.022em;
}

.res-hint {
    margin: 0.6rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.res-body { font-size: 1rem; }

.res-body h2 {
    margin: 2.4rem 0 0.85rem;
    font-size: 1.16rem;
    letter-spacing: -0.012em;
    color: var(--text);
}

.res-body h2:first-of-type { margin-top: 1.2rem; }

.res-num {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--accent);
    margin-right: 0.15em;
}

.res-body h3 {
    margin: 2rem 0 0.7rem;
    font-size: 1.06rem;
    color: var(--text);
}

.res-body p { margin: 0.85rem 0; color: rgba(232, 238, 246, 0.88); }

.res-body strong { color: var(--text); }

.res-body em { color: var(--text); font-style: italic; }

.res-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(94, 234, 212, 0.3); }
.res-body a:hover { border-bottom-color: var(--accent); }

.res-body code {
    font-family: var(--mono);
    font-size: 0.86em;
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.res-body ul, .res-body ol { margin: 0.9rem 0; padding-left: 1.3rem; color: rgba(232, 238, 246, 0.88); }
.res-body li { margin: 0.35rem 0; }

.res-body ul.plan, .res-body ol.plan { padding-left: 1.1rem; }
.res-body ol.plan li::marker { color: var(--accent); font-family: var(--mono); font-size: 0.85em; }

.res-body ul.links, .res-body ul.refs { font-size: 0.94rem; }
.res-body ul.refs { color: var(--muted); }

.res-body .katex-display {
    margin: 1.35rem 0;
    padding: 0.85rem 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.res-body .katex { font-size: 1.03em; }

.res-body .note {
    margin: 1.6rem 0;
    padding: 0.9rem 1.1rem;
    border-left: 2px solid var(--accent);
    background: rgba(94, 234, 212, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.92rem;
    color: var(--muted);
}

/* tableaux de données */
.res-body table.data {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.res-body table.data caption {
    caption-side: bottom;
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: left;
}

.res-body table.data th,
.res-body table.data td {
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.res-body table.data thead th {
    font-family: var(--mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 500;
}

.res-body table.data tbody th {
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.res-body table.data td.bad { color: #f87171; font-family: var(--mono); }
.res-body table.data td.good { color: var(--ok); }

/* figures */
.res-body figure.fig { margin: 1.8rem 0; }

.res-body figure.fig img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.res-body figure.fig figcaption {
    margin-top: 0.7rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--muted);
}

.res-body figure.fig figcaption strong { color: var(--text); }

/* pagination */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--line);
    font-size: 0.86rem;
}

.pager a {
    color: var(--muted);
    text-decoration: none;
    max-width: 46%;
    transition: color 0.15s ease;
}

.pager a:hover { color: var(--accent); }
.pager__next { text-align: right; margin-left: auto; }
.pager__home { margin-left: auto; color: var(--accent); }

@media (max-width: 640px) {
    .res-body table.data { font-size: 0.8rem; }
    .res-body table.data th, .res-body table.data td { padding: 0.4rem 0.35rem; }
    .pager a { max-width: 100%; }
}

/* ---------- Mise en avant des résolutions ---------- */

.featured { margin-bottom: clamp(2.2rem, 5vw, 3rem); }

.featured__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.featured__head h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 600;
}

.featured__hint {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.fcards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.fcard {
    padding: 1.25rem 1.35rem;
    border: 1px solid rgba(94, 234, 212, 0.28);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(94, 234, 212, 0.07), rgba(122, 162, 255, 0.05));
}

.fcard__eyebrow {
    margin: 0 0 0.35rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.fcard__title {
    margin: 0 0 0.5rem;
    font-size: 1.18rem;
    letter-spacing: -0.015em;
}

.fcard__abstract {
    margin: 0;
    max-width: 52rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.fcard__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 1rem;
}

.btn--ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
    font-weight: 500;
}

.btn--ghost:hover { color: var(--text); border-color: var(--line-strong); }

@media (max-width: 640px) {
    .fcard__actions .btn { flex: 1 1 auto; justify-content: center; }
}
