@font-face {
    font-family: 'Asemic';
    src: url('fonts/AsemicSharp.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'SW01';
    src: url('fonts/Sw01-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg:  #fff;
    --fg:  #000;
    --fs:  24px;
    --pad: 6px;
}
body.dark { --bg: #000; --fg: #fff; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
::selection { background: var(--fg); color: var(--bg); }

body {
    font-family: 'Times New Roman', Times, serif;
    background: var(--bg);
    color: var(--fg);
    font-size: var(--fs);
    line-height: 1.1;
    overflow-x: hidden;
    transition: background 0.25s, color 0.25s;
}

/* ── FIXED BUTTONS ── */
#theme-btn {
    position: fixed;
    top: var(--pad);
    right: var(--pad);
    z-index: 700;
    background: var(--bg);
    border: none;
    font-family: Georgia, serif;
    font-size: var(--fs);
    color: var(--fg);
    cursor: pointer;
    padding: 0 0 0 6px;
    margin: 0;
    line-height: 1.1;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.25s, color 0.25s;
}
#theme-btn:hover { opacity: 0.4; }

#menu-btn {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 600;
    background: var(--bg);
    border: none;
    font-family: Georgia, serif;
    font-size: var(--fs);
    color: var(--fg);
    cursor: pointer;
    padding: var(--pad);
    line-height: 1.1;
    text-align: left;
    width: 100%;
    transition: background 0.25s, color 0.25s;
}

/* ── PAGE GRID ── */
.page {
    display: grid;
    grid-template-columns: 630px 1.3fr 0.7fr;
    align-items: start;
    min-height: 100vh;
}

/* ── LEFT ── */
#left-col {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: var(--pad);
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}
#left-col::-webkit-scrollbar { display: none; }

.left-site-title {
    font-size: var(--fs);
    line-height: 1.1;
    margin-bottom: 16px;
    text-decoration: none;
    color: var(--fg);
    display: block;
}
.left-site-title:hover { opacity: 0.4; }

#left-nav { display: flex; flex-direction: column; }
#left-nav a {
    font-size: var(--fs);
    color: var(--fg);
    text-decoration: none;
    padding: 2px 0;
    line-height: 1.1;
    display: block;
    text-align: left;
}
#left-nav a:hover  { opacity: 0.4; }
#left-nav a.active { font-style: italic; }
#left-nav .nav-title { display: block; }
#left-nav .nav-sub   { display: block; }
.nav-spacer { height: 16px; }

/* ── MIDDLE ── */
#mid-col {
    padding: var(--pad);
    min-width: 0;
    position: relative;
}
#intro {
    min-height: 100vh;
    position: relative;
}
#opening-epigraph {
    font-size: var(--fs);
    line-height: 1.1;
}
.epi-attr { font-style: italic; }

/* ── BIG TITLE ── */
#title-svg-wrap {
    position: fixed;
    top: calc(30vh - 100px);
    left: 300px;
    width: 100vw;
    text-align: center;
    pointer-events: none;
    z-index: 50;
}

#big-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.bt-line {
    display: block;
    font-family: 'Asemic', serif !important;
    font-size: clamp(120px, 18vw, 320px);
    font-weight: normal;
    color: var(--fg);
    letter-spacing: 0;
    white-space: nowrap;
    overflow: visible;
    transition: color 0.25s;
    visibility: hidden;
}

/* ── CHAPTERS ── */
.ch-text {
    padding-top: 0;
    padding-bottom: 32px;
    scroll-margin-top: 0;
}

/* Space between chapters */
.ch-text + .ch-text {
    margin-top: 48px;
}

/* Extra space before chapters start (after notes) */
#ch1 {
    margin-top: 96px;
}

.ch-head {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    transition: background 0.25s;
    padding: 0;
    margin-bottom: 14px;
    scroll-margin-top: 0;
}
.ch-headline {
    font-size: var(--fs);
    font-weight: normal;
    font-style: normal;
    line-height: 1.1;
    display: block;
}

.tb { margin-bottom: 0; }
.tb p {
    font-size: var(--fs);
    line-height: 1.1;
    text-indent: 3em;
    margin-bottom: 0;
}
.tb p:first-child { text-indent: 0; }
.tb + .tb p:first-child { text-indent: 3em; }

/* ── FIGURE REFERENCES (inline in text) ── */
.fig-ref { display: none; } /* references removed from text */

/* ── RIGHT COLUMN ── */
#right-col {
    min-width: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    padding: 0;
}

#right-panel {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Tool SVGs — a and b inside right col, c spans as overlay */
.tool-item {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
}
.tool-item img {
    display: block;
    width: 100%;
    height: auto;
}

/* tool-a: right side of right col touching tool-b */
#tool-a { width: 30%; right: 32%; top: 0; }
/* tool-b: far right of right col */
#tool-b { width: 30%; right: 2%; bottom: 0; }

/* tool-c: fixed overlay, centered over mid+right boundary */
#tool-c {
    position: fixed;
    bottom: 0;
    right: 14vw;
    width: 15.4vw;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
}
#tool-c img { display: block; width: 100%; height: auto; }

/* ── SCROLL IMAGES ── */
.scroll-img-wrap {
    position: absolute;
    top: 0;
    left: 4%;
    width: 92%;
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
}
.scroll-img-wrap img {
    display: block;
    width: 100%;
    height: auto;
}

/* ── FONT SWITCHER ── */
#font-switcher {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.font-btn {
    background: none;
    border: none;
    font-size: var(--fs);
    font-family: inherit;
    color: var(--fg);
    cursor: pointer;
    padding: 2px 0;
    line-height: 1.1;
    text-align: left;
    opacity: 1;
    transition: opacity 0.15s, color 0.25s, background 0.25s;
}
.font-btn:hover { opacity: 0.4; }
#site-title-link,
#left-nav a,
.font-btn,
#opening-epigraph,
#theme-btn {
    visibility: hidden;
}
/* ── DRAWING OVERLAYS ── */
#drawing-overlays {
    pointer-events: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 45;
}
.drawing-line {
    position: absolute;
    width: 320px;
    height: auto;
    opacity: 0;
    transition: opacity 0.8s ease;
    mix-blend-mode: multiply;
}
body.dark .drawing-line {
    mix-blend-mode: screen;
    filter: invert(1);
}
.drawing-line.visible { opacity: 1; }

@media (max-width: 760px) {
    #drawing-overlays { display: none; }
}
#archive-frame-wrap {
    position: absolute;
    left: var(--pad);
    right: var(--pad);
    bottom: var(--pad);
    opacity: 0;
    will-change: transform, opacity;
    transition: opacity 0.4s ease;
}
#archive-frame-wrap.visible {
    opacity: 1;
}
#archive-frame {
    display: block;
    width: 100%;
    height: 340px;
    border: none;
    background: var(--bg);
}
#archive-frame-wrap .fig-caption a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 3px;
}
#archive-frame-wrap .fig-caption a:hover {
    opacity: 0.4;
}
#fig-items {
    position: absolute;
    top: 0; left: 0; right: 0;
    pointer-events: none;
}
.fig-item {
    position: absolute;
    left: var(--pad);
    right: var(--pad);
    top: 0;
    display: none;
    will-change: transform;
}
.fig-item img {
    display: block;
    width: 100%;
    height: auto;
}
.fig-caption {
    font-size: 12px;
    line-height: 1.3;
    padding-top: 6px;
    color: var(--fg);
    font-family: inherit;
}

/* ── MOBILE FIGURES ── */
.mobile-fig {
    display: none;
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fg); }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
    .page { grid-template-columns: 400px 1.3fr 0.7fr; }
}

@media (max-width: 760px) {
    .page { display: block; }

    #left-col {
        position: fixed;
        top: 0; left: 0;
        width: 85vw;
        max-width: 320px;
        height: 100vh;
        z-index: 400;
        background: var(--bg);
        transform: translateX(-100%);
        transition: transform 0.25s ease, background 0.25s;
        padding-top: calc(var(--fs) * 1.1 + var(--pad) * 2);
    }
    #left-col.open { transform: translateX(0); }

    #menu-btn { display: block; }

    #theme-btn {
        top: 0;
        padding: var(--pad) var(--pad) var(--pad) 8px;
        line-height: 1.1;
        background: var(--bg);
    }

    /* bar height = font-size * 1.1 + 2 * pad */
    #mid-col {
        padding-top: calc(var(--fs) * 1.1 + var(--pad) * 2);
    }

    #right-col { display: none; }
    #tool-c     { display: none; }

    /* Show figures inline on mobile */
    .mobile-fig {
        display: block !important;
        margin: 16px 0;
    }
    .mobile-fig img {
        display: block;
        width: 100%;
        height: auto;
    }
    .mobile-fig::after {
        content: attr(data-caption);
        display: block;
        font-size: 12px;
        line-height: 1.3;
        padding-top: 6px;
        color: var(--fg);
        font-family: 'Times New Roman', Times, serif;
    }

    /* sticky chapter title sits flush below the bar — no gap */
    .ch-head {
        top: calc(var(--fs) * 1.1 + var(--pad) * 2);
        background: var(--bg);
        margin-top: -2px;
        padding-top: 2px;
        box-shadow: 0 -2px 0 var(--bg);
    }

    .ch-text {
        padding-top: 0;
        scroll-margin-top: calc(var(--fs) * 1.1 + var(--pad) * 2);
    }

    /* Asemic title: centered in viewport on mobile */
    #title-svg-wrap {
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        width: 100vw;
    }
}
