/* ============================================================
   politics.quest — Surrealist Parliamentary Architecture
   ============================================================ */

/* Custom Properties */
:root {
    --color-cream: #F5E6C8;
    --color-cream-alt: #EDD9B5;
    --color-umber: #3A2E1F;
    --color-walnut: #2A1F14;
    --color-sienna: #5A4A38;
    --color-brass: #C4A265;
    --color-bronze: #8B7355;
    --color-copper: #7A6B4E;
    --color-amber: #E8B84D;
    --color-parchment: #D4C4A8;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-cream);
    color: var(--color-sienna);
    line-height: 1.7;
    font-size: clamp(0.95rem, 1.3vw, 1.15rem);
    font-weight: 400;
    overflow-x: hidden;
    position: relative;
}

/* ============================================================
   Film Grain Overlay
   ============================================================ */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.06;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    animation: grain 320ms steps(4) infinite;
}

@keyframes grain {
    0% { background-position: 0 0; }
    25% { background-position: -128px -64px; }
    50% { background-position: -64px -128px; }
    75% { background-position: -128px 0; }
    100% { background-position: 0 0; }
}

/* ============================================================
   FOYER — Opening Sequence (100vh)
   ============================================================ */
.foyer {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-left: 10%;
    background: linear-gradient(135deg, var(--color-cream) 0%, var(--color-cream-alt) 100%);
    overflow: hidden;
}

.foyer-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: -0.02em;
    color: var(--color-walnut);
    position: relative;
    z-index: 2;
    line-height: 1;
    margin-left: 10%;
}

.foyer-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--color-bronze);
    margin-top: 1.5rem;
    margin-left: 10%;
    opacity: 0;
    transform: translateY(12px);
    animation: fadeInUp 800ms cubic-bezier(0.16, 1, 0.3, 1) 1.2s forwards;
    position: relative;
    z-index: 2;
}

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

/* Foyer Hexagon */
.foyer-hexagon {
    position: absolute;
    top: 50%;
    left: 60%;
    transform: translate(-50%, -50%);
    width: clamp(300px, 50vw, 700px);
    height: clamp(300px, 50vw, 700px);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: var(--color-brass);
    opacity: 0.08;
    z-index: 1;
    animation: pulse 4s cubic-bezier(0.45, 0, 0.55, 1) infinite, rotate 120s linear infinite;
}

/* Foyer Nested Rectangles */
.foyer-nested-rect {
    position: absolute;
    top: 50%;
    left: 60%;
    transform: translate(-50%, -50%);
    border: 1px solid var(--color-brass);
    z-index: 1;
}

.foyer-nested-rect--1 {
    width: clamp(400px, 60vw, 800px);
    height: clamp(300px, 45vw, 600px);
    opacity: 0.12;
}

.foyer-nested-rect--2 {
    width: clamp(350px, 52vw, 700px);
    height: clamp(260px, 38vw, 520px);
    opacity: 0.08;
}

.foyer-nested-rect--3 {
    width: clamp(300px, 44vw, 600px);
    height: clamp(220px, 31vw, 440px);
    opacity: 0.04;
}

/* ============================================================
   Keyframes — Pulse & Rotate
   ============================================================ */
@keyframes pulse {
    0%, 100% {
        opacity: 0.08;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.18;
        transform: translate(-50%, -50%) scale(1.03);
    }
}

@keyframes rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes pulseSimple {
    0%, 100% {
        opacity: 0.08;
        transform: scale(1);
    }
    50% {
        opacity: 0.18;
        transform: scale(1.03);
    }
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================================
   GRID SECTIONS
   ============================================================ */
.grid-section {
    padding: clamp(3rem, 6vw, 8rem) clamp(1.5rem, 4vw, 6rem);
    background: linear-gradient(180deg, var(--color-cream) 0%, var(--color-cream-alt) 100%);
}

.grid-section--dark {
    background: linear-gradient(180deg, var(--color-umber) 0%, var(--color-walnut) 100%);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(200px, auto);
    gap: clamp(1rem, 2.5vw, 2.5rem);
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================================
   GRID CELLS
   ============================================================ */
.grid-cell {
    position: relative;
    padding: clamp(1.5rem, 3vw, 3rem);
    background-color: rgba(245, 230, 200, 0.5);
    box-shadow: inset 0 0 0 1px rgba(196, 162, 101, 0.19);
    transition: box-shadow 300ms ease, transform 300ms ease;
    overflow: hidden;
    /* Default state for reveal animation */
    opacity: 0;
    transform: translateY(24px) rotate(0.5deg);
}

.grid-cell.revealed {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
    transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark variant */
.grid-cell--dark {
    background-color: rgba(58, 46, 31, 0.6);
    box-shadow: inset 0 0 0 1px rgba(196, 162, 101, 0.15);
}

.grid-cell--dark .cell-label {
    color: var(--color-bronze);
}

.grid-cell--dark .cell-title {
    color: var(--color-parchment);
}

.grid-cell--dark .cell-text {
    color: var(--color-parchment);
    opacity: 0.85;
}

/* Cell modifiers */
.grid-cell--span-2 {
    grid-column: span 2;
}

.grid-cell--rotate-1 {
    transform: translateY(24px) rotate(1.5deg);
}
.grid-cell--rotate-1.revealed {
    transform: translateY(0) rotate(1deg);
}

.grid-cell--rotate-2 {
    transform: translateY(24px) rotate(2.5deg);
}
.grid-cell--rotate-2.revealed {
    transform: translateY(0) rotate(2deg);
}

.grid-cell--rotate-neg {
    transform: translateY(24px) rotate(-1.5deg);
}
.grid-cell--rotate-neg.revealed {
    transform: translateY(0) rotate(-1.5deg);
}

.grid-cell--scale-up {
    transform: translateY(24px) scale(1.05) rotate(0.5deg);
}
.grid-cell--scale-up.revealed {
    transform: translateY(0) scale(1.05) rotate(0deg);
}

.grid-cell--scale-down {
    transform: translateY(24px) scale(0.92) rotate(0.5deg);
}
.grid-cell--scale-down.revealed {
    transform: translateY(0) scale(0.92) rotate(0deg);
}

.grid-cell--clip-corner {
    clip-path: polygon(0 0, 100% 0, 100% 85%, 92% 100%, 0 100%);
}

.grid-cell--clip-corner-alt {
    clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%, 0 15%);
}

/* Hover interactions (desktop only) */
@media (hover: hover) {
    .grid-cell:hover {
        box-shadow: inset 0 0 0 2px rgba(196, 162, 101, 0.5);
        transform: translateY(-2px);
    }

    .grid-cell:hover .cell-hexagon,
    .grid-cell:hover .cell-arc,
    .grid-cell:hover .cell-triangle {
        opacity: 0.20;
    }
}

/* Cell content */
.cell-label {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-bronze);
    display: block;
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 2;
}

.cell-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    letter-spacing: 0.01em;
    color: var(--color-walnut);
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 2;
}

.cell-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.7;
    color: var(--color-sienna);
    position: relative;
    z-index: 2;
}

/* ============================================================
   Cell Decorative Elements
   ============================================================ */

/* Hexagons */
.cell-hexagon {
    position: absolute;
    top: 50%;
    right: 10%;
    transform: translate(0, -50%);
    width: 120px;
    height: 120px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: var(--color-brass);
    opacity: 0.08;
    z-index: 1;
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
    transition: opacity 300ms ease;
}

.cell-hexagon--small {
    width: 80px;
    height: 80px;
}

.cell-hexagon--large {
    width: 180px;
    height: 180px;
}

/* Triangles */
.cell-triangle {
    position: absolute;
    bottom: 1rem;
    right: 1.5rem;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid var(--color-brass);
    opacity: 0.12;
    z-index: 1;
    transition: opacity 300ms ease;
}

.cell-triangle--inverted {
    border-top: none;
    border-bottom: 20px solid var(--color-brass);
    bottom: auto;
    top: 1rem;
}

/* Arcs (quarter-circle decorations) */
.cell-arc {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid var(--color-brass);
    opacity: 0.10;
    z-index: 1;
    transition: opacity 300ms ease;
}

.cell-arc--top-right {
    top: 0;
    right: 0;
    border-radius: 0 0 0 100%;
    border-top: none;
    border-right: none;
}

.cell-arc--bottom-left {
    bottom: 0;
    left: 0;
    border-radius: 0 100% 0 0;
    border-bottom: none;
    border-left: none;
}

/* Nested Rectangles */
.cell-nested-rects {
    position: absolute;
    top: 50%;
    right: 8%;
    transform: translateY(-50%);
    width: 100px;
    height: 100px;
    z-index: 1;
}

.nested-rect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid var(--color-brass);
}

.nested-rect--1 {
    width: 100%;
    height: 100%;
    opacity: 0.15;
}

.nested-rect--2 {
    width: 75%;
    height: 75%;
    opacity: 0.09;
}

.nested-rect--3 {
    width: 50%;
    height: 50%;
    opacity: 0.04;
}

.cell-nested-rects--light .nested-rect {
    border-color: var(--color-parchment);
}

/* ============================================================
   INTERSTITIAL BREATHERS
   ============================================================ */
.breather {
    width: 100%;
    height: clamp(20vh, 25vh, 30vh);
    background: linear-gradient(180deg, var(--color-umber) 0%, var(--color-walnut) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.breather--light {
    background: linear-gradient(180deg, var(--color-cream-alt) 0%, var(--color-cream) 100%);
}

/* Overlapping Circles Motif */
.breather-motif--circles {
    position: relative;
    width: 200px;
    height: 200px;
}

.breather-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--color-brass);
    opacity: 0.15;
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.breather-circle--1 {
    width: 160px;
    height: 160px;
    top: 20px;
    left: 0;
    animation-delay: 0s;
}

.breather-circle--2 {
    width: 160px;
    height: 160px;
    top: 20px;
    left: 60px;
    animation-delay: 1.3s;
}

.breather-circle--3 {
    width: 120px;
    height: 120px;
    top: 40px;
    left: 30px;
    animation-delay: 2.6s;
}

/* Tessellated Triangles Motif */
.breather-motif--triangles {
    position: relative;
    width: 240px;
    height: 120px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.breather-triangle {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 52px solid var(--color-copper);
    opacity: 0.10;
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.breather-triangle--1 { animation-delay: 0s; }
.breather-triangle--2 { animation-delay: 0.6s; transform: rotate(180deg); }
.breather-triangle--3 { animation-delay: 1.2s; }
.breather-triangle--4 { animation-delay: 1.8s; transform: rotate(180deg); }
.breather-triangle--5 { animation-delay: 2.4s; }
.breather-triangle--6 { animation-delay: 3.0s; transform: rotate(180deg); }

/* Diamond Motif */
.breather-motif--diamond {
    position: relative;
    width: 120px;
    height: 120px;
}

.breather-diamond {
    width: 100%;
    height: 100%;
    background-color: var(--color-brass);
    opacity: 0.10;
    transform: rotate(45deg);
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* ============================================================
   TERMINAL CHAMBER
   ============================================================ */
.terminal {
    position: relative;
    width: 100%;
    height: 80vh;
    background: linear-gradient(180deg, var(--color-walnut) 0%, #1A1409 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Override grain on terminal for heavier opacity */
.terminal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0.14;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    animation: grain 320ms steps(4) infinite;
}

.terminal-domain {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.01em;
    color: var(--color-parchment);
    opacity: 0.6;
    position: relative;
    z-index: 3;
    margin-top: 2rem;
}

/* Terminal Mandala */
.terminal-mandala {
    position: relative;
    width: clamp(200px, 40vw, 400px);
    height: clamp(200px, 40vw, 400px);
    z-index: 1;
}

/* Mandala Hexagons */
.mandala-hex {
    position: absolute;
    top: 50%;
    left: 50%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation: rotateSlow 90s linear infinite;
}

.mandala-hex--1 {
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background-color: var(--color-brass);
    opacity: 0.08;
    animation-duration: 120s;
}

.mandala-hex--2 {
    width: 75%;
    height: 75%;
    transform: translate(-50%, -50%);
    background-color: var(--color-bronze);
    opacity: 0.10;
    animation-duration: 90s;
    animation-direction: reverse;
}

.mandala-hex--3 {
    width: 50%;
    height: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--color-brass);
    opacity: 0.12;
    animation-duration: 60s;
}

.mandala-hex--4 {
    width: 25%;
    height: 25%;
    transform: translate(-50%, -50%);
    background-color: var(--color-amber);
    opacity: 0.15;
    animation-duration: 45s;
    animation-direction: reverse;
}

/* Mandala Triangles */
.mandala-tri {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 2;
}

.mandala-tri--1 {
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 70px solid var(--color-brass);
    opacity: 0.08;
    transform: translate(-50%, -120%);
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.mandala-tri--2 {
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-top: 70px solid var(--color-brass);
    opacity: 0.08;
    transform: translate(-50%, 50%);
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) 1s infinite;
}

.mandala-tri--3 {
    border-top: 40px solid transparent;
    border-bottom: 40px solid transparent;
    border-right: 70px solid var(--color-brass);
    opacity: 0.08;
    transform: translate(-150%, -50%);
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) 2s infinite;
}

.mandala-tri--4 {
    border-top: 40px solid transparent;
    border-bottom: 40px solid transparent;
    border-left: 70px solid var(--color-brass);
    opacity: 0.08;
    transform: translate(50%, -50%);
    animation: pulseSimple 4s cubic-bezier(0.45, 0, 0.55, 1) 3s infinite;
}

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

/* Tablet: 2 columns */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cell--span-2 {
        grid-column: span 2;
    }

    .foyer-title {
        margin-left: 0;
    }

    .foyer-subtitle {
        margin-left: 0;
    }

    .foyer {
        padding-left: 6%;
        padding-right: 6%;
    }

    .foyer-hexagon {
        left: 70%;
    }

    .foyer-nested-rect {
        left: 70%;
    }
}

/* Mobile: 1 column */
@media (max-width: 480px) {
    .grid-container {
        grid-template-columns: 1fr;
    }

    .grid-cell--span-2 {
        grid-column: span 1;
    }

    .foyer {
        padding-left: 5%;
        padding-right: 5%;
        align-items: center;
        text-align: center;
    }

    .foyer-title {
        margin-left: 0;
        font-size: clamp(2.8rem, 14vw, 5rem);
    }

    .foyer-subtitle {
        margin-left: 0;
    }

    .foyer-hexagon {
        left: 50%;
        width: 250px;
        height: 250px;
    }

    .foyer-nested-rect {
        display: none;
    }

    .cell-nested-rects {
        display: none;
    }

    .cell-hexagon--large {
        width: 100px;
        height: 100px;
    }

    .terminal-mandala {
        width: 200px;
        height: 200px;
    }

    /* Remove rotation on mobile for readability */
    .grid-cell--rotate-1.revealed,
    .grid-cell--rotate-2.revealed,
    .grid-cell--rotate-neg.revealed {
        transform: translateY(0) rotate(0deg);
    }
}
