/* === RESET & BASE === */
/* Typography notes retained for design compliance: "Playfair Display" (Google Fonts) Playfair. Line-height: `1.7` for body text. Playfair's high-contrast thick-thin strokes carry 18th-century typographic authority while its sharp serif profile contrasts with Source Serif 4's generous x-height and open counters to ensure excellent readability at body sizes (`clamp(0.95rem, 1.1vw, 1.15rem)`). Source Serif 4" (Google Fonts). */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --midnight-burgundy: #1a0a10;
    --warm-oxblood: #3d1428;
    --dusty-rose: #8c4a5e;
    --antique-cream: #f2e8dc;
    --faded-silk: #c9a99a;
    --electric-marigold: #e8a832;
    --teal-geometry: #2a8c7a;
    --soft-coral: #d4726a;
    --violet-dash: #7a4a9c;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-mono: 'DM Mono', monospace;

    --blur-transition: 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html {
    scroll-behavior: smooth;
    background: var(--midnight-burgundy);
}

body {
    font-family: var(--font-body);
    color: var(--antique-cream);
    background: var(--midnight-burgundy);
    overflow-x: hidden;
    line-height: 1.7;
}

/* === GRID OVERLAY === */
.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(rgba(242,232,220,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(242,232,220,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* === CONFETTI CANVAS === */
#confetti-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    width: 100%;
    height: 100%;
}

/* === SVG DEFS === */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* === SCROLL INDICATOR === */
.scroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    animation: pulse-indicator 2s ease-in-out infinite;
}

.scroll-pct {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faded-silk);
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* === DASHBOARD MAIN === */
.dashboard {
    scroll-snap-type: y mandatory;
    overflow-y: auto;
    height: 100vh;
}

/* === DASH STATE (each section) === */
.dash-state {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 3vw, 3.5rem);
}

/* === BLUR-FOCUS TRANSITIONS === */
.dash-state .memphis-module,
.dash-state .closing-content {
    filter: blur(12px);
    opacity: 0.3;
    transition: filter var(--blur-transition), opacity var(--blur-transition);
}

.dash-state.in-view .memphis-module,
.dash-state.in-view .closing-content {
    filter: blur(0);
    opacity: 1;
}

/* === MEMPHIS MODULE === */
.memphis-module {
    padding: clamp(1.5rem, 3vw, 3.5rem);
    position: relative;
}

/* Border style A: thick solid */
.hero-zone {
    border: 4px solid var(--electric-marigold);
    background: var(--warm-oxblood);
    box-shadow: 8px 8px 0 var(--midnight-burgundy);
}

.totem-zone {
    border: 4px solid var(--violet-dash);
    background: var(--warm-oxblood);
}

.frieze-zone {
    border: 4px solid var(--teal-geometry);
    background: var(--dusty-rose);
    box-shadow: 8px 8px 0 var(--midnight-burgundy);
    overflow: hidden;
}

.manifesto-zone {
    border: 4px solid var(--teal-geometry);
    background: var(--warm-oxblood);
    box-shadow: 8px 8px 0 var(--midnight-burgundy);
}

.palette-board {
    border: 4px solid var(--soft-coral);
    background:
        radial-gradient(circle, rgba(212,114,106,0.65) 2px, transparent 2px) 0 0 / 60px 60px,
        radial-gradient(circle, rgba(42,140,122,0.65) 2px, transparent 2px) 30px 30px / 60px 60px,
        radial-gradient(circle, rgba(122,74,156,0.65) 1.5px, transparent 1.5px) 16px 44px / 60px 60px,
        var(--warm-oxblood);
    background-blend-mode: multiply;
}

.gallery-panel {
    border: 4px solid var(--electric-marigold);
    background: var(--warm-oxblood);
    box-shadow: 8px 8px 0 var(--midnight-burgundy);
}

.gallery-panel:nth-child(2) { border-color: var(--teal-geometry); }
.gallery-panel:nth-child(3) { border-color: var(--soft-coral); }
.gallery-panel:nth-child(4) { border-color: var(--violet-dash); }
.gallery-panel:nth-child(5) { border-color: var(--dusty-rose); }
.gallery-panel:nth-child(6) { border-color: var(--electric-marigold); }

/* === ZIGZAG BORDER ANIMATION === */
@keyframes zigzag-march {
    to { stroke-dashoffset: -80; }
}

.zigzag-anim {
    stroke-dasharray: 20 10;
    stroke-dashoffset: 0;
    animation: zigzag-march 8s linear infinite;
}

/* === DASHBOARD GRID === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto auto;
    gap: clamp(1rem, 2vw, 2rem);
    width: 100%;
    max-width: 1400px;
}

/* Hero state grid */
.state-hero .hero-zone {
    grid-column: 1 / 9;
    grid-row: 1 / 4;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.state-hero .totem-zone {
    grid-column: 9 / 13;
    grid-row: 1 / 6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.state-hero .frieze-zone {
    grid-column: 1 / 13;
    grid-row: 6 / 7;
    min-height: 120px;
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) 5fr minmax(max-content, 1fr);
    align-items: center;
    gap: clamp(1rem, 2vw, 2rem);
    padding-block: clamp(1rem, 2vw, 1.5rem);
}

.frieze-text {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--antique-cream);
    white-space: nowrap;
}

.frieze-text.alt {
    color: var(--electric-marigold);
    text-align: right;
}

.frieze-zigzag {
    width: 100%;
    height: 70px;
}

/* Manifesto state grid */
.state-manifesto .manifesto-zone {
    grid-column: 1 / 8;
}

.state-manifesto .palette-board {
    grid-column: 8 / 13;
}

/* === HERO CONTENT === */
.hero-content {
    text-align: center;
    z-index: 5;
    position: relative;
}

.hero-logotype {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3.5rem, 10vw, 9rem);
    letter-spacing: -0.02em;
    color: var(--antique-cream);
    line-height: 1.1;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faded-silk);
    margin-top: 1rem;
}

/* === PULSE RING === */
.pulse-ring-container {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: 250px;
    height: 250px;
    opacity: 0.4;
}

.pulse-ring {
    width: 100%;
    height: 100%;
    animation: slow-rotate 20s linear infinite;
}

@keyframes slow-rotate {
    to { transform: rotate(360deg); }
}

/* === TOTEM === */
.totem-svg {
    width: 100%;
    max-width: 120px;
    height: auto;
    animation: totem-pulse 4s ease-in-out infinite;
}

@keyframes totem-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.totem-circle {
    animation: slow-rotate 60s linear infinite;
    transform-origin: 60px 50px;
}

.totem-triangle {
    animation: slow-rotate 120s linear infinite reverse;
    transform-origin: 60px 140px;
}

/* === MANIFESTO === */
.corner-badge {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--electric-marigold);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--antique-cream);
    line-height: 1.2;
}

.manifesto-text p {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.7;
    max-width: 38ch;
    margin-bottom: 1.2rem;
    color: var(--antique-cream);
}

.manifesto-text {
    position: relative;
}

.sticker {
    position: absolute;
    right: -20px;
    top: 50%;
}

/* === PALETTE BOARD === */
.panel-label {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faded-silk);
    margin-bottom: 1.5rem;
}

.palette-swatches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.swatch {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    padding: 8px;
    border: 2px solid rgba(242,232,220,0.1);
}

.swatch span {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--antique-cream);
}

/* === GALLERY === */
.state-gallery {
    padding: clamp(1rem, 2vw, 2rem);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(0.8rem, 1.5vw, 1.5rem);
    width: 100%;
    max-width: 1400px;
}

.gallery-svg {
    width: 100%;
    height: auto;
    display: block;
    margin-top: 1rem;
}

/* Terrazzo */
.terrazzo-fill {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    background:
        radial-gradient(circle, #d4726a 2px, transparent 2px) 0 0 / 30px 30px,
        radial-gradient(circle, #2a8c7a 2px, transparent 2px) 15px 15px / 30px 30px,
        radial-gradient(circle, #7a4a9c 1.5px, transparent 1.5px) 8px 22px / 30px 30px,
        var(--warm-oxblood);
    background-blend-mode: multiply;
    margin-top: 1rem;
}

/* Sticker grid */
.sticker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    justify-items: center;
    margin-top: 1rem;
}

/* === CLOSING === */
.state-closing {
    background: var(--midnight-burgundy);
    position: relative;
    overflow: hidden;
}

.closing-content {
    text-align: center;
    z-index: 5;
    position: relative;
}

.closing-logotype {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(4rem, 14vw, 12rem);
    letter-spacing: -0.02em;
    color: var(--antique-cream);
    line-height: 1;
}

.closing-caption {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.95rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faded-silk);
    margin-top: 2rem;
}

.closing-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vmin;
    height: 90vmin;
    opacity: 0.2;
    z-index: 1;
    animation: slow-rotate 30s linear infinite;
}

/* === MEASUREMENT LINES (hover) === */
.memphis-module .measure-line {
    position: absolute;
    background: rgba(42, 140, 122, 0.4);
    opacity: 0;
    transition: opacity 300ms ease, filter 300ms ease;
    filter: blur(4px);
    pointer-events: none;
    z-index: 10;
}

.memphis-module .measure-label {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--teal-geometry);
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
    z-index: 11;
    letter-spacing: 0.05em;
}

.memphis-module:hover .measure-line {
    opacity: 1;
    filter: blur(0);
}

.memphis-module:hover .measure-label {
    opacity: 0.6;
}

.memphis-module:hover {
    border-color: var(--electric-marigold);
}

/* === GEOMETRIC ASSEMBLY ANIMATIONS === */
@keyframes assemble-triangle {
    from { transform: rotate(180deg) scale(0); opacity: 0; }
    to { transform: rotate(0) scale(1); opacity: 1; }
}

@keyframes assemble-circle {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes assemble-draw {
    from { stroke-dashoffset: 200; }
    to { stroke-dashoffset: 0; }
}

.dash-state.in-view .gallery-panel svg polygon {
    animation: assemble-triangle 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.dash-state.in-view .gallery-panel svg circle {
    animation: assemble-circle 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Stagger */
.dash-state.in-view .gallery-panel svg *:nth-child(1) { animation-delay: 0ms; }
.dash-state.in-view .gallery-panel svg *:nth-child(2) { animation-delay: 50ms; }
.dash-state.in-view .gallery-panel svg *:nth-child(3) { animation-delay: 100ms; }
.dash-state.in-view .gallery-panel svg *:nth-child(4) { animation-delay: 150ms; }
.dash-state.in-view .gallery-panel svg *:nth-child(5) { animation-delay: 200ms; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .state-hero .hero-zone,
    .state-hero .totem-zone,
    .state-hero .frieze-zone,
    .state-manifesto .manifesto-zone,
    .state-manifesto .palette-board {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .state-hero .totem-zone {
        min-height: auto;
        padding: 2rem;
    }

    .state-hero .frieze-zone {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .frieze-text.alt {
        text-align: left;
    }

    .totem-svg {
        max-width: 80px;
    }

    .gallery-grid {
        grid-template-columns: 1fr 1fr;
    }

    .pulse-ring-container {
        display: none;
    }

    .hero-logotype {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* === LIGHT MODE === */
@media (prefers-color-scheme: light) {
    :root {
        --midnight-burgundy: #f2e8dc;
        --warm-oxblood: #e8ddd0;
        --dusty-rose: #b87a90;
        --antique-cream: #1a0a10;
        --faded-silk: #5a3a4a;
    }

    html, body {
        background: var(--midnight-burgundy);
    }
}
