/* =============================================================
   ESSAYS — three-column layout: TOC | Content | Sidenotes
   ============================================================= */

/* --- FONT SWITCHER (commented out) ---
.font-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 252, 241, 0.97);
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 12px 16px;
    z-index: 999;
    font-size: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.font-switcher label {
    display: block;
    margin-bottom: 6px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}

.font-switcher label:hover {
    background: #f0edd8;
}

.font-switcher input[type="radio"] {
    margin-right: 8px;
}

.font-switcher .switcher-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #4a6741;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}
*/

/* --- NAV (matches main site) --- */
.essay-nav {
    position: sticky;
    top: 0;
    background: rgb(255, 252, 241);
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 24px;
    z-index: 100;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.essay-nav .nav-title {
    margin-right: auto;
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.essay-nav .nav-title strong {
    font-size: 20px;
    color: #1a1a1a;
    white-space: nowrap;
}

.essay-nav .nav-subtitle {
    font-size: 13px;
    color: #888;
    font-weight: normal;
}

.essay-nav .nav-links {
    display: flex;
    align-items: center;
}

.essay-nav a {
    margin: 0 10px;
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    font-size: 14px;
    font-weight: normal;
    color: #4a6741;
    text-decoration: none;
}

.essay-nav a:hover {
    text-decoration: underline;
}

.essay-nav .nav-divider {
    margin: 0 10px;
    color: #ccc;
    font-size: 14px;
}

/* --- HAMBURGER TOGGLE (hidden on desktop) --- */
.essay-nav .nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 4px;
}

.essay-nav .nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #4a6741;
    transition: transform 0.2s, opacity 0.2s;
}

.essay-nav.nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.essay-nav.nav-open .nav-toggle span:nth-child(2) {
    opacity: 0;
}

.essay-nav.nav-open .nav-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.essay-nav .nav-group {
    display: inline-flex;
    align-items: center;
    flex-direction: row-reverse;
}

.essay-nav .nav-collapse {
    display: inline-flex;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.4s ease 3s, opacity 0.25s ease 3s;
    white-space: nowrap;
}

.essay-nav .nav-group:hover .nav-collapse {
    max-width: 400px;
    opacity: 1;
    transition: max-width 0.4s ease, opacity 0.25s ease;
}

/* =============================================================
   EPIGRAPH — random quote below nav
   ============================================================= */

#epigraph {
    text-align: center;
    padding: 14px 20px;
    font-style: italic;
    font-size: 14px;
    color: #444;
    border-bottom: 1px solid #e0e0e0;
}

#epigraph:empty {
    display: none;
}

.epigraph-author {
    font-style: normal;
    color: #666;
}

/* =============================================================
   THREE-COLUMN LAYOUT
   ============================================================= */

.essay-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 700px) 220px;
    gap: 0 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    justify-content: center;
}

/* =============================================================
   LEFT COLUMN — Table of Contents
   ============================================================= */

.essay-toc {
    padding-top: 60px;
}

.essay-toc nav {
    position: sticky;
    top: 60px;
}

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

.essay-toc li {
    margin-bottom: 6px;
}

.essay-toc li.toc-h3 {
    padding-left: 14px;
}

.essay-toc a {
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    font-size: 12px;
    color: #999;
    text-decoration: none;
    line-height: 1.4;
    display: block;
    padding: 2px 0;
    border-left: 2px solid transparent;
    padding-left: 10px;
    transition: color 0.15s, border-color 0.15s;
}

.essay-toc a:hover {
    color: #4a6741;
    text-decoration: none;
}

.essay-toc a.active {
    color: #4a6741;
    border-left-color: #4a6741;
    font-weight: 600;
}

/* =============================================================
   CENTER COLUMN — Essay content
   ============================================================= */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    font-size: 20px;
    line-height: 1.8;
    color: #1a1a1a;
    background: rgb(255, 252, 241);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #4a6741;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

::selection {
    background: #d4e2cf;
}

.essay-container {
    padding: 60px 0 100px;
    min-width: 0;
}

/* --- HEADER --- */
.essay-header {
    margin-bottom: 56px;
    padding-bottom: 32px;
    border-bottom: 1px solid #e0e0e0;
}

.essay-header h1 {
    font-family: inherit;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 20px;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

.essay-meta {
    font-size: 15px;
    color: #555;
}

.essay-meta .author {
    color: #333;
    font-weight: 500;
}

.essay-meta .date {
    color: #555;
}

/* --- HEADINGS --- */
h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
    font-weight: 600;
    scroll-margin-top: 60px;
    line-height: 1.3;
    color: #1a1a1a;
}

h2 {
    font-size: 24px;
    margin: 2.5em 0 0.8em;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

h3 {
    font-size: 20px;
    margin: 2em 0 0.6em;
}

h4 {
    font-size: 18px;
    margin: 1.5em 0 0.5em;
}

/* --- BODY TEXT --- */
p {
    margin: 0 0 1.4em;
}

strong {
    font-weight: 600;
}

/* --- CODE --- */
code {
    font-family: 'Ubuntu Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: #f6f8f5;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e8ece6;
}

pre {
    background: #f6f8f5;
    border: 1px solid #e8ece6;
    border-radius: 8px;
    padding: 20px 24px;
    overflow-x: auto;
    line-height: 1.55;
    margin: 1.8em 0;
}

pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 14px;
}

div.sourceCode {
    margin: 1.8em 0;
}

/* Pandoc syntax highlighting */
code span.kw { color: #5a5a8f; }              /* Keyword */
code span.cf { color: #5a5a8f; }              /* ControlFlow */
code span.dt { color: #4a6741; }              /* DataType */
code span.dv { color: #8a6340; }              /* DecVal (integers) */
code span.bn { color: #8a6340; }              /* BaseN */
code span.fl { color: #8a6340; }              /* Float */
code span.ch { color: #6a7e40; }              /* Char */
code span.st { color: #6a7e40; }              /* String */
code span.co { color: #8a8a8a; font-style: italic; } /* Comment */
code span.fu { color: #3d6b6b; }              /* Function */
code span.bu { color: #3d6b6b; }              /* BuiltIn */
code span.op { color: #555; }                 /* Operator */
code span.al { color: #9e3030; font-weight: bold; }  /* Alert */
code span.er { color: #9e3030; }              /* Error */
code span.im { color: #5a5a8f; }              /* Import */
code span.va { color: #7a5050; }              /* Variable */
code span.ss { color: #6a7e40; }              /* SpecialString */
code span.at { color: #8a6340; }              /* Attribute */
code span.do { color: #8a8a8a; font-style: italic; } /* Documentation */
code span.an { color: #8a8a8a; font-weight: bold; }  /* Annotation */
code span.pp { color: #5a5a8f; }              /* Preprocessor */
code span.ot { color: #3d6b6b; }              /* Other */

/* --- BLOCKQUOTES --- */
blockquote {
    border-left: 3px solid #4a6741;
    margin: 2em 0;
    padding: 1em 0 1em 1.5em;
    color: #333;
    font-style: italic;
}

blockquote p:last-child {
    margin-bottom: 0;
}

blockquote p:last-child:not(:first-child) {
    font-style: normal;
    font-size: 14px;
    color: #888;
    margin-top: 0.5em;
}

/* --- TABLES --- */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 2em 0;
    font-size: 15px;
    line-height: 1.5;
}

thead {
    border-bottom: 2px solid #4a6741;
}

th {
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4a6741;
    padding: 8px 16px;
    text-align: left;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f6f8f5;
}

.essay-container table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- IMAGES & FIGURES --- */
img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: zoom-in;
}

figure {
    margin: 2.5em 0;
    text-align: center;
}

figcaption, .caption {
    font-size: 14px;
    color: #555;
    margin-top: 10px;
    text-align: center;
    line-height: 1.5;
}

/* --- LISTS --- */
ul, ol {
    padding-left: 1.5em;
    margin: 1.2em 0;
}

li {
    margin-bottom: 0.4em;
}

li > ul, li > ol {
    margin: 0.3em 0;
}

/* --- HORIZONTAL RULE --- */
hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 3em 0;
}

/* --- FOOTER --- */
.essay-footer {
    margin-top: 80px;
    padding-top: 24px;
    border-top: 1px solid #e0e0e0;
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    font-size: 14px;
    color: #555;
}

.essay-footer a {
    color: #4a6741;
}

/* =============================================================
   RIGHT COLUMN — Sidenotes
   ============================================================= */

.essay-sidenotes {
    position: relative;
    padding-top: 60px;
}

.sidenote-content {
    font-size: 13px;
    line-height: 1.5;
    color: #444;
    padding-left: 12px;
    border-left: 1px solid #e0e0e0;
    width: 100%;
}

.sidenote-content sup {
    color: #4a6741;
    font-weight: 600;
}

.sidenote-ref {
    color: #4a6741;
    font-weight: 600;
    cursor: default;
}

/* Hide inline sidenote text on wide screens */
.sidenote-inline {
    display: none;
}

/* =============================================================
   LISTING PAGE
   ============================================================= */

.listing-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 60px 24px 100px;
    position: relative;
}

.listing-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../../assets/davinci.png') no-repeat center center;
    background-size: cover;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

.listing-container > * {
    position: relative;
    z-index: 1;
}

.listing-header {
    margin-bottom: 48px;
    text-align: left;
}

.listing-header h1 {
    font-family: inherit;
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.5px;
    text-align: left;
}

.listing-header p {
    color: #444;
    font-size: 16px;
    margin: 0;
    text-align: left;
}

.tag {
    font-family: 'Iowan Old Style BT', 'Iowan Old Style', Georgia, serif;
    font-size: 12px;
    color: #4a6741;
    background: #f0f5ee;
    padding: 1px 8px;
    border-radius: 3px;
}

.essay-list {
    list-style: disc;
    padding-left: 1.2em;
    margin: 0;
}

.essay-list li {
    padding: 12px 0;
}

.essay-list .title {
    display: block;
}

.essay-list .title a {
    font-family: inherit;
    font-size: 17px;
    font-weight: 500;
    color: #1a1a1a;
}

.essay-list .title a:hover {
    color: #4a6741;
    text-decoration: none;
}

.essay-list .attribution {
    display: block;
    color: #999;
    font-size: 14px;
    margin-top: 2px;
}

/* =============================================================
   RESPONSIVE — collapse to single column
   ============================================================= */

@media (max-width: 1060px) {
    /* Hide right sidenotes column, show inline */
    .essay-layout {
        grid-template-columns: 180px minmax(0, 700px);
    }

    .essay-sidenotes {
        display: none;
    }

    .sidenote-inline {
        display: inline;
        font-size: 14px;
        color: #777;
    }

    .sidenote-inline::before {
        content: " [";
    }

    .sidenote-inline::after {
        content: "]";
    }
}

@media (max-width: 800px) {
    /* Hide TOC column too */
    .essay-layout {
        grid-template-columns: 1fr;
        padding: 0 18px;
    }

    .essay-toc {
        display: none;
    }

    body {
        font-size: 16px;
    }

    .essay-container {
        padding: 32px 0 60px;
    }

    .essay-header h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 21px;
    }

    pre {
        padding: 14px 16px;
        border-radius: 6px;
    }

    pre code {
        font-size: 13px;
    }

    /* --- Nav: hamburger menu --- */
    .essay-nav {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .essay-nav .nav-toggle {
        display: flex;
    }

    .essay-nav .nav-title {
        flex-direction: column;
        gap: 2px;
    }

    .essay-nav .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .essay-nav.nav-open .nav-links {
        display: flex;
    }

    .essay-nav .nav-divider {
        display: none;
    }

    .essay-nav .nav-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .essay-nav .nav-collapse {
        display: flex;
        flex-direction: column;
        max-width: none;
        opacity: 1;
    }

    .essay-nav a {
        padding: 8px 0;
        margin: 0;
        font-size: 15px;
    }
}
