/* ===================================================
   ppuzzle.org - Political Puzzle
   Dark-Academia Split-Screen Design
   =================================================== */

/* --- CSS Custom Properties --- */
:root {
    --dark-walnut: #1A1612;
    --library-oak: #221E18;
    --manuscript-cream: #E8DFD0;
    --thesis-gold: #C9A84C;
    --argument-blue: #5B7B9A;
    --citation-green: #6B8F6E;
    --margin-red: #9B4D4D;

    --font-headlines: 'Space Grotesk', sans-serif;
    --font-body: 'Lora', serif;
    --font-labels: 'JetBrains Mono', monospace;

    --header-height: 48px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--dark-walnut);
    color: var(--manuscript-cream);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(17px, 1.6vw, 19px);
    line-height: 1.8;
    overflow: hidden;
}

a {
    color: var(--thesis-gold);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--argument-blue);
}

/* --- Header Bar --- */
#header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--dark-walnut);
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
    z-index: 100;
    display: flex;
    align-items: center;
}

.header-inner {
    width: 100%;
    max-width: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wordmark-text {
    font-family: var(--font-headlines);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--manuscript-cream);
    font-variant: small-caps;
}

.header-motif {
    opacity: 0.7;
}

.header-nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: rgba(232, 223, 208, 0.5);
    transition: color 0.3s ease;
    text-transform: uppercase;
}

.nav-link:hover,
.nav-link.active {
    color: var(--thesis-gold);
}

.header-motifs {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* --- Main Split-Screen Grid --- */
.main-grid {
    display: grid;
    grid-template-columns: 45fr 55fr;
    height: 100vh;
    padding-top: var(--header-height);
}

/* --- Panels --- */
.panel {
    overflow-y: auto;
    scroll-behavior: smooth;
    position: relative;
}

.panel-left {
    background: var(--dark-walnut);
}

.panel-right {
    background: var(--library-oak);
    border-left: 1px solid rgba(201, 168, 76, 0.08);
}

/* Reading Lamp Effect */
.panel-lamp {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle 200px at var(--mx, -100px) var(--my, -100px), rgba(201, 168, 76, 0.05), transparent);
    transition: background 0.1s ease;
}

/* Panel Content */
.panel-content {
    position: relative;
    z-index: 1;
}

.left-content {
    max-width: 520px;
    margin-left: auto;
    margin-right: 40px;
    padding: 60px 0 80px;
}

.right-content {
    max-width: 600px;
    margin-left: 40px;
    margin-right: auto;
    padding: 60px 0 80px;
}

/* --- Essays (Left Panel) --- */
.essay {
    margin-bottom: 80px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.essay.visible {
    opacity: 1;
    transform: translateY(0);
}

.essay-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.meta-label {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--thesis-gold);
    text-transform: uppercase;
}

.meta-date {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: rgba(232, 223, 208, 0.35);
    margin-left: auto;
}

.essay-title {
    font-family: var(--font-headlines);
    font-weight: 700;
    font-size: clamp(24px, 3.5vw, 44px);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--manuscript-cream);
    margin-bottom: 20px;
}

.essay-lede {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(17px, 1.6vw, 19px);
    line-height: 1.8;
    color: rgba(232, 223, 208, 0.85);
    margin-bottom: 28px;
    border-left: 2px solid var(--thesis-gold);
    padding-left: 16px;
}

.essay-body p {
    margin-bottom: 20px;
    color: rgba(232, 223, 208, 0.75);
}

.pull-quote {
    display: block;
    font-family: var(--font-body);
    font-weight: 700;
    font-style: italic;
    font-size: clamp(18px, 2vw, 22px);
    line-height: 1.6;
    color: var(--thesis-gold);
    padding: 24px 0;
    margin: 12px 0;
    border-top: 1px solid rgba(201, 168, 76, 0.2);
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
}

.essay-notation-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(232, 223, 208, 0.08);
}

.footnote-ref {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: rgba(232, 223, 208, 0.4);
}

/* Notation Symbols */
.notation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* --- Evidence Blocks (Right Panel) --- */
.evidence-block {
    margin-bottom: 80px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.evidence-block.visible {
    opacity: 1;
    transform: scale(1);
}

.generative-art {
    width: 100%;
    height: 280px;
    margin-bottom: 32px;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    background: rgba(26, 22, 18, 0.4);
}

.evidence-content {
    padding: 0 4px;
}

.evidence-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.evidence-label {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--argument-blue);
    text-transform: uppercase;
}

/* Source Cards */
.source-card {
    background: rgba(232, 223, 208, 0.03);
    border: 1px solid rgba(232, 223, 208, 0.06);
    border-left: 3px solid var(--argument-blue);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.source-card:hover {
    border-left-color: var(--thesis-gold);
    background: rgba(232, 223, 208, 0.05);
}

.source-title {
    font-family: var(--font-headlines);
    font-weight: 500;
    font-size: 16px;
    letter-spacing: -0.02em;
    color: var(--manuscript-cream);
    margin-bottom: 6px;
}

.source-meta {
    font-family: var(--font-labels);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--citation-green);
    margin-bottom: 12px;
}

.source-excerpt {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
    color: rgba(232, 223, 208, 0.65);
    margin-bottom: 10px;
}

.citation-ref {
    font-family: var(--font-labels);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(232, 223, 208, 0.3);
}

/* Data Visualizations */
.data-visualization {
    margin-top: 24px;
    padding: 24px;
    background: rgba(26, 22, 18, 0.5);
    border: 1px solid rgba(232, 223, 208, 0.06);
}

.viz-title {
    font-family: var(--font-headlines);
    font-weight: 500;
    font-size: 14px;
    letter-spacing: -0.02em;
    color: rgba(232, 223, 208, 0.7);
    margin-bottom: 20px;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    font-family: var(--font-labels);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(232, 223, 208, 0.45);
    min-width: 80px;
    text-align: right;
}

.bar {
    height: 24px;
    width: var(--bar-width, 50%);
    background: linear-gradient(90deg, var(--thesis-gold), rgba(201, 168, 76, 0.6));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    transition: width 1s ease;
}

.bar-value {
    font-family: var(--font-labels);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--dark-walnut);
    font-weight: 400;
}

.bar-historical {
    background: linear-gradient(90deg, var(--argument-blue), rgba(91, 123, 154, 0.6));
}

.bar-historical .bar-value {
    color: var(--manuscript-cream);
}

.bar-current {
    background: linear-gradient(90deg, var(--margin-red), rgba(155, 77, 77, 0.6));
}

.bar-current .bar-value {
    color: var(--manuscript-cream);
}

.bar-target {
    background: linear-gradient(90deg, var(--citation-green), rgba(107, 143, 110, 0.6));
}

.bar-target .bar-value {
    color: var(--dark-walnut);
}

/* --- Connection Lines Overlay --- */
.connection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.connection-overlay line {
    stroke: var(--thesis-gold);
    stroke-width: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.connection-overlay line.active {
    opacity: 0.3;
}

/* --- Scrollbar Styling --- */
.panel::-webkit-scrollbar {
    width: 4px;
}

.panel::-webkit-scrollbar-track {
    background: transparent;
}

.panel::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.2);
    border-radius: 2px;
}

.panel::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.4);
}

/* --- Mobile Overlay --- */
.mobile-overlay {
    display: none;
}

/* --- Mobile Responsive (below 768px) --- */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-grid {
        display: block;
        height: auto;
    }

    .panel {
        overflow: visible;
    }

    .panel-left {
        min-height: auto;
    }

    .panel-right {
        display: none;
    }

    .left-content {
        max-width: 100%;
        margin: 0;
        padding: 40px 20px 60px;
    }

    .right-content {
        max-width: 100%;
        margin: 0;
        padding: 20px;
    }

    .header-nav {
        display: none;
    }

    .header-motifs {
        display: none;
    }

    /* Mobile: Show evidence as accordions after each essay */
    .essay {
        margin-bottom: 20px;
    }

    .mobile-evidence {
        display: block;
        margin-bottom: 60px;
    }

    .mobile-evidence-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 14px 16px;
        background: var(--library-oak);
        border: 1px solid rgba(201, 168, 76, 0.12);
        color: var(--argument-blue);
        font-family: var(--font-labels);
        font-size: 11px;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        cursor: pointer;
        transition: background 0.3s ease;
    }

    .mobile-evidence-toggle:hover {
        background: rgba(34, 30, 24, 0.9);
    }

    .mobile-evidence-toggle .toggle-arrow {
        margin-left: auto;
        transition: transform 0.3s ease;
    }

    .mobile-evidence-toggle.expanded .toggle-arrow {
        transform: rotate(180deg);
    }

    .mobile-evidence-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.5s ease;
        background: var(--library-oak);
        border: 1px solid rgba(201, 168, 76, 0.08);
        border-top: none;
    }

    .mobile-evidence-content.expanded {
        max-height: 2000px;
    }

    .mobile-evidence-content .evidence-content {
        padding: 20px 16px;
    }

    .generative-art {
        height: 180px;
    }

    .panel-lamp {
        display: none;
    }
}

/* --- Tablet (769px - 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .left-content {
        max-width: 400px;
        margin-right: 24px;
    }

    .right-content {
        max-width: 460px;
        margin-left: 24px;
    }

    .essay-title {
        font-size: clamp(22px, 3vw, 34px);
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(201, 168, 76, 0.3);
    color: var(--manuscript-cream);
}
