/* Le poireau et la machine — carnet de bord.
   Extends the ideesnoires house style (see /css/landing.css) with the
   vegetal green Leek Wars owns. Same ground, same serif, greener light. */

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

:root {
    --bg: #131211;
    --surface: #1a1917;
    --text: #e6e2d9;
    --text-dim: #a29d94;        /* 5.5:1 on --bg — safe for body */
    --text-faint: #6e6961;      /* decoration only, never prose */
    --border: #2b2825;

    --leek: #9ec585;            /* 9.2:1 on --bg — links, live status */
    --leek-dim: #6f8664;        /* the house green, from landing.css */
    --leek-deep: #35402f;

    --font-display: Calibri, 'Lato', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --font-body: Calibri, 'Lato', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', 'Menlo', 'Consolas', monospace;

    --measure: 66ch;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Matches the landing page: a little tooth so the near-black flats don't
   band on cheap panels. */
.grain {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.journal {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: clamp(40px, 8vw, 88px) clamp(16px, 5vw, 24px) 40px;
}

.hub {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Masthead ─────────────────────────────────────────── */

.back {
    display: inline-block;
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
    text-decoration: none;
    margin-bottom: clamp(36px, 8vw, 64px);
    transition: color 0.4s ease;
}

.back::before {
    content: '\2190\00a0\00a0';
    color: var(--text-faint);
}

.back:hover,
.back:focus-visible {
    color: var(--leek);
}

.masthead h1 {
    font-family: var(--font-display);
    font-size: clamp(2.05rem, 5.8vw, 3.3rem);
    font-weight: 300;
    letter-spacing: -0.005em;
    line-height: 1.1;
    text-wrap: balance;
    color: #f2eee5;
    margin-bottom: 24px;
}

.tagline {
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.1vw, 1.14rem);
    font-weight: 300;
    line-height: 1.65;
    color: var(--text-dim);
    max-width: 34em;
    text-wrap: pretty;
}

/* ── Hero board ───────────────────────────────────────── */

.hero {
    margin: clamp(44px, 9vw, 76px) 0 clamp(40px, 8vw, 68px);
}

.board {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.board-grid {
    fill: none;
    stroke: #302f2b;
    stroke-width: 0.6;
}

.board-obstacle {
    fill: #2e3133;
    stroke: #434a4c;
    stroke-width: 0.6;
}

.board-heat {
    stroke: none;
    fill: var(--leek);
}

/* On near-black these need real weight, or the halo reads as noise. */
.board-heat-1 { fill-opacity: 0.10; }
.board-heat-2 { fill-opacity: 0.24; }
.board-heat-3 { fill-opacity: 0.46; }

.board-self path,
.board-enemy path {
    fill-opacity: 0.5;
    stroke-width: 0.8;
}

.board-self path   { fill: var(--leek);   stroke: var(--leek); }
.board-self circle { fill: var(--leek); }

.board-enemy path   { fill: #8f6060; stroke: #ad7373; }
.board-enemy circle { fill: #c08585; }

.hero figcaption {
    font-family: var(--font-display);
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-dim);
    max-width: 42em;
    margin-top: 28px;
    text-wrap: pretty;
}

/* ── Article ──────────────────────────────────────────── */

.kicker {
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--leek);
    margin-bottom: 18px;
}

.article {
    max-width: var(--measure);
    margin-top: clamp(8px, 2vw, 16px);
}

.article p {
    font-size: 1.06rem;
    line-height: 1.72;         /* humanist sans: tighter than the old serif */
    color: var(--text);
    margin-bottom: 1.5em;
    text-wrap: pretty;
}

.lede {
    font-family: var(--font-display);
    font-size: clamp(1.12rem, 2.4vw, 1.34rem) !important;
    font-weight: 400;
    line-height: 1.6 !important;
    color: #ece8df;
    margin-bottom: 2em !important;
}

.article section {
    margin-top: clamp(48px, 7vw, 76px);
}

.article h2 {
    font-family: var(--font-display);
    font-size: clamp(1.32rem, 2.9vw, 1.6rem);
    font-weight: 400;
    letter-spacing: 0.005em;
    color: #ded9d0;
    margin-bottom: 1.1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--border);
    text-wrap: balance;
}

.article h3 {
    font-family: var(--font-display);
    font-size: clamp(1.08rem, 2.2vw, 1.22rem);
    font-weight: 600;
    font-style: normal;
    letter-spacing: 0.02em;
    color: var(--leek);
    margin: 2.2em 0 0.9em;
}

.article em {
    font-style: italic;
    color: #ece8df;
}

.article strong {
    font-weight: 600;
    color: #f2eee5;
}

.article ul {
    list-style: none;
    margin: 0 0 1.6em;
}

.article ul li {
    position: relative;
    font-size: 1.06rem;
    line-height: 1.7;
    color: var(--text);
    padding-left: 1.5em;
    margin-bottom: 1em;
    text-wrap: pretty;
}

/* A rule, not a bullet: round dots on a serif page read as UI. */
.article ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.85em;
    width: 0.7em;
    height: 1px;
    background: var(--leek-dim);
}

.decisions li strong {
    display: block;
    margin-bottom: 0.2em;
}

/* The arithmetic, set apart so the reader can follow it line by line
   instead of parsing it out of a sentence. */
.sum {
    font-family: var(--font-mono);
    font-size: 0.92rem !important;
    line-height: 2.1 !important;
    color: var(--text-dim) !important;
    background: var(--surface);
    border-left: 1px solid var(--leek-dim);
    padding: 1.1em 1.4em;
    margin: 1.8em 0 !important;
    overflow-x: auto;
}

.sum strong {
    color: var(--leek);
    font-weight: 600;
}

/* ── The chart ────────────────────────────────────────── */

.chart {
    margin: clamp(32px, 5vw, 48px) 0;
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.c-budget {
    stroke: var(--text);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
}

.c-budget-label,
.c-label,
.c-val {
    font-family: var(--font-body);
    fill: var(--text-dim);
}

.c-budget-label { font-size: 11px; letter-spacing: 0.06em; }

.c-label {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.c-val { font-size: 15px; fill: var(--text); }
.c-val.c-over { fill: #d4818f; }

.c-bar.c-ok { fill: var(--leek); }

.chart figcaption {
    font-family: var(--font-display);
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-dim);
    margin-top: 22px;
    max-width: 46em;
    text-wrap: pretty;
}

/* The one thing worth stopping on. */
.callout {
    font-family: var(--font-display);
    font-size: 1.08rem !important;
    font-style: normal;
    line-height: 1.7 !important;
    color: #ece8df !important;
    background: var(--surface);
    border-top: 1px solid var(--leek-deep);
    border-bottom: 1px solid var(--leek-deep);
    padding: 1.3em 1.5em;
    margin: 2em 0 !important;
}

/* Mono only where it names real code. Anywhere else it reads as costume. */
code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    letter-spacing: -0.01em;
    color: var(--leek);
    background: var(--surface);
    padding: 0.1em 0.38em;
    border-radius: 2px;
}

/* ── Outline of what follows ──────────────────────────── */

.outline {
    list-style: none;
    counter-reset: none;
    margin-top: 2em;
}

.outline li {
    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: 8px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.outline li:last-child {
    border-bottom: 1px solid var(--border);
}

.outline-index {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--leek-dim);
    padding-top: 0.45em;
}

.outline-body {
    display: block;
    font-size: 0.97rem;
    line-height: 1.75;
    color: var(--text-dim);
    max-width: 52ch;
    text-wrap: pretty;
}

.outline-body strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #ded9d0;
    margin-bottom: 6px;
}

/* ── Hub index (same grammar as the landing rows) ─────── */

.index { flex: 1; }

.row {
    --accent-row: var(--leek);

    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 12px 24px;
    padding: clamp(26px, 4vh, 38px) 4px;
    border-top: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    isolation: isolate;
    transition: border-color 0.5s var(--ease);
}

.row::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(100deg,
        color-mix(in oklab, var(--accent-row) 14%, transparent),
        transparent 62%);
    opacity: 0;
    transition: opacity 0.5s var(--ease);
}

.row:hover::before,
.row:focus-visible::before { opacity: 1; }

.row:hover,
.row:focus-visible {
    border-top-color: color-mix(in oklab, var(--accent-row) 42%, var(--border));
}

.row-main { display: block; min-width: 0; }

.row-title {
    position: relative;
    display: inline-block;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: #ded9d0;
    text-wrap: balance;
    transition: color 0.5s var(--ease), transform 0.6s var(--ease);
}

/* The edge: a hairline drawn under the title, left to right, on hover. */
.row-title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.28em;
    height: 1px;
    background: var(--accent-row);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s var(--ease);
}

.row:hover .row-title::after,
.row:focus-visible .row-title::after {
    transform: scaleX(1);
}

.row:hover .row-title,
.row:focus-visible .row-title {
    color: #f6f2e9;
    transform: translateX(7px);
}

.row-desc {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(0.95rem, 2vw, 1.06rem);
    font-style: italic;
    font-weight: 300;
    line-height: 1.65;
    color: var(--text-dim);
    max-width: 58ch;
    margin-top: 18px;
    text-wrap: pretty;
    transition: color 0.5s var(--ease), transform 0.6s var(--ease);
}

.row:hover .row-desc,
.row:focus-visible .row-desc {
    color: #bab5ab;
    transform: translateX(7px);
}

.row-kind {
    display: flex;
    align-items: center;
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-dim);
    transition: color 0.5s var(--ease);
}

.row:hover .row-kind,
.row:focus-visible .row-kind { color: var(--accent-row); }

.row-arrow {
    display: inline-block;
    width: 0;
    margin-left: 0;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.45s var(--ease), transform 0.5s var(--ease),
                width 0.5s var(--ease), margin-left 0.5s var(--ease);
}

.row:hover .row-arrow,
.row:focus-visible .row-arrow {
    width: 1em;
    margin-left: 0.7em;
    opacity: 1;
    transform: translateX(0);
}

.row:focus-visible {
    outline: 1px solid color-mix(in oklab, var(--accent-row) 55%, transparent);
    outline-offset: 6px;
}

.row-game    { --accent-row: #a89980; }
.row-carnet  { --accent-row: var(--leek); }
.row-ranking { --accent-row: #d0a95a; }   /* l'or poussiéreux du classement Dalton */

.status {
    font-family: var(--font-body);
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--leek);
}

.status.is-todo { color: var(--text-dim); }

.figure {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.figure::before {
    content: '\00b7\00a0\00a0';
    color: var(--text-faint);
}

/* Done and in-flight entries carry a little more light than the plan.
   --leek-dim reads at 3.6:1, so the brighter --leek does the text work. */
.is-done .entry-index,
.is-live .entry-index { color: var(--leek); }

.is-done h3,
.is-live h3 { color: #e6e1d8; }

.is-live { border-top-color: var(--leek-deep); }

.is-live .entry-body > p:first-of-type { color: var(--text); }

/* ── Footer ───────────────────────────────────────────── */

.journal-footer {
    margin-top: clamp(56px, 10vw, 88px);
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.journal-footer p {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--text-dim);   /* --text-faint is 3.4:1 here — under AA */
}

.journal-footer a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.4s ease;
}

.journal-footer a:hover,
.journal-footer a:focus-visible { color: var(--leek); }

:focus-visible {
    outline: 1px solid var(--leek-dim);
    outline-offset: 4px;
}

/* ── Motion ───────────────────────────────────────────── */
/* Everything above is the visible default. Motion only ever adds. */

@media (prefers-reduced-motion: no-preference) {
    .masthead h1,
    .tagline,
    .hero,
    .premise > * {
        animation: rise 0.9s var(--ease) backwards;
    }

    .masthead h1 { animation-delay: 0.05s; }
    .tagline     { animation-delay: 0.14s; }
    .hero        { animation-delay: 0.22s; }
    .premise > :nth-child(1) { animation-delay: 0.30s; }
    .premise > :nth-child(2) { animation-delay: 0.36s; }
    .premise > :nth-child(3) { animation-delay: 0.42s; }
    .premise > :nth-child(4) { animation-delay: 0.48s; }
    .premise > :nth-child(5) { animation-delay: 0.54s; }

    /* The board settles cell by cell, then the reading heat comes up. */
    .board-grid     { animation: fade 1.6s var(--ease) 0.3s backwards; }
    .board-obstacle { animation: fade 1.6s var(--ease) 0.45s backwards; }

    .board-heat-1 { animation: heat 7s ease-in-out 1.1s infinite; }
    .board-heat-2 { animation: heat 7s ease-in-out 1.25s infinite; }
    .board-heat-3 { animation: heat 7s ease-in-out 1.4s infinite; }

    .board-self,
    .board-enemy { animation: fade 1.2s var(--ease) 0.9s backwards; }

    .index .row { animation: rise 0.85s var(--ease) backwards; }
    .index .row:nth-child(1) { animation-delay: 0.26s; }
    .index .row:nth-child(2) { animation-delay: 0.34s; }
    .hub .journal-footer { animation: rise 0.85s var(--ease) 0.46s backwards; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
}

@keyframes fade {
    from { opacity: 0; }
}

/* Breathing, not blinking: the halo drifts around its resting opacity. */
@keyframes heat {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}

/* ── Narrow viewports ─────────────────────────────────── */

@media (max-width: 560px) {
    .entry {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .entry-index {
        padding-top: 0;
        margin-bottom: 10px;
        display: block;
    }

    .entry-body p { max-width: none; }

    .row {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Kind label leads on mobile: it reads as a category, and touch has no
       hover to reveal the arrow. */
    .row-kind {
        order: -1;
        font-size: 0.62rem;
    }

    .row-arrow {
        width: 1em;
        margin-left: 0.7em;
        opacity: 1;
        transform: none;
    }

    .row-title,
    .row-desc { transform: none !important; }
}

/* ── Glossary tooltips ────────────────────────────────────
   The carnet assumes you already write a Leek Wars AI, so the game words go
   unglossed. The machine-learning words don't: any term a reader could bluff
   past carries its definition on hover and on keyboard focus. */

.gl {
    position: relative;
    border-bottom: 1px dotted var(--leek-dim);
    cursor: help;
}

.gl::after {
    content: attr(data-def);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(5px);
    width: max-content;
    max-width: min(330px, 76vw);
    font-family: var(--font-body);
    font-size: 0.83rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text);
    background: #201e1b;
    border: 1px solid var(--border);
    border-left: 2px solid var(--leek-dim);
    border-radius: 2px;
    padding: 0.75em 0.95em;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
    z-index: 5;
}

.gl:hover::after,
.gl:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.gl:focus-visible {
    outline: 1px solid var(--leek-deep);
    outline-offset: 3px;
}

/* Near the edges of the measure the centred bubble would clip. */
.gl-l::after { left: 0; transform: translateX(0) translateY(5px); }
.gl-l:hover::after,
.gl-l:focus-visible::after { transform: translateX(0) translateY(0); }

.gl-r::after { left: auto; right: 0; transform: translateX(0) translateY(5px); }
.gl-r:hover::after,
.gl-r:focus-visible::after { transform: translateX(0) translateY(0); }

/* ── What computer chess learned, and in what order ───── */

.era {
    width: 100%;
    border-collapse: collapse;
    margin: 1.9em 0 1.6em;
    font-size: 0.95rem;
}

.era th,
.era td {
    text-align: left;
    vertical-align: top;
    padding: 0.85em 1em 0.85em 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}

.era th {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding-bottom: 0.6em;
}

.era td:first-child {
    font-family: var(--font-mono);
    font-size: 0.84rem;
    color: var(--text-dim);
    white-space: nowrap;
    padding-right: 1.6em;
}

.era td:last-child { padding-right: 0; }
.era tr:last-child td { border-bottom: none; }
.era strong { color: #f2eee5; font-weight: 600; }
.era .era-note { color: var(--text-dim); }

/* The bar that finally fits. */
.c-bar.c-win { fill: var(--leek); }
.c-val.c-win { fill: var(--leek); }

/* ── Dataset grids: a few rows of the actual data, in the article ── */

.dataset {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
    display: block;
    overflow-x: auto;
}

.dataset caption {
    caption-side: top;
    text-align: left;
    font-family: var(--font-display);
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-dim);
    padding-bottom: 12px;
}

.dataset th {
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 400;
    text-align: right;
    padding: 6px 10px;
    border-bottom: 1px solid var(--leek-dim);
}

.dataset td {
    text-align: right;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.dataset th:first-child, .dataset td:first-child,
.dataset th:nth-child(2), .dataset td:nth-child(2),
.dataset th:nth-child(4), .dataset td:nth-child(4) { text-align: left; }

.dataset td strong { color: var(--leek); font-weight: 600; }
.dataset td.c-over { color: #d4818f; }

/* ---- tutoriel : notions ---- */

.notions {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1.4em;
    row-gap: 0.55em;
    margin: 0 0 1.8em;
    padding: 1.1em 1.4em;
    background: var(--surface);
    border-left: 1px solid var(--leek-dim);
}

.notions dt {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--leek);
    padding-top: 0.25em;
    max-width: 11em;
}

.notions dd {
    font-size: 0.97rem;
    line-height: 1.65;
    color: var(--text-dim);
    margin: 0;
}

@media (max-width: 560px) {
    .notions { grid-template-columns: 1fr; row-gap: 0.15em; }
    .notions dd { margin-bottom: 0.8em; }
}

.article ul.recap li::before { background: var(--leek); }
