/* Page « Programmation stochastique » (stochastique.php) : introduction,
   présentation animée (js/stochastique.js) et liste des chapitres. */

/* --- Introduction --- */
.sp-intro {
    margin: 0.5rem 0 2.25rem;
}

.sp-intro h1 {
    margin-top: 0;
}

.sp-lead {
    font-size: 1.12rem;
}

.sp-note {
    color: var(--color-text-light);
}

.sp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.4rem 0 0;
}

/* --- Présentation --- */
.sp-deck {
    --sp-wheat: #cf9a1d;
    --sp-corn: #4f9a45;
    --sp-beet: #9a3f74;
    --sp-sun: #f2b22e;
    --sp-cloud: #c3ccd6;
    --sp-cloud-dark: #8e99a6;
    --sp-rain: #3b7dc4;
    --sp-soft: rgba(155, 27, 48, 0.16);
    --sp-band: rgba(155, 27, 48, 0.1);
    --sp-area: rgba(44, 62, 80, 0.07);
    position: relative;
    margin: 1.25rem 0 2.75rem;
    padding: clamp(0.9rem, 2.5vw, 1.75rem);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

@media (prefers-color-scheme: dark) {
    .sp-deck {
        --sp-wheat: #e0b04a;
        --sp-corn: #6fbf63;
        --sp-beet: #cf6ca6;
        --sp-sun: #f5c451;
        --sp-cloud: #8692a3;
        --sp-cloud-dark: #5d6878;
        --sp-rain: #6fb0f0;
        --sp-soft: rgba(224, 92, 110, 0.24);
        --sp-band: rgba(224, 92, 110, 0.14);
        --sp-area: rgba(228, 233, 240, 0.07);
    }
}

.sp-deck:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

.sp-viewport {
    display: grid;
}

/* Sans JavaScript, les diapositives se lisent l'une sous l'autre, sans figure. */
.sp-slide + .sp-slide {
    margin-top: 1.75rem;
}

.sp-figure {
    display: none;
}

.sp-deck.is-ready .sp-slide {
    display: grid;
    grid-area: 1 / 1;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: clamp(1rem, 3vw, 2.25rem);
    align-items: center;
    margin-top: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.sp-deck.is-ready .sp-slide.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
}

.sp-deck.is-ready .sp-figure {
    display: block;
}

.sp-figure svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: var(--font-sans);
}

.sp-text h3 {
    margin: 0 0 0.6rem;
    font-size: 1.3rem;
}

.sp-text p {
    margin-bottom: 0.8rem;
}

.sp-formula {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    background: var(--color-code-bg);
    border-left: 3px solid var(--color-accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.45rem 0.8rem;
    overflow-x: auto;
}

.sp-refs {
    font-size: 0.88rem;
    color: var(--color-text-light);
}

.sp-text .sp-refs {
    margin: 0;
}

.sp-source {
    margin: 0.9rem 0 0;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* --- Commandes --- */
.sp-nav[hidden] {
    display: none;
}

.sp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.6rem;
    margin-top: 1.4rem;
}

.sp-btn {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.sp-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.sp-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.sp-play {
    min-width: 6.5rem;
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.sp-play:hover:not(:disabled) {
    background: var(--color-accent-light);
    border-color: var(--color-accent-light);
    color: #fff;
}

.sp-btn:focus-visible,
.sp-pick:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.sp-counter {
    min-width: 3.2em;
    font-size: 0.9rem;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

.sp-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0 0 0 auto;
    padding: 0;
    list-style: none;
}

.sp-pick {
    width: 1.95rem;
    height: 1.95rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-light);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.sp-pick:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.sp-pick[aria-current="step"] {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.sp-progress {
    height: 3px;
    margin-top: 1rem;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.sp-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--color-accent);
}

.sp-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- Figures (unités du viewBox 600 × 360) --- */
.sp-figure text {
    fill: var(--color-text);
    font-size: 19px;
}

.sp-figure .t-sm { font-size: 16.5px; }
.sp-figure .t-b { font-weight: 600; }
.sp-figure .t-lg { font-size: 22px; font-weight: 700; }
.sp-figure .t-xl { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-figure .t-muted { fill: var(--color-text-light); }
.sp-figure .t-acc { fill: var(--color-accent); }
.sp-figure .t-i { font-style: italic; }
.sp-figure .t-sup { font-size: 70%; }

.sp-figure .halo {
    paint-order: stroke;
    stroke: var(--color-surface);
    stroke-width: 6px;
    stroke-linejoin: round;
}

.sp-figure .ln,
.sp-figure .ln-faint,
.sp-figure .ln-text,
.sp-figure .ln-acc,
.sp-figure .ln-dash,
.sp-figure .ln-dash-acc,
.sp-figure .ln-dash-text,
.sp-figure .sp-rug {
    fill: none;
}

.sp-figure .ln { stroke: var(--color-text-light); stroke-width: 1.5; }
.sp-figure .ln-faint { stroke: var(--color-border); stroke-width: 1.5; }
.sp-figure .ln-text { stroke: var(--color-text); stroke-width: 2.5; stroke-linejoin: round; }
.sp-figure .ln-acc { stroke: var(--color-accent); stroke-width: 3; stroke-linejoin: round; }
.sp-figure .ln-dash { stroke: var(--color-text-light); stroke-width: 1.5; stroke-dasharray: 5 5; }
.sp-figure .ln-dash-acc { stroke: var(--color-accent); stroke-width: 2; stroke-dasharray: 6 5; }
.sp-figure .ln-dash-text { stroke: var(--color-text); stroke-width: 2; stroke-dasharray: 7 6; stroke-opacity: 0.6; }
.sp-figure .reveal { stroke-dasharray: 1 1; stroke-dashoffset: 1; }

.sp-figure .sp-cut { stroke: var(--color-accent); stroke-width: 1.4; stroke-opacity: 0.5; }
.sp-figure .sp-pt { fill: var(--color-accent); stroke: var(--color-surface); stroke-width: 2; }
.sp-figure .sp-node { fill: var(--color-text-light); }
.sp-figure .sp-ring { fill: none; stroke: var(--color-accent); stroke-width: 2.5; }
.sp-figure .sp-band { fill: var(--sp-band); stroke: var(--color-accent); stroke-width: 1; stroke-dasharray: 4 3; }
.sp-figure .sp-area { fill: var(--sp-area); }
.sp-figure .sp-area-acc { fill: var(--sp-soft); }
.sp-figure .sp-tail { fill: var(--color-text-light); fill-opacity: 0.25; }
.sp-figure .sp-rug { stroke: var(--color-accent); stroke-width: 1.2; stroke-opacity: 0.35; }

.sp-figure .sp-plot { fill: var(--sp-area); stroke: var(--color-border); stroke-width: 1.5; stroke-dasharray: 6 5; }
.sp-figure .sp-strip { stroke: var(--color-surface); stroke-width: 1.5; }
.sp-figure .sp-wheat { fill: var(--sp-wheat); }
.sp-figure .sp-corn { fill: var(--sp-corn); }
.sp-figure .sp-beet { fill: var(--sp-beet); }

.sp-figure .sp-sun circle { fill: var(--sp-sun); }
.sp-figure .sp-sun line { stroke: var(--sp-sun); stroke-width: 2.5; stroke-linecap: round; }
.sp-figure .sp-cloud { fill: var(--sp-cloud); }
.sp-figure .sp-cloud-dark { fill: var(--sp-cloud-dark); }
.sp-figure .sp-rain { stroke: var(--sp-rain); stroke-width: 2.5; stroke-linecap: round; }

/* --- Chapitres et annexes --- */
.sp-chapters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 0 1.75rem;
    margin: 0 0 2rem;
    padding: 0;
    list-style: none;
}

.sp-chapters li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border);
}

.sp-chapters a {
    font-weight: 600;
}

.sp-chapters span {
    display: block;
    font-size: 0.92rem;
    color: var(--color-text-light);
    line-height: 1.5;
}

@media (max-width: 820px) {
    .sp-deck.is-ready .sp-slide {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }

    .sp-figure {
        margin: 0 -0.4rem;
    }

    .sp-dots {
        width: 100%;
        margin-left: 0;
    }
}

/* Sur téléphone, la figure tient dans 330 px environ : le texte grossit d'un cinquième. */
@media (max-width: 560px) {
    .sp-figure text { font-size: 22px; }
    .sp-figure .t-sm { font-size: 20px; }

    .sp-btn-text {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sp-deck.is-ready .sp-slide,
    .sp-deck.is-ready .sp-slide.is-active {
        transition: none;
    }
}
