/* Model Basics - Slideshow */

:root {
    --ink: #18202e;          /* titles, strong text */
    --text: #364152;         /* body copy */
    --muted: #677184;        /* secondary text */
    --paper: #eceff4;        /* page background */
    --sheet: #ffffff;        /* slide card */
    --rule: #d9dee6;         /* dividers */
    --wash: #f4f6f9;         /* subtle fills */

    /* Section colours */
    --arch: #4c55c9;
    --infer: #0b7f8c;
    --train: #b83c72;
    --adv: #3f7f3a;
    --cat: var(--arch);

    --font-ui: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-prose: 'Source Serif 4', Georgia, 'Times New Roman', serif;

    --nav-h: 52px;
    --gutter: clamp(16px, 2.2vw, 40px);
    --radius: 12px;
    --radius-sm: 7px;
}

[data-category="arch"] { --cat: var(--arch); }
[data-category="infer"] { --cat: var(--infer); }
[data-category="train"] { --cat: var(--train); }
[data-category="adv"] { --cat: var(--adv); }

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

/* Type scales with the viewport so dense slides fit on large and small desktops */
html {
    font-size: clamp(13px, calc(0.34vw + 0.78vh + 2.4px), 18.5px);
}

body {
    font-family: var(--font-ui);
    background: var(--paper);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--cat);
    outline-offset: 2px;
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    z-index: 100;
    gap: 12px;
    font-size: 14px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.version {
    font-size: 12px;
    color: var(--muted);
    margin-left: 10px;
}

.nav-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--rule);
    background: var(--sheet);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover:not(:disabled) {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
    color: var(--ink);
    background: var(--wash);
}

.nav-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--rule);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--cat);
    width: 0%;
    transition: width 0.25s ease, background-color 0.25s ease;
}

.progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    min-width: 48px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.nav-controls {
    display: flex;
    gap: 6px;
}

/* Slides container */
.slides-container {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    will-change: transform;
}

.slide {
    flex: 0 0 100vw;
    width: 100vw;
    min-width: 100vw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 1.8vh, 24px) var(--gutter);
    overflow: hidden;
}

/* Slide card — scrolls internally if a slide still doesn't fit */
.slide-content {
    position: relative;
    width: 100%;
    max-width: 92rem;
    max-height: 100%;
    /* Scroll shadows: the white covers move with the content, so the shadows
       only show at an edge when there's more to scroll that way */
    background:
        linear-gradient(var(--sheet) 30%, rgba(255, 255, 255, 0)) top / 100% 40px,
        linear-gradient(rgba(255, 255, 255, 0), var(--sheet) 70%) bottom / 100% 40px,
        radial-gradient(farthest-side at 50% 0, rgba(24, 32, 46, 0.14), transparent) top / 100% 12px,
        radial-gradient(farthest-side at 50% 100%, rgba(24, 32, 46, 0.14), transparent) bottom / 100% 12px,
        var(--sheet);
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll, scroll;
    border-radius: var(--radius);
    border-top: 4px solid var(--cat);
    padding: clamp(18px, 2.7vh, 36px) clamp(22px, 3vw, 52px);
    box-shadow: 0 1px 2px rgba(24, 32, 46, 0.06), 0 8px 28px -12px rgba(24, 32, 46, 0.14);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(24, 32, 46, 0.22) transparent;
}

/* Header */
.slide-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: clamp(10px, 1.6vh, 18px);
    margin-bottom: clamp(12px, 2vh, 22px);
    border-bottom: 1px solid var(--rule);
}

.slide-heading {
    min-width: 0;
}

.slide-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cat);
    margin-bottom: 4px;
}

.slide-title {
    font-size: 1.75rem;
    font-weight: 650;
    font-variation-settings: 'opsz' 48;
    letter-spacing: -0.015em;
    color: var(--ink);
    line-height: 1.15;
    text-wrap: balance;
}

.slide-description {
    font-size: 0.95rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.45;
    max-width: 80ch;
}

.slide-img-btn {
    flex-shrink: 0;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--wash);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.slide-img-btn:hover {
    background: var(--sheet);
    border-color: var(--cat);
}

/* Body */
.slide-body {
    color: var(--text);
}

.slide-main {
    font-family: var(--font-prose);
    font-size: 1.0625rem;
    line-height: 1.57;
    font-variation-settings: 'opsz' 14;
}

.slide-main p + p {
    margin-top: 0.7em;
}

.slide-body strong {
    color: var(--ink);
    font-weight: 600;
}

.slide-body code {
    background: var(--wash);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85em;
    color: var(--ink);
}

.slide-aside {
    font-size: 0.94rem;
    line-height: 1.5;
    margin-top: 1.2rem;
}

.slide-aside > * + * {
    margin-top: 1rem;
}

.slide-aside ul {
    list-style: none;
}

.slide-aside li {
    position: relative;
    padding-left: 18px;
}

.slide-aside li + li {
    margin-top: 0.55em;
}

.slide-aside li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 0.6em;
    width: 6px;
    height: 6px;
    border-radius: 1.5px;
    background: var(--cat);
}

/* Callout */
.callout {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid;
    font-size: 0.9rem;
    line-height: 1.5;
}

.callout > strong:first-child {
    display: block;
    margin-bottom: 3px;
}

.callout-insight {
    background: rgba(11, 127, 140, 0.07);
    border-color: var(--infer);
}

.callout-analogy {
    background: rgba(184, 60, 114, 0.065);
    border-color: var(--train);
}

.callout-note {
    background: var(--wash);
    border-color: var(--muted);
}

/* Resources */
.resources-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.resources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 11px 5px 6px;
    background: var(--sheet);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--rule);
    font-size: 0.84rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.resource-link:hover {
    background: var(--wash);
    border-color: var(--ink);
}

.resource-icon {
    font-size: 0.65rem;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--wash);
    color: var(--muted);
}

.resource-link--video .resource-icon { background: rgba(11, 127, 140, 0.12); color: var(--infer); }
.resource-link--article .resource-icon { background: rgba(63, 127, 58, 0.12); color: var(--adv); }
.resource-link--tool .resource-icon { background: rgba(76, 85, 201, 0.12); color: var(--arch); }
.resource-link--interactive .resource-icon { background: rgba(184, 60, 114, 0.12); color: var(--train); }

.resource-info {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex-wrap: wrap;
}

.resource-title {
    font-weight: 600;
    color: var(--ink);
    line-height: 1.25;
}

.resource-meta {
    font-size: 0.92em;
    color: var(--muted);
    line-height: 1.25;
}

/* Wide screens: prose on the left, key points and resources on the right */
@media (min-width: 1100px) {
    .slide-body {
        --col-gap: clamp(32px, 3.2vw, 56px);
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr);
        column-gap: var(--col-gap);
        align-items: start;
    }

    .slide--balanced .slide-body {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    }

    /* Divider sits in the middle of the column gap */
    .slide-aside {
        margin-top: 0;
        margin-left: calc(var(--col-gap) / -2);
        padding-left: calc(var(--col-gap) / 2);
        border-left: 1px solid var(--rule);
    }

    .resource-link {
        border-radius: var(--radius-sm);
    }
}

/* Scrollbar inside the card */
.slide-content::-webkit-scrollbar {
    width: 6px;
}

.slide-content::-webkit-scrollbar-track {
    background: transparent;
}

.slide-content::-webkit-scrollbar-thumb {
    background: rgba(24, 32, 46, 0.2);
    border-radius: 3px;
}

.slide-content::-webkit-scrollbar-thumb:hover {
    background: rgba(24, 32, 46, 0.38);
}

/* Image lightbox */
.img-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-modal[hidden] {
    display: none;
}

.img-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 32, 46, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

.img-modal-panel {
    position: relative;
    background: var(--sheet);
    border-radius: var(--radius);
    padding: 20px;
    max-width: min(1000px, calc(100vw - 40px));
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.img-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 30px;
    height: 30px;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, border-color 0.15s ease;
    line-height: 1;
}

.img-modal-close:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.img-modal-img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    height: auto;
    border-radius: var(--radius-sm);
    display: block;
    object-fit: contain;
}

.img-modal-caption {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
}

.img-modal-attribution {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.img-modal-attribution::before {
    content: 'Source: ';
}

/* Small screens */
@media (max-width: 768px) {
    :root {
        --nav-h: 48px;
    }

    html {
        font-size: 15px;
    }

    .nav {
        gap: 8px;
    }

    .nav-link {
        padding: 6px 6px;
        font-size: 13px;
    }

    .slide-content {
        border-radius: 10px;
    }

    .slide-header {
        flex-direction: column;
        gap: 10px;
    }

    .slide-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .nav-progress {
        gap: 8px;
    }

    .progress-bar {
        display: none;
    }

    .version {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .slides-container,
    .progress-fill {
        transition: none;
    }
}
