/* ===================================
   Fonts
   =================================== */

@font-face {
    font-family: 'Departure Mono';
    src: url('../fonts/DepartureMono-Regular.woff2') format('woff2'),
         url('../fonts/DepartureMono-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===================================
   Theme tokens
   =================================== */

:root {
    --bg: #ffffff;
    --text: #000000;
    --muted: #555555;
    --faint: #aaaaaa;
    --rule: #000000;
    --border: #000000;
    --link: #1155cc;
    --link-hover: #0a3d91;
}

html.dark {
    --bg: #0d0d0d;
    --text: #e8e8e8;
    --muted: #9a9a9a;
    --faint: #555555;
    --rule: #e8e8e8;
    --border: #e8e8e8;
    --link: #6eb3ff;
    --link-hover: #99ccff;
}

/* ===================================
   Reset & Base Styles
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    background-color: var(--bg);
}

body {
    font-family: 'Departure Mono', 'IBM Plex Mono', 'SF Mono', 'Monaco', 'Consolas', monospace;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    padding: 48px 24px;
    max-width: 820px;
    margin: 0 auto;
    font-weight: normal;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* ===================================
   Theme toggle
   =================================== */

.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    z-index: 100;
    transition: opacity 0.2s ease;
}

.theme-toggle:hover {
    opacity: 0.6;
}

/* ===================================
   Typography
   =================================== */

h1 {
    font-size: 2.25rem;
    margin-bottom: 0.4rem;
    font-weight: normal;
    line-height: 1.15;
    letter-spacing: 0;
}

h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--link-hover);
}

em {
    font-style: italic;
}

ul {
    list-style: none;
}

li {
    margin-bottom: 0.35rem;
}

/* ===================================
   Layout
   =================================== */

.container {
    width: 100%;
}

/* ===================================
   Masthead (name + photo)
   =================================== */

.masthead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.masthead-text {
    flex: 1;
    min-width: 0;
}

.affiliation {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0;
}

.profile-photo {
    width: 140px;
    height: auto;
    display: block;
    border: 2px solid var(--border);
    filter: grayscale(100%);
    flex-shrink: 0;
}

/* ===================================
   Intro + sections
   =================================== */

.intro {
    margin-bottom: 1rem;
}

.intro p:last-child {
    margin-bottom: 0;
}

.section {
    margin: 0;
}

.section li:before {
    content: "* ";
    color: var(--muted);
}

/* ===================================
   Section dividers (asterisks)
   =================================== */

.rule {
    border: none;
    text-align: center;
    color: var(--faint);
    margin: 2rem 0;
    overflow: visible;
    height: auto;
}

.rule:before {
    content: "*   *   *";
    letter-spacing: 0.3em;
    font-size: 0.9rem;
}

/* ===================================
   Breadcrumb Navigation
   =================================== */

.breadcrumb {
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--link);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ===================================
   Content Pages (portfolio, poems)
   =================================== */

.content {
    max-width: 100%;
}

.poem-content {
    margin: 0 auto;
}

.poem-meta {
    font-style: italic;
    color: var(--muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* ===================================
   Poem Formatting
   =================================== */

.poem {
    margin: 2rem 0;
    padding: 2rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.poem p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.line-numbers {
    position: relative;
}

.line-num {
    display: inline-block;
    width: 3em;
    text-align: right;
    margin-right: 1em;
    color: var(--muted);
    font-size: 0.8em;
    user-select: none;
}

.poem-preview {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--faint);
}

.poem-preview:last-of-type {
    border-bottom: none;
}

.poem-preview h2 a {
    color: var(--link);
    text-decoration: none;
}

.poem-preview h2 a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.excerpt {
    color: var(--text);
    font-style: italic;
    margin: 1rem 0;
}

.read-more {
    color: var(--link);
    font-weight: normal;
    text-decoration: none;
}

.read-more:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.poem-footer {
    margin-top: 3rem;
}

.back-link {
    color: var(--link);
    text-decoration: none;
}

.back-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ===================================
   Book Section
   =================================== */

.book-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--faint);
}

/* ===================================
   Footer
   =================================== */

footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ===================================
   Homepage (jdcarson-style directory)
   =================================== */

/* extra bottom padding so the fixed marquee never covers content */
body.home {
    padding-bottom: 64px;
}

.wordmark {
    display: block;
    text-align: center;
    font-size: 1.15rem;
    letter-spacing: 0.12em;
    font-weight: normal;
    line-height: 1.15;
    margin: 0;
    padding-bottom: 1.75rem;
}

.wordmark a {
    color: var(--text);
    text-decoration: none;
}

.wordmark a:hover {
    color: var(--text);
}

/* two-column: nested list on the left, photo + caption on the right */
.home-wrap {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    line-height: 1.35;
}

.home-list {
    flex: 1 1 60%;
    min-width: 0;
}

/* top-level categories: wittgenstein / tractatus numbering (1, 2, ...) */
.home-index {
    list-style: none;
    counter-reset: sec;
    padding-left: 0;
    margin: 0;
}

.home-index > li {
    counter-increment: sec;
    position: relative;
    padding-left: 2.2em;
    font-size: 1rem;
    margin-bottom: 0.7rem;
}

.home-index > li::before {
    content: counter(sec);
    position: absolute;
    left: 0;
    top: 0;
}

.home-index > li:last-child {
    margin-bottom: 0;
}

/* highlights under each category: decimal sub-numbering (1.1, 1.2, ...) */
.home-index ol {
    list-style: none;
    counter-reset: sub;
    padding-left: 0.4em;
    margin: 0.2rem 0 0;
}

.home-index ol li {
    counter-increment: sub;
    position: relative;
    padding-left: 2.6em;
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 0.1rem;
    line-height: 1.4;
}

.home-index ol li::before {
    content: counter(sec) "." counter(sub);
    position: absolute;
    left: 0;
    top: 0;
}

.home-index ol li:last-child {
    margin-bottom: 0;
}

.home-index ol li a {
    color: var(--link);
}

.home-list sup {
    font-size: 0.7em;
}

.home-pic {
    flex: 0 0 40%;
    text-align: center;
}

.home-pic img {
    width: 100%;
    height: auto;
    display: block;
    border: 2px solid var(--border);
    filter: grayscale(100%);
}

.home-caption {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--muted);
    text-align: left;
    padding-top: 0.9rem;
}

/* fixed scrolling footer marquee */
.marquee {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: 7px 0;
    background: var(--text);
    color: var(--bg);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    z-index: 10;
}

.marquee span {
    display: inline-block;
    padding-left: 100%;
    animation: marquee-scroll 60s linear infinite;
}

@keyframes marquee-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
    .marquee span { animation: none; padding-left: 1rem; }
}

/* ===================================
   Responsive
   =================================== */

@media (max-width: 600px) {
    body {
        padding: 24px 16px;
    }

    .masthead {
        flex-direction: column;
        gap: 1.5rem;
    }

    .profile-photo {
        width: 120px;
    }

    h1 {
        font-size: 1.85rem;
    }

    /* stack the homepage; float photo + caption to the top */
    .home-wrap {
        flex-direction: column;
        align-items: center;
        gap: 1.25rem;
    }

    .home-pic {
        order: -1;
        flex: none;
        width: 100%;
    }

    .home-pic img {
        max-width: 70%;
        margin: 0 auto;
    }

    .home-caption {
        text-align: center;
        max-width: 90%;
        margin: 0 auto;
    }

    .home-list {
        flex: none;
        width: 100%;
    }
}
