/* ===========================
   GLOBAL STYLES & RESET
   =========================== */

:root {
    /* Color Palette */
    --color-bg-canvas: #F7F3ED;
    --color-dark-panels: #2B2D42;
    --color-text-primary: #3A3632;
    --color-text-light: #F7F3ED;
    --color-accent-coral: #E07A5F;
    --color-accent-sage: #81B29A;
    --color-accent-gold: #F2CC8F;
    --color-border-meta: #8C8478;

    /* Fonts */
    --font-display: 'Bebas Neue', sans-serif;
    --font-body: 'Merriweather', serif;
    --font-accent: 'Karla', sans-serif;

    /* Spacing */
    --gap-masonry: 12px;
    --grid-row-unit: 20px;

    /* Easing */
    --easing-magnetic: cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Mouse tracking */
    --mouse-x: 0;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-bg-canvas);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.7;
    font-size: 0.9rem;
    overflow-x: hidden;
}

/* ===========================
   HEADER & NAVIGATION
   =========================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background-color: var(--color-dark-panels);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    height: 100%;
}

.nav-tab {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-light);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    transition: all 150ms ease;
    transform: translateX(calc(var(--mouse-x) * 0.1));
    position: relative;
}

.nav-tab:hover {
    color: var(--color-accent-coral);
    transform: translateX(calc(var(--mouse-x) * 0.1)) scale(1.05);
}

.nav-tab.active {
    color: var(--color-accent-gold);
    border-bottom: 2px solid var(--color-accent-gold);
}

.magnetic-cursor {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-accent-coral);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    z-index: 1001;
}

/* ===========================
   MAIN CONTENT AREA
   =========================== */

main {
    margin-top: 48px;
    padding: 24px;
    min-height: calc(100vh - 48px);
}

.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: var(--grid-row-unit);
    gap: var(--gap-masonry);
    max-width: 1600px;
    margin: 0 auto;
}

/* ===========================
   BLOCK BASE STYLES
   =========================== */

.block {
    background-color: var(--color-bg-canvas);
    border: 1px solid #E8E2D9;
    padding: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(30px);
    animation: blockFadeIn 500ms var(--easing-magnetic) forwards;
    content-visibility: auto;
    content-visibility-skip-stagger: auto;
}

@keyframes blockFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.block-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-dark-panels);
    margin-bottom: 16px;
    line-height: 1.2;
}

.block-text {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.7;
    color: var(--color-text-primary);
    flex-grow: 1;
}

.block-border {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--color-accent-coral);
}

/* ===========================
   BLOCK TYPES
   =========================== */

/* Article Block */
.block-article {
    background-color: #F7F3ED;
    flex-direction: column;
    justify-content: flex-start;
}

.block-article .block-border {
    background-color: var(--color-accent-coral);
}

/* Quote Block */
.block-quote {
    background-color: rgba(224, 122, 95, 0.05);
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    padding: 24px;
    flex-direction: column;
    gap: 12px;
}

.quote-text {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 400;
    font-style: italic;
    color: var(--color-text-primary);
    line-height: 1.6;
}

.quote-attribution {
    font-family: var(--font-accent);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-border-meta);
    margin-top: 8px;
}

.wave-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.05;
}

/* Timeline Block */
.block-timeline {
    background-color: var(--color-dark-panels);
    color: var(--color-text-light);
    flex-direction: column;
    justify-content: flex-start;
    gap: 0;
}

.block-timeline .block-title {
    color: var(--color-text-light);
    margin-bottom: 20px;
}

.timeline-nodes {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

.timeline-node {
    display: flex;
    gap: 12px;
    position: relative;
    padding-left: 20px;
}

.timeline-node::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: -16px;
    width: 1px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 2 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1,0 Q0,25 1,50 T1,100' stroke='%23F2CC8F' stroke-width='1' fill='none'/%3E%3C/svg%3E");
    background-size: 100% 40px;
    background-repeat: repeat-y;
    opacity: 0.5;
}

.timeline-node:last-child::before {
    display: none;
}

.timeline-marker {
    width: 10px;
    height: 10px;
    background-color: var(--color-accent-gold);
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.timeline-date {
    font-family: var(--font-accent);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent-gold);
    margin-bottom: 4px;
}

.timeline-event {
    font-size: 0.85rem;
    line-height: 1.6;
    color: rgba(247, 243, 237, 0.9);
}

/* Map Block */
.block-map {
    background-color: #EDE8DF;
    flex-direction: column;
    justify-content: flex-start;
}

.map-svg {
    width: 100%;
    height: auto;
    flex-grow: 1;
    margin-top: 12px;
}

/* Stat Block */
.block-stat {
    background-color: var(--color-dark-panels);
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-direction: column;
    gap: 12px;
}

.stat-number {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 400;
    color: var(--color-text-light);
    line-height: 1;
}

.stat-label {
    font-family: var(--font-accent);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(247, 243, 237, 0.8);
    line-height: 1.4;
}

/* Connection Block */
.block-connection {
    background-color: #F7F3ED;
    border: 2px dashed var(--color-border-meta);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.connection-diagram {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
    flex-grow: 1;
}

.connection-node {
    font-family: var(--font-accent);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-primary);
    background-color: rgba(255, 255, 255, 0.6);
    padding: 8px 12px;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    z-index: 2;
}

.connection-arrow {
    width: 100%;
    height: 24px;
    z-index: 1;
}

/* Image Block */
.block-image {
    background-color: #F7F3ED;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.collage-composition {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.collage-element {
    position: absolute;
}

.collage-text {
    font-family: var(--font-accent);
    font-weight: 600;
    letter-spacing: 0.08em;
}

/* ===========================
   HOVER STATES
   =========================== */

.block {
    transition: all 300ms ease;
}

.block:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

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

/* Tablet (768px - 1200px) */
@media (max-width: 1200px) {
    .masonry-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .block-title {
        font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    }

    main {
        padding: 16px;
    }
}

/* Mobile (<768px) */
@media (max-width: 768px) {
    .masonry-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .site-header {
        padding: 0 12px;
    }

    .nav-tabs {
        gap: 4px;
        overflow-x: auto;
    }

    .nav-tab {
        font-size: 0.8rem;
        padding: 6px 10px;
        white-space: nowrap;
    }

    main {
        padding: 12px;
        margin-top: 48px;
    }

    .block {
        padding: 16px;
        grid-row: span 8 !important;
    }

    .block-title {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .block-text {
        font-size: 0.85rem;
    }

    .stat-number {
        font-size: 2.5rem;
    }

    .quote-text {
        font-size: 1rem;
    }

    .timeline-nodes {
        gap: 12px;
    }
}

/* ===========================
   ANIMATION STAGGER
   =========================== */

.block:nth-child(1) { animation-delay: 0ms; }
.block:nth-child(2) { animation-delay: 50ms; }
.block:nth-child(3) { animation-delay: 100ms; }
.block:nth-child(4) { animation-delay: 150ms; }
.block:nth-child(5) { animation-delay: 200ms; }
.block:nth-child(6) { animation-delay: 250ms; }
.block:nth-child(7) { animation-delay: 300ms; }
.block:nth-child(8) { animation-delay: 350ms; }
.block:nth-child(9) { animation-delay: 400ms; }
.block:nth-child(10) { animation-delay: 450ms; }
.block:nth-child(11) { animation-delay: 500ms; }
.block:nth-child(12) { animation-delay: 550ms; }
.block:nth-child(13) { animation-delay: 600ms; }
.block:nth-child(14) { animation-delay: 650ms; }
.block:nth-child(15) { animation-delay: 700ms; }
.block:nth-child(16) { animation-delay: 750ms; }
.block:nth-child(17) { animation-delay: 800ms; }
.block:nth-child(18) { animation-delay: 850ms; }
.block:nth-child(19) { animation-delay: 900ms; }
.block:nth-child(20) { animation-delay: 950ms; }

/* ===========================
   UTILITY CLASSES
   =========================== */

.hidden {
    display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-canvas);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-meta);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-primary);
}

/* ===========================
   PRINT STYLES
   =========================== */

@media print {
    .site-header {
        position: static;
    }

    main {
        margin-top: 0;
    }

    .block {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .magnetic-cursor {
        display: none;
    }
}
