:root {
    --navy: #00224C;
    --blue-mid: #002EA3;
    --blue-bright: #00B8FF;
    --accent: #E6E61A;
    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-400: #94A3B8;
    --gray-600: #475569;
    --gray-800: #1E293B;
    --measure: 36rem;
    --measure-wide: 44rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inclusive Sans', system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.65;
    color: var(--gray-800);
    background: var(--white);
}

.blog-main { padding: 7rem 1.5rem 5rem; }

.article, .index-page { max-width: var(--measure); margin: 0 auto; }

/* Navigation ----------------------------------------------------------- */
/* These rules are a verbatim copy of the nav block in fr/index.html and
   en/index.html: the header is the same component on the landing page and on
   the blog. The test "blog nav CSS matches the landing page" fails if they
   ever drift apart again. */

/* body > nav, not nav: the table of contents nests its own <nav>, and a bare
   selector would pin it to the top of the page at full width. */
body > nav {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--gray-200);
    z-index: 100;
    padding: 0 2rem;
}

.nav-content {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Without an explicit colour the anchor inherits the browser's default link
   blue (#0000EE), which is off-palette and would show through any SVG path
   drawn with currentColor. */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--navy);
}

.logo svg {
    height: 28px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 2.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--navy);
}

.nav-links .btn-contact {
    background: var(--navy);
    color: var(--white);
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-links .btn-contact:hover {
    background: var(--blue-mid);
    color: var(--white);
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.lang-link {
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: color 0.2s;
}

/* Navy, not Blue Bright: at 2.3:1 on white the active language was below the
   WCAG floor. Navy reaches 15.8:1. */
.lang-link.active {
    color: var(--navy);
}

.lang-link:hover {
    color: var(--navy);
}

.lang-separator {
    color: var(--gray-200);
}

/* Blog-only: marks the section you are in. The landing page has no active
   nav link, so this rule has no counterpart there.
   The child combinator matters: the language links are also `a.active` inside
   .nav-links, and a descendant selector here would outrank .lang-link.active
   and repaint FR/EN navy. */
.nav-links > a.active {
    color: var(--navy);
}

/* Same two breakpoints as the landing page, so the header collapses at the
   same width on both. */
@media (max-width: 900px) {
    .nav-links { display: none; }
}

@media (max-width: 600px) {
    body > nav { padding: 0 1.5rem; }
}

/* Article header ------------------------------------------------------- */

.article > header { padding-bottom: 2.5rem; }

.article h1 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--navy);
    text-wrap: balance;
}

.article-meta {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--gray-600);   /* never gray-400: 2.6:1 fails contrast */
}

/* Body ----------------------------------------------------------------- */

.article > p, .article > ul, .article > ol, .article > blockquote,
.article > table { margin-top: 1.15rem; }

.article h2 {
    margin: 3rem 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
    text-wrap: balance;
}

.article h3 {
    margin: 2rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
}

.article a {
    color: var(--navy);
    text-decoration: underline;
    text-decoration-color: var(--blue-bright);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

.article a:hover { text-decoration-color: var(--navy); }

.article ul, .article ol { padding-left: 1.25rem; }
.article li { margin-top: 0.35rem; }

.article blockquote {
    padding-left: 1rem;
    border-left: 2px solid var(--blue-bright);
    font-style: italic;
    color: var(--gray-600);
}

.article strong { font-weight: 600; color: var(--navy); }

/* AutoIdentifierRule adds an empty anchor to every heading. */
.article .anchor { display: none; }

.article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.article th, .article td {
    padding: 0.5rem 0.75rem 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
    text-align: left;
}

.article th { color: var(--navy); font-weight: 600; }

/* Code ----------------------------------------------------------------- */

.article pre {
    max-width: var(--measure-wide);
    margin: 1.5rem calc((var(--measure) - var(--measure-wide)) / 2);
    padding: 1rem 1.15rem;
    background: var(--gray-100);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
}

.article :not(pre) > code {
    padding: 0.1em 0.35em;
    background: var(--gray-100);
    border-radius: 3px;
    font-size: 0.875em;
}

/* highlight.js, restricted to the brand palette rather than a stock theme */
.hljs-keyword, .hljs-built_in, .hljs-meta { color: var(--navy); font-weight: 600; }
.hljs-string, .hljs-number, .hljs-literal { color: var(--blue-mid); }
.hljs-comment { color: var(--gray-600); font-style: italic; }
.hljs-title, .hljs-function, .hljs-params { color: var(--gray-800); font-weight: 600; }

/* Figures --------------------------------------------------------------- */

.article figure {
    max-width: var(--measure-wide);
    margin: 2rem calc((var(--measure) - var(--measure-wide)) / 2);
}

.article figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
}

/* An SVG chart draws its own frame; a border would double it. */
.article figure img[src$=".svg"] {
    border: none;
    border-radius: 0;
}

.article figcaption {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--gray-600);   /* never gray-400: 2.6:1 fails contrast */
    text-align: center;
}

/* Inline images ride along with the text rather than breaking out. */
.article p > img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* Math ----------------------------------------------------------------- */

.article .katex-display {
    max-width: var(--measure-wide);
    margin: 1.75rem calc((var(--measure) - var(--measure-wide)) / 2);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
}

/* Table of contents ----------------------------------------------------- */

/* Below the breakpoint it sits in the flow above the article, the way
   benji.org's does. His is pinned left; this one is pinned right. */
.toc {
    max-width: var(--measure);
    margin: 0 auto 2.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-bottom: 0.6rem;
}

.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin-top: 0.35rem; }
.toc li.toc-h3 { padding-left: 0.85rem; }

.toc a {
    display: block;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--gray-600);
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.toc a:hover { opacity: 1; color: var(--navy); }

/* Scroll-spy sets data-active; without JavaScript the list still works as
   plain anchors, it simply never highlights. */
.toc a[data-active="true"] { opacity: 1; color: var(--navy); font-weight: 600; }

/* 1250px is where a 12rem rail at 3rem from the edge clears the 44rem
   break-out with room to spare: (W - 48 - 192) - (W/2 + 352) >= 32. */
@media (min-width: 1250px) {
    .toc {
        position: fixed;
        top: 7rem;
        right: 3rem;
        width: 12rem;
        max-width: none;
        margin: 0;
        padding: 0;
        border-bottom: none;
        max-height: calc(100vh - 10rem);
        overflow-y: auto;
    }
}

/* Index ---------------------------------------------------------------- */

.index-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.02em;
}

.index-lede { margin-top: 0.75rem; color: var(--gray-600); }

.index-empty { color: var(--gray-600); }

.post-list { margin-top: 3rem; }

.post-year {
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
}

.post-year:not(:first-child) { margin-top: 2.5rem; }

.post-list ul { list-style: none; padding: 0; }

.post-list li a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--gray-200);
    text-decoration: none;
    color: var(--navy);
}

.post-list li:last-child a { border-bottom: none; }

.post-title { font-weight: 500; }
.post-date { font-size: 0.85rem; color: var(--gray-600); white-space: nowrap; }

/* benji.org's trick: hovering the list dims every row but the one you want */
@media (min-width: 33rem) {
    .post-list:hover .post-title,
    .post-list:hover .post-date { opacity: 0.35; transition: opacity 0.14s ease; }
    .post-list li a:hover .post-title,
    .post-list li a:hover .post-date { opacity: 1; }
}

/* The single Accent element per view: Navy on yellow, never yellow on white */
.badge-new {
    margin-left: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--accent);
    color: var(--navy);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    vertical-align: 0.1em;
}

/* Article footer ------------------------------------------------------- */

.article > footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.85rem;
    color: var(--gray-600);
}

.article > footer a { color: var(--gray-600); text-decoration: none; }
.article > footer a:hover { color: var(--navy); }

/* Revision history ------------------------------------------------------ */

.article-updated { color: var(--gray-600); }

.revisions { margin-bottom: 1.5rem; }

.revisions summary {
    cursor: pointer;
    color: var(--gray-600);
    font-size: 0.85rem;
    list-style: none;
}

.revisions summary::-webkit-details-marker { display: none; }

.revisions summary::before {
    content: "+";
    display: inline-block;
    width: 1rem;
    color: var(--gray-600);
    font-weight: 600;
}

.revisions[open] summary::before { content: "\2212"; }
.revisions summary:hover { color: var(--navy); }

.revisions ul {
    list-style: none;
    padding: 0.75rem 0 0 1rem;
    margin: 0;
}

.revisions li {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}

.revisions .rev-date {
    flex: 0 0 8.5rem;
    color: var(--gray-600);
    font-variant-numeric: tabular-nums;
}

.revisions .rev-summary { color: var(--gray-800); }

@media (max-width: 30rem) {
    .revisions li { display: block; }
    .revisions .rev-date { display: block; }
}

/* Page footer ---------------------------------------------------------- */

.blog-footer {
    padding: 2.5rem 2rem 3rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.85rem;
    color: var(--gray-600);
}

.blog-footer-inner {
    max-width: var(--measure);
    margin: 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

/* No flex-wrap: at the article measure the copyright line lands within half a
   pixel of the container, and wrapping would drop RSS onto its own line. Let
   the text shrink and wrap inside its own box instead. */
.blog-footer-inner p:first-child { min-width: 0; }
.blog-footer-inner p:last-child { flex-shrink: 0; }

.blog-footer a { color: var(--gray-600); text-decoration: none; }
.blog-footer a:hover { color: var(--navy); }

/* 47rem, not 46: the break-out is 44rem wide and .blog-main takes 1.5rem of
   padding each side, so it only fits from 47rem + 1px upward. At 46rem the
   reset came one breakpoint too late and code blocks overflowed by up to 15px. */
@media (max-width: 47rem) {
    .article pre, .article .katex-display, .article figure {
        margin-left: 0; margin-right: 0;
    }
    .blog-main { padding-top: 6rem; }
}


/* Personal identity, using the Nablarise palette. */
.logo { color: var(--navy); flex-direction: column; align-items: flex-start; line-height: 1.35; flex-shrink: 0; }
.logo-name { font-size: 1.125rem; font-weight: 700; }
.logo-role { font-size: 0.9375rem; font-weight: 400; color: var(--gray-600); }
.nav-content { gap: 1.5rem; }
.nav-links { gap: 1.5rem; }
a:focus-visible { outline: 3px solid var(--blue-mid); outline-offset: 5px; }
section[id] { scroll-margin-top: 7rem; }
@media (max-width: 1000px) {
    .nav-links { display: flex; gap: 1rem; }
    .nav-links > a { display: none; }
}
@media (max-width: 600px) {
    body > nav { padding: 0 1rem; }
    .nav-content { gap: 0.75rem; }
    .logo-name { font-size: 1rem; }
}
