/* Color Palette */
:root {
    --bg-primary: #1F1610;
    --bg-alt: #2A1F15;
    --surface-hex: #3A2D1F;
    --accent-terracotta: #C17A50;
    --accent-clay: #D4956A;
    --accent-gold: #D4A86E;
    --accent-deep: #8B5E3C;
    --text-primary: #F0E8DE;
    --text-secondary: #A89880;
    --glitch-flash: #E8C4A0;

    --hex-width: clamp(280px, 20vw, 360px);
    --hex-gap: clamp(8px, 1vw, 16px);
}

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

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
    font-weight: 400;
    overflow: hidden;
}

/* Viewport */
.viewport {
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
}

.viewport::-webkit-scrollbar {
    display: none;
}

/* Film Grain Overlay */
.film-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="grain"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="3" /></filter><rect width="100" height="100" fill="white" filter="url(%23grain)" /></svg>');
    background-size: 100px 100px;
    opacity: 0.03;
}

/* Vignette Overlay */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.35) 100%);
}

/* Progress Bar */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-terracotta), var(--accent-gold));
    z-index: 10000;
    width: 0%;
    transition: width 0.1s ease-out;
}

/* Honeycomb Grid */
.honeycomb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--hex-width), 1fr));
    grid-auto-rows: var(--hex-width);
    gap: var(--hex-gap);
    padding: clamp(20px, 5vh, 40px);
    width: 100%;
    height: auto;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Hexagon Base */
.hex {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: linear-gradient(135deg, var(--surface-hex), var(--bg-alt));
    border: 1px solid rgba(193, 122, 80, 0.15);
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    opacity: 0;
    transform: scale(0.85);
}

.hex.visible {
    opacity: 1;
    transform: scale(1);
}

.hex:hover {
    border-color: rgba(193, 122, 80, 0.5);
    box-shadow: 0 0 30px rgba(193, 122, 80, 0.2);
}

.hex-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

/* Hero Section */
.hex-hero {
    grid-column: span 2;
    grid-row: span 2;
    border: 2px solid var(--accent-gold);
    background: radial-gradient(ellipse at 40% 40%, rgba(212, 149, 106, 0.1), transparent);
    opacity: 1;
    transform: scale(1);
}

.hex-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    border: 2px solid var(--accent-gold);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    opacity: 0;
    animation: frame-draw 1.5s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}

@keyframes frame-draw {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.hero-title {
    font-family: 'Sora', system-ui, sans-serif;
    font-size: clamp(3rem, 7vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--accent-gold);
    text-transform: lowercase;
    text-align: center;
    position: relative;
    z-index: 10;
}

.hero-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
}

.hero-letter.reveal {
    animation: letter-reveal 0.2s ease-out forwards;
}

@keyframes letter-reveal {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Content Cells */
.hex-content-cell {
    background: linear-gradient(135deg, rgba(42, 31, 21, 0.8), rgba(58, 45, 31, 0.8));
}

.hex-content-cell h2 {
    font-family: 'Sora', system-ui, sans-serif;
    font-size: clamp(1.4rem, 2.8vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--accent-gold);
    margin-bottom: 0.75rem;
    text-align: center;
}

.hex-content-cell p {
    font-family: 'Work Sans', system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.72;
    color: var(--text-secondary);
    text-align: center;
}

/* 3D Render Cells */
.hex-render {
    background: linear-gradient(135deg, rgba(50, 35, 20, 0.9), rgba(30, 22, 16, 0.9));
    position: relative;
}

.render-3d {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Hexagonal Prism */
.render-prism {
    position: relative;
    width: 140px;
    height: 140px;
}

.render-prism::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: conic-gradient(
        from 0deg at 50% 50%,
        #D4956A 0deg,
        #D4A86E 120deg,
        #E8C4A0 180deg,
        #D4956A 240deg,
        #D4956A 360deg
    );
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    box-shadow:
        -10px 10px 25px rgba(0, 0, 0, 0.6),
        inset -5px -5px 15px rgba(0, 0, 0, 0.4);
}

.render-prism::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(35px);
    width: 120px;
    height: 120px;
    background: linear-gradient(to bottom, #A89880, #3A2D1F);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    opacity: 0.4;
}

/* Stacked Discs */
.render-discs {
    position: relative;
    width: 140px;
    height: 140px;
}

.render-discs::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 24px;
    background: radial-gradient(ellipse at 50% 30%, #E8C4A0, #D4956A);
    border-radius: 50%;
    box-shadow:
        0 -24px 0 -10px rgba(212, 149, 106, 0.85),
        0 -48px 0 -20px rgba(212, 168, 110, 0.65),
        0 24px 0 -10px rgba(168, 152, 128, 0.65),
        0 -18px 35px rgba(0, 0, 0, 0.6);
}

.render-discs::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110px;
    height: 110px;
    background: radial-gradient(circle at 40% 40%, transparent 25%, rgba(0, 0, 0, 0.35) 75%);
}

/* Twisted Spiral */
.render-spiral {
    position: relative;
    width: 120px;
    height: 140px;
}

.render-spiral::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 120px;
    background: conic-gradient(
        from 0deg,
        #D4956A 0deg,
        #D4A86E 50deg,
        #E8C4A0 100deg,
        #D4A86E 150deg,
        #D4956A 200deg,
        #A89880 250deg,
        #8B5E3C 300deg,
        #A89880 350deg,
        #D4956A 360deg
    );
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    box-shadow:
        inset -8px 0 15px rgba(0, 0, 0, 0.5),
        -12px 12px 30px rgba(0, 0, 0, 0.6);
}

.render-spiral::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 120px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.3));
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
}

/* Column */
.render-column {
    position: relative;
    width: 110px;
    height: 140px;
}

.render-column::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 110px;
    background: linear-gradient(90deg, #8B5E3C 0%, #D4956A 50%, #A89880 100%);
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    box-shadow:
        -12px 12px 25px rgba(0, 0, 0, 0.7),
        inset -6px 0 12px rgba(0, 0, 0, 0.4);
}

.render-column::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 110px;
    background: linear-gradient(270deg, transparent, rgba(0, 0, 0, 0.5));
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}

/* Dome */
.render-dome {
    position: relative;
    width: 140px;
    height: 140px;
}

.render-dome::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 35% 35%, rgba(232, 196, 160, 0.7), #D4956A);
    border-radius: 50%;
    box-shadow:
        inset -18px -18px 35px rgba(0, 0, 0, 0.6),
        -12px -12px 30px rgba(0, 0, 0, 0.6),
        18px 18px 45px rgba(0, 0, 0, 0.4);
}

.render-dome::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: conic-gradient(
        from 225deg at 35% 35%,
        rgba(232, 196, 160, 0.25) 0deg,
        transparent 100deg
    );
    border-radius: 50%;
}

/* Twisted Form */
.render-twisted {
    position: relative;
    width: 140px;
    height: 140px;
}

.render-twisted::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 130px;
    background: conic-gradient(
        from 45deg at 50% 50%,
        #E8C4A0 0deg,
        #D4A86E 60deg,
        #D4956A 120deg,
        #A89880 180deg,
        #8B5E3C 240deg,
        #D4956A 300deg,
        #E8C4A0 360deg
    );
    clip-path: polygon(30% 0%, 70% 0%, 100% 45%, 80% 100%, 20% 100%, 0% 45%);
    box-shadow:
        -8px 8px 20px rgba(0, 0, 0, 0.5),
        inset -6px -6px 12px rgba(0, 0, 0, 0.3);
}

.render-twisted::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 130px;
    background: radial-gradient(ellipse at 30% 30%, transparent 30%, rgba(0, 0, 0, 0.4) 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 45%, 80% 100%, 20% 100%, 0% 45%);
}

/* Accent Cells */
.hex-accent {
    background: linear-gradient(135deg, var(--accent-terracotta), var(--accent-deep));
}

.accent-icon {
    width: 60px;
    height: 60px;
    border: 2px solid var(--text-primary);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    animation: pulse-soft 3s ease-in-out infinite;
}

.accent-glyph {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--text-primary);
    animation: pulse-soft 3.5s ease-in-out infinite;
}

@keyframes pulse-soft {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Empty Breathing Cells */
.hex-empty {
    background: rgba(31, 22, 16, 0.3);
    border: 1px dashed rgba(193, 122, 80, 0.1);
}

/* Glitch Effect */
.hex.glitch-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(212, 149, 106, 0.3);
    clip-path: inset(0 0 100% 0);
    animation: glitch-slice 0.08s ease-out;
    z-index: 100;
}

.hex.glitch-active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(212, 149, 106, 0.2) 50%, transparent 100%);
    clip-path: inset(40% 0 55% 0);
    animation: glitch-displacement 0.08s ease-out;
    mix-blend-mode: screen;
    z-index: 100;
}

@keyframes glitch-slice {
    0% {
        clip-path: inset(40% 0 55% 0);
        transform: translateX(0);
    }
    50% {
        clip-path: inset(35% 0 60% 0);
        transform: translateX(5px);
    }
    100% {
        clip-path: inset(40% 0 55% 0);
        transform: translateX(0);
    }
}

@keyframes glitch-displacement {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(-6px);
        opacity: 0.8;
    }
    100% {
        transform: translateX(0);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .honeycomb-grid {
        grid-template-columns: repeat(auto-fit, minmax(clamp(240px, 25vw, 300px), 1fr));
        grid-auto-rows: clamp(240px, 25vw, 300px);
    }

    .hex-hero {
        grid-column: span 1;
        grid-row: span 1;
    }
}

@media (max-width: 768px) {
    .honeycomb-grid {
        grid-template-columns: repeat(auto-fit, minmax(clamp(180px, 35vw, 240px), 1fr));
        grid-auto-rows: clamp(180px, 35vw, 240px);
    }

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

    .hex-content-cell h2 {
        font-size: clamp(1rem, 2vw, 1.4rem);
    }

    .hex-content-cell p {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .honeycomb-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        padding: 10px;
        gap: 8px;
    }

    .hex {
        clip-path: none;
        border-radius: 12px;
    }

    .hex-frame {
        clip-path: none;
        border-radius: 12px;
    }

    .hex-hero {
        grid-column: span 1;
        grid-row: span auto;
    }

    .hero-title {
        font-size: clamp(1.5rem, 4vw, 2.2rem);
    }

    .hero-letter {
        display: inline;
    }

    .hex-content-cell h2 {
        font-size: 1rem;
    }

    .hex-content-cell p {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    .render-3d {
        transform: scale(0.8);
    }
}
