/* ppuzzle.net - Political Puzzle Design Language */
/* Palette:
   Primary: #2C3E50 (deep slate-blue)
   Secondary: #D35400 (warm burnt-orange)
   Accent A: #16A085 (teal-green)
   Accent B: #E74C3C (cardinal red)
   Neutral Warm: #ECF0F1 (off-white)
   Neutral Dark: #2C2C2C (charcoal)
   Highlight: #F39C12 (golden-amber)
   Subtle: #95A5A6 (light gray)
   Paper: #fafaf7 (aged paper)
*/

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

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

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    line-height: 1.7;
    color: #3a3a3a;
    background-color: #fafaf7;
    overflow-x: hidden;
}

/* Canvas texture overlay */
#canvas-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='1' height='1' fill='%232C2C2C'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ===== LEFT-SIDE INDEX COLUMN ===== */
#index-column {
    position: fixed;
    left: 0;
    top: 0;
    width: 18%;
    height: 100vh;
    background-color: #2C3E50;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.2rem;
    overflow-y: auto;
    will-change: transform;
}

.index-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: #ECF0F1;
    letter-spacing: 0.05em;
    margin-bottom: 2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #16A085;
}

.chapter-markers {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.chapter-marker {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.chapter-marker:hover,
.chapter-marker.active {
    background-color: rgba(22, 160, 133, 0.2);
}

.chapter-num {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    color: #95A5A6;
    min-width: 1.6rem;
    transition: color 0.3s ease;
}

.chapter-marker.active .chapter-num,
.chapter-marker:hover .chapter-num {
    color: #F39C12;
}

.chapter-label {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    color: #ECF0F1;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.chapter-marker.active .chapter-label,
.chapter-marker:hover .chapter-label {
    opacity: 1;
}

/* ===== MOBILE HEADER ===== */
#mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background-color: #2C3E50;
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.mobile-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: #ECF0F1;
}

.mobile-chapter-indicator {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.85rem;
    color: #F39C12;
}

/* ===== MAIN CONTENT ===== */
#content {
    margin-left: 18%;
    width: 82%;
    position: relative;
}

/* ===== HERO SECTION ===== */
#hero {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2C3E50;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #2C3E50 0%, #1a252f 60%, #2C3E50 100%);
    opacity: 0.95;
}

.hero-vignette {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 150px rgba(44, 62, 80, 0.6);
    pointer-events: none;
}

.hero-pattern {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.4;
}

.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 2rem;
}

.hero-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    color: #ECF0F1;
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.hero-tagline {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: #95A5A6;
    margin-bottom: 3rem;
    letter-spacing: 0.03em;
}

.chapter-circles {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.circle-marker {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #16A085;
    color: #ECF0F1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.circle-marker:hover {
    transform: scale(1.15);
    background-color: #D35400;
    box-shadow: 0 4px 15px rgba(211, 84, 0, 0.4);
}

/* Puzzle decorative elements */
.puzzle-deco {
    position: absolute;
    pointer-events: none;
}

.puzzle-deco-1 {
    width: 180px;
    height: 180px;
    top: 10%;
    left: 5%;
    opacity: 0.3;
    animation: float-slow 12s ease-in-out infinite;
}

.puzzle-deco-2 {
    width: 140px;
    height: 140px;
    bottom: 15%;
    right: 8%;
    opacity: 0.25;
    animation: float-slow 15s ease-in-out infinite reverse;
}

@keyframes float-slow {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

/* ===== CHAPTER SECTIONS ===== */
.chapter-section {
    padding: 6rem 4rem 4rem;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.chapter-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.chapter-header {
    margin-bottom: 2.5rem;
}

.chapter-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    color: #D35400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    display: block;
    margin-bottom: 0.5rem;
}

.chapter-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    color: #2C3E50;
    letter-spacing: 0.02em;
    position: relative;
    display: inline-block;
}

.title-underline {
    position: absolute;
    bottom: -4px;
    left: 0;
    height: 3px;
    width: 0;
    background-color: #16A085;
    transition: width 0.6s ease;
}

.chapter-section.visible .title-underline {
    width: 100%;
}

/* Zig-zag layout: alternating left-heavy and right-heavy */
.chapter-body {
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.left-heavy .chapter-body {
    flex-direction: row;
}

.right-heavy .chapter-body {
    flex-direction: row-reverse;
}

.full-width .chapter-body {
    flex-direction: column;
    align-items: center;
}

.content-block {
    flex-shrink: 0;
}

.content-block.wide {
    flex: 2;
    min-width: 300px;
}

.content-block.narrow {
    flex: 1;
    min-width: 240px;
}

.content-block.medium {
    flex: 1.5;
    min-width: 280px;
}

.content-block p {
    margin-bottom: 1.2rem;
    color: #3a3a3a;
}

/* Callout boxes with puzzle-piece borders */
.callout-box {
    background-color: #ECF0F1;
    border-left: 4px solid #F39C12;
    padding: 1.5rem 1.8rem;
    border-radius: 0 6px 6px 0;
    position: relative;
    align-self: flex-start;
}

.callout-box.right {
    border-left: none;
    border-right: 4px solid #F39C12;
    border-radius: 6px 0 0 6px;
}

.callout-icon {
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-bottom: 0.8rem;
}

.callout-icon svg {
    width: 100%;
    height: 100%;
}

.callout-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #2C2C2C;
}

/* Policy term highlights */
.policy-term {
    background-color: rgba(243, 156, 18, 0.15);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-weight: 500;
    color: #2C2C2C;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
}

.policy-term:hover {
    background-color: rgba(243, 156, 18, 0.35);
}

/* Puzzle piece icon on hover */
.policy-term::after {
    content: '';
    position: absolute;
    top: -8px;
    right: -12px;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23F39C12' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 8Q4 4 8 4L11 4Q11 2 12 2Q13 2 13 4L16 4Q20 4 20 8L20 11Q22 11 22 12Q22 13 20 13L20 16Q20 20 16 20L13 20Q13 22 12 22Q11 22 11 20L8 20Q4 20 4 16L4 13Q2 13 2 12Q2 11 4 11Z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    transform: rotate(0deg) scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.policy-term:hover::after {
    opacity: 1;
    transform: rotate(45deg) scale(1.2);
}

/* Section puzzle borders */
.section-puzzle-border {
    width: 100%;
    height: 20px;
    margin-top: 2rem;
    display: block;
}

/* ===== FULL-BLEED PARALLAX SECTIONS ===== */
.full-bleed-image {
    height: 40vh;
    position: relative;
    overflow: hidden;
    background-color: #1a252f;
}

.parallax-overlay {
    position: absolute;
    inset: 0;
    background-color: #2C3E50;
    opacity: 0.3;
}

.parallax-vignette {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 100px rgba(44, 62, 80, 0.5);
    pointer-events: none;
}

.geometric-pattern {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.geometric-pattern svg {
    width: 100%;
    height: 100%;
}

/* ===== DATA VISUALIZATIONS ===== */
.data-viz {
    background-color: #ECF0F1;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid rgba(149, 165, 166, 0.3);
}

.viz-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.8rem;
    color: #2C3E50;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.2rem;
}

/* Bar chart */
.viz-bars {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.viz-bar {
    position: relative;
    height: 32px;
    background-color: rgba(149, 165, 166, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.viz-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: var(--bar-color);
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.viz-bar.animated::before {
    width: calc(var(--bar-width, 0) * 1%);
}

.bar-label {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    height: 100%;
    padding-left: 0.8rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #2C2C2C;
}

/* Line chart */
.line-chart-svg {
    width: 100%;
    max-width: 400px;
}

.chart-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease;
}

.chart-line.drawn {
    stroke-dashoffset: 0;
}

/* Connection diagram */
.viz-nodes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.viz-node {
    padding: 0.8rem 1.2rem;
    background-color: var(--node-color);
    color: #ECF0F1;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.8rem;
    border-radius: 6px;
    text-align: center;
}

.viz-connector {
    width: 40px;
    height: 2px;
    background-color: #95A5A6;
    position: relative;
}

.viz-connector::after {
    content: '';
    position: absolute;
    right: -4px;
    top: -4px;
    width: 0;
    height: 0;
    border-left: 6px solid #95A5A6;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

/* Feedback loop */
.feedback-ring {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    position: relative;
}

.feedback-node {
    padding: 0.6rem 1rem;
    background-color: #2C3E50;
    color: #ECF0F1;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    border-radius: 20px;
    position: relative;
}

.feedback-node::after {
    content: '\2192';
    position: absolute;
    right: -1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #16A085;
    font-size: 1.1rem;
}

.feedback-node:last-child::after {
    content: '\21BB';
    color: #D35400;
}

/* ===== PUZZLE ASSEMBLY (Chapter 12) ===== */
.synthesis-block {
    max-width: 700px;
}

.synthesis-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #2C2C2C;
}

.puzzle-assembly {
    margin: 3rem auto;
    max-width: 520px;
}

.assembly-svg {
    width: 100%;
    height: auto;
}

.puzzle-piece {
    opacity: 0;
    transform: translate(0, 20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.puzzle-piece.placed {
    opacity: 1;
    transform: translate(0, 0);
}

.connection-line {
    opacity: 0;
    transition: opacity 0.4s ease 0.3s;
}

.puzzle-assembly.assembled .connection-line {
    opacity: 0.4;
}

/* ===== FOOTER ===== */
#site-footer {
    background-color: #2C3E50;
    padding: 4rem 3rem;
    text-align: center;
}

.footer-content {
    max-width: 500px;
    margin: 0 auto;
}

.footer-brand {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: #ECF0F1;
    margin-bottom: 0.5rem;
}

.footer-tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: #95A5A6;
    margin-bottom: 1.5rem;
}

.footer-puzzle {
    width: 200px;
    margin: 0 auto;
    display: block;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    #index-column {
        display: none;
    }

    #mobile-header {
        display: flex;
    }

    #content {
        margin-left: 0;
        width: 100%;
        padding-top: 48px;
    }

    .chapter-section {
        padding: 4rem 2rem 3rem;
    }

    .chapter-body {
        flex-direction: column !important;
    }

    .content-block.wide,
    .content-block.narrow,
    .content-block.medium {
        min-width: 100%;
    }

    .callout-box.right {
        border-right: none;
        border-left: 4px solid #F39C12;
        border-radius: 0 6px 6px 0;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .circle-marker {
        width: 34px;
        height: 34px;
        font-size: 0.7rem;
    }

    .viz-nodes {
        flex-direction: column;
        gap: 0.5rem;
    }

    .viz-connector {
        width: 2px;
        height: 20px;
    }

    .viz-connector::after {
        right: auto;
        bottom: -4px;
        top: auto;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid #95A5A6;
        border-bottom: none;
        left: -4px;
    }
}

@media (max-width: 600px) {
    .chapter-section {
        padding: 3rem 1.2rem 2rem;
    }

    .chapter-circles {
        gap: 0.5rem;
    }

    .circle-marker {
        width: 30px;
        height: 30px;
        font-size: 0.65rem;
    }

    .puzzle-deco {
        display: none;
    }

    .data-viz {
        padding: 1rem;
    }

    .feedback-ring {
        flex-direction: column;
        align-items: center;
    }

    .feedback-node::after {
        right: auto;
        bottom: -1.2rem;
        top: auto;
        left: 50%;
        transform: translateX(-50%) rotate(90deg);
    }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #fafaf7;
}

::-webkit-scrollbar-thumb {
    background: #95A5A6;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2C3E50;
}
