*, *::before, *::after { box-sizing: border-box; }

/* CSS custom properties — override via site_colors: in release.yaml */
:root {
    --bg: #fff;
    --fg: #222;
    --muted: #555;
    --nav-bg: #2c2c2c;
    --nav-fg: #bbb;
    --nav-active: #fff;
    --nav-action: #7eb8d8;
    --nav-width: 180px;
    --accent: #5a7fa0;
    --accent-hover: color-mix(in srgb, var(--accent) 80%, black);
    --subtle-button-hover: color-mix(in srgb, var(--accent) 10%, transparent);
    --border: #ddd;
    --code-bg: #f5f5f5;
    --font-body: Georgia, serif;
    --font-ui: system-ui, sans-serif;
    --font-mono: 'Courier New', monospace;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--fg);
    background: var(--bg);
    min-height: 100vh;
}

/* Sidebar layout — base.njk: <div class="layout"> wraps <nav> and <main> */
.layout {
    display: flex;
    min-height: 100vh;
}

/* base.njk: <nav><ul>{{ nav_html }}</ul></nav> */
nav {
    width: var(--nav-width);
    min-width: var(--nav-width);
    background: var(--nav-bg);
    padding: 1.5rem 0;
}

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

/* nav items — emitted by render_nav() in nav.ts */
nav li a {
    display: block;
    padding: 0.6rem 1.25rem;
    color: var(--nav-fg);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

nav li a:hover {
    color: var(--nav-active);
    background: rgba(255,255,255,0.05);
}

/* active class set by render_nav() when item.label matches the current page */
nav li.active a {
    color: var(--nav-active);
    border-left-color: var(--accent);
    background: rgba(255,255,255,0.07);
}

/* subnav — render_nav() emits <ul class="subnav"> beneath a Source parent when it's active */
nav .subnav {
    list-style: none;
    margin: 0;
    padding: 0;
}

nav .subnav li a {
    padding: 0.4rem 1.25rem 0.4rem 2rem;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
}

nav .subnav li.active a {
    color: var(--nav-active);
    border-left-color: var(--accent);
}

/* visual separator between action items and page links */
nav li.action + li:not(.action) {
    margin-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 0.75rem;
}

/* nav: separator — render_nav() emits <li class="sep"> for null nav entries */
nav li.sep {
    margin: 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* nav-id-* classes — render_nav() emits nav-id-{slug} on every <li>;
   override these in a custom site_css_files stylesheet to restyle any item */
nav li.nav-id-index a { font-weight: bold; }
nav li.nav-id-play a,
nav li.nav-id-download a { color: var(--nav-action); }

/* Mobile nav toggle button — hidden on desktop, shown on mobile */
.nav-toggle {
    display: none;
}

/* Mobile layout */
@media (max-width: 640px) {
    .layout {
        flex-direction: column;
    }

    nav {
        width: 100%;
        min-width: 0;
        padding: 0;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.75rem 1.25rem;
        background: none;
        border: none;
        color: var(--nav-fg);
        font-family: var(--font-ui);
        font-size: 0.9rem;
        cursor: pointer;
        text-align: left;
    }

    .nav-toggle:hover {
        color: var(--nav-active);
    }

    .nav-arrow {
        display: inline-block;
        transition: transform 0.2s ease;
        font-size: 0.75em;
    }

    nav.open .nav-arrow {
        transform: rotate(90deg);
    }

    nav ul {
        display: none;
        padding-bottom: 0.5rem;
    }

    nav.open ul {
        display: block;
    }
}

/* base.njk: <main> holds the page body */
main {
    flex: 1;
    max-width: 780px;
    padding: 2rem 2.5rem;
}

/* Index page — index.njk */
.title-block {
    text-align: center;
}

/* index.njk: <img class="cover"> — only rendered when site_cover_image is set */
.cover {
    max-width: 300px;
    max-height: 300px;
    display: block;
    margin: 0 auto 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.title-block h1 {
    font-size: 2rem;
    margin: 0 0 0.25rem;
}

/* index.njk: <p class="byline"> — only rendered when author is set */
.byline {
    font-style: italic;
    color: var(--muted);
    margin: 0 0 1rem;
}

/* index.njk: <p class="description"> — only rendered when description is set */
.description {
    max-width: 600px;
    margin: 1rem auto;
    line-height: 1.6;
}

/* index.njk: <p class="ifid"> — only rendered when ifid is set */
.ifid {
    color: var(--muted);
    margin: 0.5rem 0 1.5rem;
}

/* index.njk: <div class="cta-buttons"> wraps play and download CTAs */
.cta-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* index.njk: <a class="play-link"> and <a class="download-link"> */
.play-link, .download-link {
    display: inline-block;
    padding: 0.6rem 2rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 1rem;
}

.play-link:hover, .download-link:hover { background: var(--accent-hover); }

/* source.njk: <a class="subtle-button"> — the raw file download link */
.subtle-button {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
}

.subtle-button:hover { background: var(--subtle-button-hover); }

/* Source page — source.njk */

/* source.njk / walkthrough.njk: header row with title + download button */
.source-header, .walkthrough-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

/* source.njk: filename heading uses monospace; walkthrough.njk uses default body font */
.source-header h1 {
    margin: 0;
    font-size: 1.3rem;
    font-family: var(--font-mono);
}

.walkthrough-header h1 {
    margin: 0;
}

/* source.njk: Shiki wraps highlighted code in <pre> inside <div class="source-file"> */
.source-file pre {
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: 0 4px 4px 4px;
    margin: 0;
}

pre.shiki {
    padding: 0.75rem;
}

/* Details page — details.njk: <table class="details-table"> */
.details-table {
    border-collapse: collapse;
    width: 100%;
}

.details-table th, .details-table td {
    text-align: left;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.details-table th {
    width: 8rem;
    color: var(--muted);
    font-weight: normal;
    font-family: var(--font-ui);
}

/* Markdown pages — markdown-page.njk: <div class="markdown-content"> wraps marked() output */
.markdown-content { line-height: 1.7; }
.markdown-content h1, .markdown-content h2, .markdown-content h3 { margin-top: 1.5rem; }
.markdown-content pre { background: var(--code-bg); padding: 1rem; border-radius: 4px; overflow-x: auto; }
.markdown-content code { font-family: var(--font-mono); font-size: 0.9em; }
.markdown-content pre code { background: none; }
.markdown-content blockquote { border-left: 3px solid var(--border); margin-left: 0; padding-left: 1rem; color: var(--muted); }

/* How to Play page — how_to_play.njk (and potentially custom_templates override) */
dt { font-weight: bold; margin-top: 0.75rem; }
dd { margin-left: 1.5rem; }
kbd {
    background: #eee;
    border: 1px solid #bbb;
    border-radius: 3px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* Transcript page — transcript.njk: .transcript-body wraps transcript_to_html() output */
.transcript-command {
    font-family: var(--font-mono);
    font-weight: bold;
    display: inline-block;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.75rem;
    margin: 1.25rem 0 0.5rem;
}

.transcript-section {
    font-size: 1.5em;
    font-weight: bold;
    margin: 2.5rem 0 0.5rem;
}

.transcript-quote {
    font-family: var(--font-mono);
    font-size: 1.1em;
    font-weight: bold;
    line-height: 1.2;
    border: none;
    margin: 0.75rem 0;
    padding: 0;
    white-space: pre;
}

.transcript-room {
    font-size: 1.2em;
    font-weight: bold;
    margin: 1.5rem 0 0;
}

hr.transcript-room-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0 0.75rem;
}

.transcript-text {
    margin: 0.75rem 0;
    line-height: 1.5;
}

/* Author color overrides */
:root {
    --bg: #f5eedc;
    --fg: #2a1f0e;
    --accent: #6F4E37;
}
