/* ===== theme ===== */

:root {
    color-scheme: light;

    --bg: #ffffff;
    --fg: #000000;
    --muted: #666;
    --muted-soft: #767676;
    --body-dim: #444;
    --heading-dim: #333;
    --link-hover: #505050;
    --rule: #ddd;
    --rule-strong: #bbb;

    /* The dark values are spelled out once here; the two selectors below adopt
       them, so the system preference and the explicit toggle cannot drift. */
    --dark-bg: #101013;
    --dark-fg: #e6e6e9;
    --dark-muted: #91919a;
    --dark-muted-soft: #8a8a93;
    --dark-body-dim: #b3b3bb;
    --dark-heading-dim: #c6c6cd;
    --dark-link-hover: #9a9aa3;
    --dark-rule: #2b2b32;
    --dark-rule-strong: #3c3c45;
}

/* System preference, unless the reader has explicitly chosen light. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: var(--dark-bg);
        --fg: var(--dark-fg);
        --muted: var(--dark-muted);
        --muted-soft: var(--dark-muted-soft);
        --body-dim: var(--dark-body-dim);
        --heading-dim: var(--dark-heading-dim);
        --link-hover: var(--dark-link-hover);
        --rule: var(--dark-rule);
        --rule-strong: var(--dark-rule-strong);
    }
}

/* Explicit choice wins in both directions. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: var(--dark-bg);
    --fg: var(--dark-fg);
    --muted: var(--dark-muted);
    --muted-soft: var(--dark-muted-soft);
    --body-dim: var(--dark-body-dim);
    --heading-dim: var(--dark-heading-dim);
    --link-hover: var(--dark-link-hover);
    --rule: var(--dark-rule);
    --rule-strong: var(--dark-rule-strong);
}

/* ===== base (main.css) ===== */

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: 'Courier New', Courier, monospace;
    -webkit-font-smoothing: subpixel-antialiased;
    line-height: 1.6;
    max-width: 800px;
    margin: 64px auto 0 auto;
    padding: 0 16px;
    text-align: left;
}

main {
    flex: 1;
}

html,
body {
    background-color: var(--bg);
    height: 100%;
    scroll-behavior: smooth;
}

#site-wrapper {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--fg);
    text-decoration: underline;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    line-height: 1.4;
    margin: 0 0 12px;
}

.long-title {
    display: block;
}

.short-title {
    display: none;
}

@media (max-width: 600px) {
    .long-title {
        display: none;
    }

    .short-title {
        display: block;
    }
}

/* ===== header ===== */

#header {
    margin: 0;
    font-family: "STIX Two Math", "Cambria Math", "DejaVu Serif", serif;
    font-feature-settings: "cv03" 1;
}

.header-inner {
    margin: 0 auto;
}

#logo {
    margin: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-end;
    text-decoration: none;
    color: var(--fg);
}

.glyph {
    font-size: 64px;
    display: inline-block;
    line-height: 1;
}

#logo h1 {
    margin: 0;
    margin-left: 10;
    line-height: 1.5;
}

#divider {
    color: var(--fg);
    max-width: 80%;
}

/* ===== navbar ===== */

#navbar {
    /* Matches #divider so the theme control lands under the rule's right end. */
    margin: 0 auto;
    max-width: 80%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding-top: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

.nav-links {
    grid-column: 2;
}

#navbar a {
    color: var(--fg);
    margin-right: 20px;
    text-decoration: none;
    transition: color 0.2s ease;
}

#navbar a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Hidden until the script reveals it, so a no-JS reader sees no dead control
   and still gets dark mode from the system preference. */
#theme-toggle {
    grid-column: 3;
    justify-self: end;
    appearance: none;
    background: none;
    border: none;
    color: var(--fg);
    cursor: pointer;
    font: inherit;
    padding: 0;
    white-space: nowrap;
    transition: color 0.2s ease;
}

#theme-toggle .theme-icon {
    font-family: system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    margin-right: 6px;
}

#theme-toggle:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

#theme-toggle:focus-visible {
    outline: 1px solid var(--fg);
    outline-offset: 4px;
}

/* ===== footer ===== */

#footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    font-family: 'Courier New', Courier, monospace;
    color: var(--muted-soft);
}

/* ===== home ===== */

#welcome {
    margin: 48px 0 0;
}

#welcome h2 {
    font-size: 22px;
    line-height: 1.4;
    margin: 0 0 20px;
}

#welcome p {
    max-width: 720px;
}

#work {
    margin: 72px 0 64px;
}

#work > h2 {
    font-size: 17px;
    margin: 0 0 10px;
}

.work-intro {
    color: var(--body-dim);
    font-size: 14px;
    margin: 0 0 40px;
    max-width: 680px;
}

.work-group {
    color: var(--heading-dim);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 6px;
    margin: 48px 0 24px;
}

#work article {
    margin-bottom: 40px;
    max-width: 680px;
}

#work h3 {
    font-size: 16px;
    line-height: 1.4;
    margin: 0 0 8px;
}

#work h3 a {
    color: inherit;
    text-decoration: none;
}

#work h3 a:hover {
    text-decoration: underline;
}

#work article p {
    font-size: 14px;
    line-height: 1.6;
}

#work .project-meta {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.035em;
    line-height: 1.4;
    margin: 0 0 6px;
    text-transform: uppercase;
}

#work .case-study-link {
    font-size: 13px;
}

@media (max-width: 600px) {
    #welcome {
        margin-top: 36px;
    }

    #work {
        margin-top: 56px;
    }
}

/* ===== case-study pages (work.css) ===== */

#work-item {
    max-width: 700px;
    margin: 64px auto 80px;
    font-family: 'Courier New', Courier, monospace;
}

.work-back {
    font-size: 13px;
    margin: 0 0 36px;
}

.work-discipline {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.035em;
    line-height: 1.4;
    margin: 0 0 8px;
}

#work-item h2 {
    font-size: 22px;
    line-height: 1.4;
    margin: 0 0 12px;
}

.work-summary {
    color: var(--body-dim);
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 44px;
}

.case-study h3 {
    font-size: 15px;
    margin: 32px 0 6px;
}

.case-study > h3:first-child {
    margin-top: 0;
}

.case-study p {
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 12px;
}

.work-visual {
    margin: 0 0 44px;
}

/* ===== pose-graph figure ===== */

.pgo-body {
    align-items: start;
    display: flex;
    gap: 28px;
}

.pgo {
    display: block;
    flex: 1 1 auto;
    height: auto;
    min-width: 0;
    width: 100%;
}

.pgo path {
    fill: none;
}

.pgo .l-gt path  { stroke: var(--rule-strong); stroke-width: 1.2; }
.pgo .l-bef path { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 5 3; }
.pgo .l-aft path { stroke: var(--fg); stroke-width: 1.8; stroke-linejoin: round; }
.pgo .l-lc path  { stroke: var(--muted); stroke-width: 0.6; opacity: 0.45; }
.pgo .l-aft circle { fill: var(--fg); }

/* Real checkboxes, so layers toggle with no JavaScript and stay
   keyboard-reachable. Where :has() is unsupported every layer simply
   stays visible, which is the correct figure either way. */
.pgo-key {
    flex: 0 0 196px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pgo-key li {
    margin-bottom: 18px;
}

.pgo-key label {
    align-items: center;
    cursor: pointer;
    display: grid;
    font-size: 12px;
    gap: 0 8px;
    grid-template-columns: auto 26px 1fr;
}

.pgo-key input {
    margin: 0;
}

.pgo-key .sw {
    border-top: 2px solid var(--fg);
    display: block;
    height: 0;
}

.pgo-key .sw-bef { border-top-color: var(--muted); border-top-style: dashed; }
.pgo-key .sw-gt  { border-top-color: var(--rule-strong); }
.pgo-key .sw-lc  { border-top-color: var(--muted); opacity: 0.5; }

.pgo-key .vl {
    color: var(--muted);
    font-size: 11px;
    grid-column: 3;
}

.pgo-fig:has(#pgo-aft:not(:checked)) .l-aft,
.pgo-fig:has(#pgo-bef:not(:checked)) .l-bef,
.pgo-fig:has(#pgo-gt:not(:checked)) .l-gt,
.pgo-fig:has(#pgo-lc:not(:checked)) .l-lc {
    display: none;
}

@media (max-width: 600px) {
    .pgo-body {
        display: block;
    }

    .pgo-key {
        display: flex;
        flex-wrap: wrap;
        gap: 10px 22px;
        margin-top: 18px;
    }

    .pgo-key li {
        margin-bottom: 0;
    }
}

.work-visual img {
    border: 1px solid var(--rule);
    box-sizing: border-box;
    display: block;
    max-width: 100%;
    width: 100%;
}

.work-visual figcaption {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    margin-top: 8px;
}

.work-note {
    border-top: 1px solid var(--rule-strong);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    margin: 48px 0 0;
    padding-top: 16px;
}

/* ===== not found ===== */

#not-found {
    margin: 80px auto;
    text-align: left;
}
