/* =========================================================
   Project page layout (TOC sidebar + content)
   ========================================================= */

.project-layout {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
    gap: 2.5rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    box-sizing: border-box;
}

.project-content {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    overflow-x: hidden;
    padding: 3rem 0 6rem;
    margin: 0;
    box-sizing: border-box;
}

/* TOC sidebar */
.toc {
    position: sticky;
    top: calc(var(--nav-height) + 1.5rem);
    width: 230px;
    flex-shrink: 0;
    max-height: calc(100vh - var(--nav-height) - 3rem);
    overflow-y: auto;
    padding-top: 3rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    margin-top: 3rem;
}

.toc-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

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

.toc-item {
    margin-bottom: 0;
}

.toc-item a {
    display: block;
    padding: 0.3rem 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.4;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    transition: color 0.15s, border-color 0.15s;
}

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

.toc-item a.toc-active {
    color: var(--text);
    border-left-color: var(--accent);
}

.toc-h3 a {
    padding-left: 1.5rem;
    font-size: 0.78rem;
}

@media (max-width: 900px) {
    .project-layout {
        flex-direction: column;
        padding: 0 1.5rem;
        gap: 0;
    }

    .toc {
        position: static;
        width: 100%;
        max-height: none;
        margin-top: 1.5rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 640px) {
    .project-layout {
        padding: 0 0.75rem;
    }

    .project-header {
        padding: 1.5rem 0 1.5rem;
    }

    .media-grid {
        padding: 1rem 0.5rem;
    }

    .media-item,
    .media-item.wide,
    .media-item.tall {
        flex: 1 1 100%;
        max-width: 100%;
        min-width: 0;
    }

    .media-item img {
        height: 200px;
    }

    .sdw-outer {
        padding: 1rem 0.75rem;
    }
}

/* ── Filmstrip ────────────────────────────────────────── */
.filmstrip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 1.5rem 0 2rem;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.filmstrip img {
    height: 180px;
    width: auto;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Stat strip ───────────────────────────────────────── */
.stat-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2.5rem;
}

.stat-item {
    flex: 1 1 0;
    min-width: 120px;
    background: var(--bg-2);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.stat-item .stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
    margin-bottom: 0.3rem;
}

.stat-item .stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── Mechanic rows ────────────────────────────────────── */
.mechanic-row {
    display: flex;
    align-items: center;
    gap: 3rem;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.mechanic-row.reverse {
    flex-direction: row-reverse;
}

.mechanic-visual {
    flex: 0 0 52%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mechanic-visual img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
}

.mechanic-visual .mechanic-gif-pair {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mechanic-body {
    flex: 1;
    min-width: 0;
}

.mechanic-body h3 {
    margin-top: 0;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.mechanic-body p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.65;
}

/* ── Design cards ─────────────────────────────────────── */
.design-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 1.5rem 0 2.5rem;
}

.design-grid--centered {
    justify-items: stretch;
    justify-content: center;
}

/* When the last row has fewer cards than columns, center them */
.design-grid--centered > :last-child:nth-child(3n - 2),
.design-grid--centered > :last-child:nth-child(3n - 1) {
    grid-column: auto;
}

.design-grid--centered::after {
    content: none;
}

/* Five cards: first row 3, second row 2 centered */
.design-grid--centered {
    grid-template-columns: repeat(6, 1fr);
}

.design-grid--centered .design-card {
    grid-column: span 2;
}

.design-grid--centered .design-card:nth-child(4) {
    grid-column: 2 / span 2;
}

.design-grid--centered .design-card:nth-child(5) {
    grid-column: 4 / span 2;
}

.design-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.design-card h3 {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.design-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

/* ── Design stills row ────────────────────────────────── */
.design-stills {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0 2.5rem;
}

.design-stills img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    object-fit: cover;
    object-position: center;
    display: block;
}

/* ── Render comparison figures ────────────────────────── */
.render-compare {
    flex: 1;
    min-width: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.render-compare img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
}

.render-compare figcaption {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ── Level strip ──────────────────────────────────────── */
.level-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 1.5rem 0 2.5rem;
}

.level-card img {
    width: 100%;
    height: auto;
    object-fit: unset;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    display: block;
}

.level-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: var(--text);
}

.level-card p {
    font-size: 0.87rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.55;
}

/* ── Scope grid ───────────────────────────────────────── */
.scope-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 2rem;
    margin: 1rem 0 2rem;
}

.scope-grid li {
    font-size: 0.92rem;
    color: var(--text-muted);
    padding-left: 1rem;
    position: relative;
    list-style: none;
}

.scope-grid li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
    .mechanic-row,
    .mechanic-row.reverse {
        flex-direction: column;
        padding: 1.25rem;
        gap: 1.5rem;
    }

    .mechanic-visual {
        flex: none;
        width: 100%;
    }

    .design-grid {
        grid-template-columns: 1fr;
    }

    .level-strip {
        grid-template-columns: 1fr;
    }

    .scope-grid {
        grid-template-columns: 1fr;
    }

    .stat-strip {
        flex-wrap: wrap;
    }

    .stat-item {
        flex: 1 1 40%;
    }
}
.project-header {
    padding: 3rem 0 2.5rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border);
}

.project-header-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

.project-header h1 {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.project-header .badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
}

.badge {
    display: inline-block;
    padding: 0.25em 0.75em;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(220, 20, 60, 0.3);
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.project-header .description {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 700px;
    line-height: 1.7;
}

.project-header-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding: 0.75rem 1.6rem;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-decoration: none;
    border-radius: 6px;
    border: 2px solid var(--accent);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 18px rgba(220, 20, 60, 0.35);
}

.project-header-cta:hover {
    background: transparent;
    color: var(--accent);
    box-shadow: 0 4px 24px rgba(220, 20, 60, 0.5);
}

.wip-banner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
    padding: 0.65rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(80, 200, 120, 0.35);
    background: rgba(80, 200, 120, 0.12);
    color: #9ee6b3;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    box-shadow: 0 8px 24px rgba(80, 200, 120, 0.12);
}

.wip-banner::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}

/* Thumbnail image in the project header */
.project-thumbnail {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin-bottom: 2.5rem;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

/* Section headings */
.project-content h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    line-height: 1.3;
}

.project-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.75rem 0 0.6rem;
    color: var(--text);
}

/* Prose width cap */
.project-content p,
.project-content ul,
.project-content ol {
    max-width: none;
}

/* Highlights block - "Why this project stands out" */
.project-highlights {
    background: rgba(220, 20, 60, 0.05);
    border: 1px solid rgba(220, 20, 60, 0.2);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin: 0 0 2rem;
    list-style: none;
}

.project-highlights li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.65rem;
    color: var(--text);
    font-size: 0.97rem;
}

.project-highlights li:last-child {
    margin-bottom: 0;
}

.project-highlights li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* Project link (GitHub etc.) */
.project-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 2rem 0;
}

.project-ext-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
}

.project-ext-link:hover {
    color: var(--text);
    border-color: var(--accent);
    opacity: 1;
}

/* Rules reference list */
.rules-list {
    margin: 1.5rem 0 2.5rem;
    padding: 0;
    border-top: 1px solid var(--border);
}

.rules-row {
    display: flex;
    gap: 2rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}

.rules-row dt {
    flex: 0 0 220px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.rules-row dd {
    flex: 1;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.97rem;
    line-height: 1.65;
}

@media (max-width: 600px) {
    .rules-row {
        flex-direction: column;
        gap: 0.3rem;
    }
    .rules-row dt {
        flex: none;
    }
}

/* Media grids (GIF / screenshot galleries) */
.media-grid {
    background: rgba(0, 0, 0, 0.45);
    padding: 2rem 1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    margin-bottom: 2rem;
}

.media-grid-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.media-item {
    flex: 1 1 220px;
    min-width: 140px;
    text-align: center;
    border-radius: var(--radius-sm);
}

.media-item.wide {
    flex: 1 1 340px;
    min-width: 200px;
}

.media-item.tall {
    flex: 1 1 280px;
    min-width: 160px;
}

.media-item img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.media-item.tall img {
    height: 200px;
}

.media-item.natural img {
    height: auto;
}

.media-caption {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Placeholder blocks for missing visuals */
.placeholder {
    background: rgba(255, 180, 0, 0.08);
    border: 2px dashed rgba(255, 180, 0, 0.45);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.placeholder strong {
    color: rgba(255, 200, 80, 0.9);
}

/* Video blocks */
.video-block {
    text-align: center;
    margin: 1em 0 0.5em;
}

.video-block video {
    max-width: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.video-note {
    margin-top: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
}

/* Standalone centred image (e.g. level design diagram) */
.figure-center {
    display: flex;
    justify-content: center;
    margin-bottom: 2em;
}

.figure-center img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* arXiv / external link button */
.btn-primary {
    display: inline-block;
    padding: 0.45em 1.1em;
    background: var(--accent);
    color: var(--bg);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    margin: 0.5rem 0;
    transition: opacity 0.15s;
}

.btn-primary:hover {
    opacity: 0.8;
    color: var(--bg);
}

/* Work-in-progress banner */
.wip-banner {
    background: rgba(255, 180, 0, 0.12);
    border: 2px solid rgba(255, 180, 0, 0.45);
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    font-weight: 700;
    margin-bottom: 2rem;
    color: rgba(255, 200, 80, 0.9);
}

/* Diagram containers */
.diagram-wrap {
    overflow-x: auto;
    margin-top: 1.2em;
    margin-bottom: 1.2em;
}

/* Skill diagram specific wrapper (has its own header + legend) */
.sdw-outer {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.sdw-header {
    text-align: center;
    margin-bottom: 1rem;
}

.sdw-header h3 {
    margin-top: 0;
}

.sdw-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sdw-skill-desc {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    font-size: 0.8em;
    line-height: 1.7;
    color: rgba(255,255,255,0.7);
}

.sdw-skill-meta {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85em;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.04em;
}

.sdw-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 14px;
    justify-content: center;
    margin-bottom: 16px;
}

.sdw-leg {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.71em;
    color: rgba(255,255,255,0.55);
}

.sdw-leg-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    border: 1.5px solid;
    flex-shrink: 0;
}

.sdw-scroll {
    overflow-x: auto;
    overflow-y: visible;
}

#sdw-chart {
    position: relative;
    width: 860px;
    height: 640px;
    margin: 0 auto;
}
