/* Shared site layout: top header + centered content.
   Loaded after each page's inline <style>, so it overrides the legacy sidebar rules. */

:root {
    --header-bg: #FAFAF8;
    --rule: #000;
    --content-width: 760px;
    --gutter: clamp(1.25rem, 4vw, 2rem);
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body { padding-top: 0; }

/* ---------- Page frame ---------- */
.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    width: 100%;
    max-width: calc(var(--content-width) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 2.5rem var(--gutter) 3rem;
    overflow: visible;
    flex: 1 0 auto;
}

.site-footer {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 1.5rem 0 2.5rem;
    margin-top: 1rem;
    border-top: 1px solid #E2E2E1;
    width: calc(100% - 2 * var(--gutter));
    text-align: center;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    font-family: var(--sans);
}
.site-footer p { margin: 0; }
.site-footer p + p { color: #000; margin-top: 0.25rem; }
.site-footer svg { vertical-align: middle; margin-right: 4px; }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid #E2E2E1;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem var(--gutter) 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}
.brand .profile-image {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 30%;
    border: 1px solid #000;
    flex-shrink: 0;
}
.brand h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin: 0;
}
.tagline {
    font-family: 'Libre Caslon Text', Georgia, serif;
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.8;
    margin: 0.15rem 0 0;
    letter-spacing: 0.01em;
}
.tagline-menu { display: none; }

/* Search is hidden from the banner for now (markup kept; remove these rules to restore) */
.header-search, .mobile-search { display: none !important; }

.header-search { width: 240px; max-width: 100%; }
.mobile-search { display: none; }

/* Search box (re-declared; legacy rules were scoped to the sidebar) */
.search-row { display: flex; align-items: center; gap: 0.3rem; }

/* ---------- Menu / nav ---------- */
.menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0 var(--gutter);
    border-top: 1px solid #E2E2E1;
}
.menu nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 1.75rem;
    margin: 0;
    padding: 0;
}
.menu nav li { margin: 0; position: relative; }
.menu nav a {
    display: inline-block;
    padding: 0.8rem 0;
    color: #000;
    text-decoration: none;
    font-family: var(--sans);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
}
.menu nav a:hover { border-bottom-color: #000; }
.menu nav a.active { font-weight: 700; border-bottom-color: #000; }

.social-links {
    font-family: var(--sans);
    font-size: 0.8rem;
    margin: 0;
    white-space: nowrap;
    opacity: 0.85;
}
.social-links svg { vertical-align: middle; }

/* Papers sub-menu: dropdown on desktop */
.menu nav ul.tree {
    display: none;
    position: absolute;
    top: 100%;
    left: -0.75rem;
    z-index: 10;
    flex-direction: column;
    gap: 0;
    min-width: 14rem;
    padding: 0.4rem 0.75rem;
    background: var(--header-bg);
    border: 1px solid #E2E2E1;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.menu nav li.nav-tree:hover > ul.tree,
.menu nav li.nav-tree:focus-within > ul.tree { display: flex; }
.menu nav ul.tree li { margin: 0; }
.menu nav ul.tree a { padding: 0.5rem 0; font-size: 0.75rem; letter-spacing: 1.2px; }
.menu nav ul.tree a.current { font-weight: 700; border-bottom-color: #000; }
.menu nav ul.tree .wip-tag { font-size: 0.72rem; }

/* ---------- Hamburger (small screens only) ---------- */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
    position: relative;
    z-index: 102;
}
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #000;
    transition: transform 0.3s, opacity 0.3s;
}
.site-header.nav-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header.nav-open .hamburger span:nth-child(2) { opacity: 0; }
.site-header.nav-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 99;
}

/* ---------- Small screens: photo + name, menu in a drawer ---------- */
@media (max-width: 1440px) {
    .header-top { padding: 0.75rem var(--gutter); }
    .brand .profile-image { width: 40px; height: 40px; }
    .brand h1 { font-size: 1.5rem; }
    .tagline-desktop, .header-search { display: none; }
    .hamburger { display: flex; }

    .mobile-search { display: block; padding: 0 var(--gutter) 0.75rem; }

    .menu {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 80%;
        max-width: 340px;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 1rem;
        padding: 4.5rem 1.5rem 2rem;
        background: var(--header-bg);
        border-top: 0;
        border-left: 1px solid #000;
        overflow-y: auto;
        transform: translateX(110%);
        visibility: hidden;
        transition: transform 0.35s ease, visibility 0s linear 0.35s;
        z-index: 101;
    }
    .site-header.nav-open .menu {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.35s ease;
    }

    .tagline-menu { display: block; font-size: 1.125rem; margin: 0; }
    .menu nav ul { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; }
    .menu nav a { font-size: 1.125rem; padding: 0.6rem 0; }
    .social-links { font-size: 1rem; }

    /* Sub-menu is always expanded inside the drawer */
    .menu nav ul.tree {
        display: flex;
        position: static;
        min-width: 0;
        margin: 0 0 0.25rem 0.4rem;
        padding: 0 0 0 1rem;
        border: 0;
        border-left: 1px solid #000;
        box-shadow: none;
        background: transparent;
    }
    .menu nav ul.tree a { font-size: 1rem; }

    .main-content { padding-top: 1.5rem; }
}

/* Keep the legacy small-screen body padding from the inline styles out of the way */
@media (max-width: 768px) { body { padding-top: 0; } }

/* Desktop: brand, nav and search share one banner row */
@media (min-width: 1441px) {
    .site-header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 1.5rem;
        padding: 0.9rem var(--gutter);
    }
    .header-top { display: contents; }
    .brand { grid-row: 1; grid-column: 1; justify-self: start; }
    .menu { display: contents; }
    .menu nav { grid-row: 1; grid-column: 2; }
    .menu .social-links { grid-row: 1; grid-column: 3; justify-self: end; font-size: 0.85rem; }
    .menu nav ul { gap: 0 1.25rem; }
    .menu nav a { padding: 0.5rem 0; font-size: 0.78rem; letter-spacing: 1px; }
    .menu nav ul.tree { top: calc(100% + 0.4rem); }
    .menu nav li.nav-tree::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 0.6rem; }
}

/* ---------- Card overview (Papers, Social Experiments, Vibe-Coding) ---------- */
.paper-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.paper-card { border: 1px solid #2B2320; border-radius: 10px; padding: 1.5rem; background: #FAFAF8; display: flex; flex-direction: column; }
.paper-card h3 { font-family: 'Playfair Display', Georgia, serif; font-size: 1.35rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.6rem; }
.paper-card p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 0.75rem; }
.paper-card .read-more { margin-top: 0.75rem; color: #000; font-weight: 700; text-decoration: none; border-bottom: 1px solid #000; align-self: flex-start; }
.paper-card .read-more:hover { opacity: 0.65; }
.paper-cards.no-dates .read-more { margin-top: auto; }
.paper-cards.no-dates .paper-card p { margin-bottom: 1.25rem; }
.paper-view[hidden] { display: none; }
.status-tag { display: inline-block; align-self: flex-start; margin: 0 0 0.6rem; padding: 2px 10px; border: 1px solid #747474; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: #595959; font-family: var(--sans); }
.intro-header .status-tag { margin: 0 0 1rem; }
.back-link { margin: 0 0 1.5rem; font-family: var(--sans); font-size: 0.85rem; }
.back-link a { color: #000; text-decoration: none; border-bottom: 1px solid #000; }
.back-link a:hover { opacity: 0.65; }
.note-preview.expanded::after { display: none; }
@media (max-width: 768px) { .paper-card p { font-size: 1rem; } }

/* Equal-size cards (same footprint as the Papers cards) */
.paper-cards { grid-auto-rows: 1fr; }
@media (min-width: 769px) { .paper-cards.no-dates .paper-card { min-height: 19rem; } }

/* Dated cards */
.paper-card .paper-date { font-size: 14px; color: #747474; font-family: var(--sans); margin-top: auto; margin-bottom: 0; }
.paper-card .card-desc { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 769px) { .paper-card { min-height: 19rem; } }
div.paper-cards#notes { display: grid; flex-direction: initial; }
