/* ============================================
   TAN MU RESEARCH
   ============================================ */

:root {
    --black: #111111;
    --text: #1a1a1a;
    --text-mid: #555555;
    --text-muted: #999999;
    --rule: #d0d0d0;
    --rule-light: #e6e6e6;
    --bg: #ffffff;

    --font-mono: 'Courier Prime', 'Courier New', monospace;
    --font-serif: 'EB Garamond', 'Georgia', serif;

    --side-pad: clamp(1.5rem, 4vw, 4rem);
    --max-width: 1200px;
    --reading-width: 680px;
}

/* ---- Reset ---- */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--text);
    background: var(--bg);
    letter-spacing: 0.02em;
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--black);
    color: var(--bg);
}

/* ============================================
   HEADER
   ============================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    transition: box-shadow 0.3s ease;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--side-pad);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--black);
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.site-title:hover {
    opacity: 0.5;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 2.25rem;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-mid);
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover {
    color: var(--black);
    border-bottom-color: var(--black);
}

.nav-link.active {
    color: var(--black);
}

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 22px;
    height: 16px;
    position: relative;
    z-index: 1100;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 1px;
    background: var(--black);
    position: absolute;
    left: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle span:first-child { top: 3px; }
.nav-toggle span:last-child { bottom: 3px; }

.nav-toggle.active span:first-child {
    transform: rotate(45deg);
    top: 7px;
}

.nav-toggle.active span:last-child {
    transform: rotate(-45deg);
    bottom: 7px;
}

/* Mobile nav */
.mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1050;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.75rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-link {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-mid);
    transition: color 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    color: var(--black);
}

/* ============================================
   MAIN
   ============================================ */

.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(56px + 5rem) var(--side-pad) 5rem;
}

/* ============================================
   ESSAYS STREAM (Homepage)
   ============================================ */

.essays-stream {
    display: flex;
    flex-direction: column;
}

.essay-entry {
    display: block;
    padding: 2.75rem 0;
    border-bottom: 1px solid var(--rule-light);
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.essay-entry:first-child {
    padding-top: 0;
}

.essay-entry:hover {
    opacity: 0.6;
}

.essay-date {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.essay-title {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 3.8vw, 2.875rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    color: var(--black);
    margin-bottom: 0.75rem;
    max-width: 820px;
}

.essay-brief {
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--text-mid);
    max-width: var(--reading-width);
}

/* Load more */
.load-more {
    padding-top: 3rem;
    text-align: center;
}

.load-more-btn {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-mid);
    background: none;
    border: 1px solid var(--rule);
    padding: 0.7rem 2rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.load-more-btn:hover {
    background: var(--black);
    color: var(--bg);
    border-color: var(--black);
}

/* ============================================
   ESSAY SINGLE (Full reading page)
   ============================================ */

.essay-single {
    max-width: var(--reading-width);
    margin-left: auto;
    margin-right: auto;
}

.essay-full {
    animation: fadeIn 0.5s ease both;
}

.essay-full-date {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.essay-full-title {
    font-family: var(--font-serif);
    font-size: clamp(2.25rem, 5vw, 3.25rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: var(--black);
    margin-bottom: 3rem;
}

.essay-full-body p {
    font-family: var(--font-serif);
    font-size: 1.1875rem;
    line-height: 1.82;
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: 0.003em;
}

.essay-full-body p em {
    font-style: italic;
}

.essay-full-body p:last-child {
    margin-bottom: 0;
}

/* Prev / Next nav */
.essay-nav {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--rule);
    gap: 2rem;
}

.essay-nav-link {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    max-width: 48%;
    transition: opacity 0.2s ease;
}

.essay-nav-link:hover {
    opacity: 0.5;
}

.essay-nav-link.next {
    margin-left: auto;
    text-align: right;
    flex-direction: row-reverse;
}

.essay-nav-dir {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.essay-nav-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.4;
    color: var(--text);
}

/* ============================================
   STATIC PAGES (About, Contact)
   ============================================ */

.page-static {
    max-width: 900px;
}

.page-heading {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--black);
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
}

/* ---- About ---- */

.about-body {
    display: grid;
    grid-template-columns: 5fr 2fr;
    gap: 5rem;
}

.about-text p {
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.78;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.about-lede {
    font-size: 1.1875rem !important;
    color: var(--black) !important;
    font-weight: 500 !important;
}

.about-text a {
    border-bottom: 1px solid var(--rule);
    transition: border-color 0.2s ease, opacity 0.2s ease;
}

.about-text a:hover {
    border-bottom-color: var(--black);
}

.about-aside {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding-top: 0.25rem;
}

.about-link-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.about-link-label {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.about-link-url {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text);
    letter-spacing: 0.03em;
    transition: opacity 0.2s ease;
}

.about-link-url:hover {
    opacity: 0.5;
}

/* ---- Contact ---- */

.contact-body {
    max-width: var(--reading-width);
}

.contact-text {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.contact-email {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    letter-spacing: 0.04em;
    color: var(--black);
    border-bottom: 1px solid var(--black);
    padding-bottom: 2px;
    transition: opacity 0.2s ease;
}

.contact-email:hover {
    opacity: 0.5;
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
    border-top: 1px solid var(--rule);
    margin-top: 5rem;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5rem var(--side-pad);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-brand {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--black);
}

.footer-right {
    display: flex;
    gap: 2rem;
}

.footer-link {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    color: var(--text-mid);
    transition: opacity 0.2s ease;
}

.footer-link:hover {
    opacity: 0.5;
}

.footer-colophon {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem var(--side-pad);
    border-top: 1px solid var(--rule-light);
}

.footer-colophon span {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.essay-entry {
    animation: fadeIn 0.5s ease both;
}

.essay-entry:nth-child(1) { animation-delay: 0s; }
.essay-entry:nth-child(2) { animation-delay: 0.05s; }
.essay-entry:nth-child(3) { animation-delay: 0.1s; }
.essay-entry:nth-child(4) { animation-delay: 0.15s; }
.essay-entry:nth-child(5) { animation-delay: 0.2s; }
.essay-entry:nth-child(6) { animation-delay: 0.25s; }
.essay-entry:nth-child(7) { animation-delay: 0.3s; }
.essay-entry:nth-child(8) { animation-delay: 0.35s; }

.about-section,
.contact-section {
    animation: fadeIn 0.5s ease both;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .about-body {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
}

@media (max-width: 768px) {
    .header-nav { display: none; }
    .nav-toggle { display: block; }
    .mobile-nav { display: flex; }

    .main-content {
        padding-top: calc(56px + 3rem);
        padding-bottom: 3rem;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.25rem;
    }

    .essay-nav {
        flex-direction: column;
    }

    .essay-nav-link {
        max-width: 100%;
    }

    .essay-nav-link.next {
        text-align: left;
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    :root {
        --side-pad: 1.25rem;
    }

    .essay-title {
        font-size: 1.625rem;
    }

    .essay-full-title {
        font-size: 1.875rem;
    }
}

/* ---- Print ---- */

@media print {
    .site-header, .site-footer, .nav-toggle, .mobile-nav, .load-more, .essay-nav { display: none; }
    .main-content { padding: 0; }
    body { font-size: 11pt; }
}

/* ============================================
   ESSAY IMAGES
   ============================================ */

.essay-image {
    margin: 2.5rem 0;
}

.essay-image img {
    width: 100%;
    height: auto;
    display: block;
}

.essay-image figcaption {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-top: 0.75rem;
    letter-spacing: 0.03em;
}

.essay-image figcaption em {
    font-style: italic;
}

.essay-image-placeholder {
    background: #f4f4f2;
    padding: 4rem 2rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}
