/* =============================================
   penclos.com - Computational Palace
   ============================================= */

:root {
    /* Foundation */
    --obsidian-void: #0B0A14;
    --midnight-amethyst: #1A1432;
    /* Gradients */
    --imperial-violet: #4A1A8A;
    --molten-orchid: #8B2FC6;
    --liquid-gold: #D4A017;
    /* Accents */
    --celestial-amber: #F5C542;
    --rose-quartz: #C76E8A;
    /* Text */
    --pale-platinum: #E8E4F0;
    --faded-amethyst: #9B8FB8;
    /* Gradients */
    --grad-primary: linear-gradient(135deg, #4A1A8A 0%, #8B2FC6 40%, #D4A017 100%);
    --grad-subtle: linear-gradient(160deg, #1A1432 0%, #2A1E4A 100%);
    --grad-accent: linear-gradient(90deg, #C76E8A 0%, #F5C542 100%);
    /* Spacing */
    --hex-gap: 24px;
    /* Hex clip path */
    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

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

html {
    scroll-behavior: smooth;
    background: var(--obsidian-void);
}

body {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--pale-platinum);
    background: var(--obsidian-void);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =============================================
   Background Hexagonal Pattern
   ============================================= */

.hex-bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image:
        linear-gradient(30deg, var(--faded-amethyst) 12%, transparent 12.5%, transparent 87%, var(--faded-amethyst) 87.5%, var(--faded-amethyst)),
        linear-gradient(150deg, var(--faded-amethyst) 12%, transparent 12.5%, transparent 87%, var(--faded-amethyst) 87.5%, var(--faded-amethyst)),
        linear-gradient(30deg, var(--faded-amethyst) 12%, transparent 12.5%, transparent 87%, var(--faded-amethyst) 87.5%, var(--faded-amethyst)),
        linear-gradient(150deg, var(--faded-amethyst) 12%, transparent 12.5%, transparent 87%, var(--faded-amethyst) 87.5%, var(--faded-amethyst)),
        linear-gradient(60deg, var(--faded-amethyst) 25%, transparent 25.5%, transparent 75%, var(--faded-amethyst) 75%),
        linear-gradient(60deg, var(--faded-amethyst) 25%, transparent 25.5%, transparent 75%, var(--faded-amethyst) 75%);
    background-size: 80px 140px;
    background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
}

/* =============================================
   Chamber Navigation
   ============================================= */

.chamber-nav {
    position: fixed;
    bottom: 32px;
    left: 32px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-hex {
    width: 28px;
    height: 32px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.nav-hex:hover {
    transform: scale(1.2);
}

.nav-hex-svg {
    width: 100%;
    height: 100%;
}

.nav-hex-fill {
    fill: transparent;
    transition: fill 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-hex.active .nav-hex-fill {
    fill: url(#primaryGrad);
    opacity: 0.8;
}

/* =============================================
   Chambers (General)
   ============================================= */

.chamber {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chamber-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    transition: background 1s ease;
}

.chamber-1 .chamber-bg {
    background: var(--obsidian-void);
}

.chamber-2 .chamber-bg {
    background: var(--grad-subtle);
}

.chamber-3 .chamber-bg {
    background: linear-gradient(180deg, #1A1432 0%, #0B0A14 100%);
}

.chamber-4 .chamber-bg {
    background: var(--obsidian-void);
}

.chamber-5 .chamber-bg {
    background: linear-gradient(180deg, #0B0A14 0%, #1A1432 50%, #0B0A14 100%);
}

.chamber-6 .chamber-bg {
    background: radial-gradient(ellipse at center, #1A1432 0%, #0B0A14 70%);
}

.chamber-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pale-platinum);
    margin-bottom: 24px;
    line-height: 1.3;
}

.chamber-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--faded-amethyst);
    margin-bottom: 16px;
}

.chamber-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 2;
}

/* =============================================
   Chamber 1: Hero
   ============================================= */

.hero-hex-container {
    position: relative;
    width: 80vmin;
    height: 80vmin;
    max-width: 700px;
    max-height: 700px;
    z-index: 1;
}

.hero-hex {
    position: absolute;
    inset: 0;
    clip-path: var(--hex-clip);
    background: var(--grad-primary);
    padding: 3px;
    animation: heroGradientShift 12s ease-in-out infinite;
}

.hero-hex-inner {
    width: 100%;
    height: 100%;
    clip-path: var(--hex-clip);
    background: var(--midnight-amethyst);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-gradient-fill {
    position: absolute;
    inset: 0;
    background: var(--grad-primary);
    opacity: 0.15;
    animation: heroGradientShift 12s ease-in-out infinite;
}

@keyframes heroGradientShift {
    0%, 100% {
        background: linear-gradient(135deg, #4A1A8A 0%, #8B2FC6 40%, #D4A017 100%);
    }
    50% {
        background: linear-gradient(315deg, #D4A017 0%, #8B2FC6 60%, #4A1A8A 100%);
    }
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 5.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pale-platinum);
    position: relative;
    z-index: 2;
    text-shadow: 0 0 60px rgba(139, 47, 198, 0.4), 0 0 120px rgba(74, 26, 138, 0.2);
}

/* Satellite Hexagons */
.satellite-hex {
    position: absolute;
    width: 80px;
    height: 92px;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chamber-1.in-view .satellite-hex {
    opacity: 1;
}

.satellite-svg {
    width: 100%;
    height: 100%;
}

.satellite-1 { top: -5%; right: -8%; animation: satelliteFloat 8s ease-in-out infinite; }
.satellite-2 { top: 15%; left: -10%; animation: satelliteFloat 9s ease-in-out 1s infinite; }
.satellite-3 { bottom: 5%; right: -5%; animation: satelliteFloat 7s ease-in-out 2s infinite; }
.satellite-4 { bottom: -5%; left: -3%; animation: satelliteFloat 10s ease-in-out 0.5s infinite; }

@keyframes satelliteFloat {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(5px, -8px); }
    50% { transform: translate(-3px, -12px); }
    75% { transform: translate(8px, -4px); }
}

/* Hex Border Draw Animation */
.hex-border-draw {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.in-view .hex-border-draw {
    stroke-dashoffset: 0;
}

/* =============================================
   Chamber 2: Honeycomb Grid
   ============================================= */

.honeycomb-grid {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
}

.honeycomb-row {
    display: flex;
    gap: var(--hex-gap);
    justify-content: center;
}

.honeycomb-row-offset {
    margin-left: calc(75px + var(--hex-gap) / 2);
}

.grid-hex {
    width: 150px;
    height: 173px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chamber-2.in-view .grid-hex {
    opacity: 1;
    transform: scale(1);
}

.chamber-2.in-view .honeycomb-row:nth-child(1) .grid-hex:nth-child(1) { transition-delay: 0.05s; }
.chamber-2.in-view .honeycomb-row:nth-child(1) .grid-hex:nth-child(2) { transition-delay: 0.1s; }
.chamber-2.in-view .honeycomb-row:nth-child(1) .grid-hex:nth-child(3) { transition-delay: 0.15s; }
.chamber-2.in-view .honeycomb-row:nth-child(2) .grid-hex:nth-child(1) { transition-delay: 0.2s; }
.chamber-2.in-view .honeycomb-row:nth-child(2) .grid-hex:nth-child(2) { transition-delay: 0.25s; }
.chamber-2.in-view .honeycomb-row:nth-child(2) .grid-hex:nth-child(3) { transition-delay: 0.3s; }
.chamber-2.in-view .honeycomb-row:nth-child(3) .grid-hex:nth-child(1) { transition-delay: 0.35s; }
.chamber-2.in-view .honeycomb-row:nth-child(3) .grid-hex:nth-child(2) { transition-delay: 0.4s; }
.chamber-2.in-view .honeycomb-row:nth-child(3) .grid-hex:nth-child(3) { transition-delay: 0.45s; }

.grid-hex-clip {
    width: 150px;
    height: 150px;
    clip-path: var(--hex-clip);
    background: var(--grad-primary);
    padding: 2px;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.grid-hex:hover .grid-hex-clip {
    transform: scale(1.05);
    border-radius: 8px;
    clip-path: polygon(50% 2%, 98% 26%, 98% 74%, 50% 98%, 2% 74%, 2% 26%);
}

.grid-hex-clip > .waveform-svg {
    width: 100%;
    height: 100%;
    clip-path: var(--hex-clip);
    background: var(--midnight-amethyst);
    display: block;
}

.hex-label {
    font-family: 'Fira Code', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--faded-amethyst);
    font-variant-ligatures: none;
    margin-top: 8px;
}

/* =============================================
   Chamber 3: Split Composition
   ============================================= */

.split-layout {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    max-width: 1200px;
    min-height: 80vh;
    padding: 60px 40px;
    gap: 40px;
    align-items: center;
}

.split-left {
    flex: 0 0 58%;
}

.split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.text-hex-frame {
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--grad-primary);
    padding: 2px;
}

.text-hex-border {
    display: none;
}

.text-hex-content {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--midnight-amethyst);
    padding: 80px 60px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pulse-border {
    animation: pulseBorder 3s ease-in-out infinite;
}

@keyframes pulseBorder {
    0%, 100% { stroke-opacity: 0.6; }
    50% { stroke-opacity: 1; }
}

.stacked-hex {
    width: 120px;
    height: 138px;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chamber-3.in-view .stacked-hex-1 { opacity: 1; transform: translateX(0); transition-delay: 0.1s; }
.chamber-3.in-view .stacked-hex-2 { opacity: 1; transform: translateX(0); transition-delay: 0.3s; }
.chamber-3.in-view .stacked-hex-3 { opacity: 1; transform: translateX(0); transition-delay: 0.5s; }

.stacked-svg {
    width: 100%;
    height: 100%;
}

/* =============================================
   Chamber 4: Layered Depth
   ============================================= */

.depth-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
}

.depth-layer {
    position: absolute;
    inset: 0;
}

.depth-bg { opacity: 0.2; z-index: 1; }
.depth-mid { opacity: 0.5; z-index: 2; }
.depth-fg { opacity: 1; z-index: 3; }

.depth-hex {
    position: absolute;
    clip-path: var(--hex-clip);
    background: var(--grad-primary);
}

.depth-hex-lg {
    width: 300px;
    height: 346px;
}

.depth-hex-md {
    width: 180px;
    height: 208px;
}

.depth-hex-sm {
    width: 100px;
    height: 115px;
    background: var(--grad-accent);
}

.depth-text {
    position: absolute;
    z-index: 10;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    max-width: 600px;
    padding: 40px;
}

.depth-text-sub {
    max-width: 480px;
    margin: 0 auto;
}

/* =============================================
   Chamber 5: Simplicity
   ============================================= */

.simplicity-container {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
}

.rotating-hex {
    position: absolute;
    width: min(60vw, 500px);
    height: auto;
    animation: rotateHex 60s linear infinite;
}

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

.simplicity-text {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px;
}

.statement {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.4;
    color: var(--pale-platinum);
    text-shadow: 0 0 80px rgba(139, 47, 198, 0.3);
}

/* =============================================
   Chamber 6: Finale
   ============================================= */

.finale-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finale-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.finale-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    opacity: 0;
}

.finale-center-point {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--celestial-amber);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 30px var(--celestial-amber), 0 0 60px var(--molten-orchid);
}

.chamber-6.in-view .finale-center-point {
    transform: translate(-50%, -50%) scale(1);
}

.finale-message {
    position: relative;
    z-index: 5;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease 1s, transform 1.2s ease 1s;
}

.chamber-6.in-view .finale-message {
    opacity: 1;
    transform: translateY(0);
}

.closing-text {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.6;
    color: var(--pale-platinum);
    margin-bottom: 32px;
}

.closing-label {
    font-family: 'Fira Code', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--faded-amethyst);
    font-variant-ligatures: none;
}

/* =============================================
   Morph Animations
   ============================================= */

@keyframes gradientRotate {
    0% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(15deg); }
    100% { filter: hue-rotate(0deg); }
}

/* Gradient fill morph - bleeds inward from edges */
@keyframes fillMorphIn {
    0% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
        opacity: 0;
    }
    50% {
        clip-path: polygon(50% 10%, 90% 30%, 90% 70%, 50% 90%, 10% 70%, 10% 30%);
        opacity: 0.5;
    }
    100% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
        opacity: 1;
    }
}

/* Chamber background gradient rotation */
.chamber-2 .chamber-bg,
.chamber-4 .chamber-bg {
    animation: bgGradientShift 20s linear infinite;
}

@keyframes bgGradientShift {
    0% { background: linear-gradient(160deg, #1A1432 0%, #2A1E4A 100%); }
    25% { background: linear-gradient(200deg, #1A1432 0%, #2A1E4A 100%); }
    50% { background: linear-gradient(240deg, #1A1432 0%, #2A1E4A 100%); }
    75% { background: linear-gradient(300deg, #1A1432 0%, #2A1E4A 100%); }
    100% { background: linear-gradient(160deg, #1A1432 0%, #2A1E4A 100%); }
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 768px) {
    .honeycomb-row {
        flex-direction: column;
        align-items: center;
    }

    .honeycomb-row-offset {
        margin-left: 0;
    }

    .grid-hex {
        width: 120px;
        height: 139px;
    }

    .grid-hex-clip {
        width: 120px;
        height: 120px;
    }

    .split-layout {
        flex-direction: column;
        padding: 40px 20px;
    }

    .split-left {
        flex: none;
        width: 100%;
    }

    .text-hex-content {
        padding: 60px 40px;
    }

    .split-right {
        flex-direction: row;
        gap: 16px;
        justify-content: center;
    }

    .stacked-hex {
        width: 80px;
        height: 92px;
    }

    .depth-hex-lg {
        width: 180px;
        height: 208px;
    }

    .depth-hex-md {
        width: 120px;
        height: 138px;
    }

    .depth-hex-sm {
        width: 70px;
        height: 81px;
    }

    .satellite-hex {
        width: 50px;
        height: 58px;
    }

    .hero-hex-container {
        width: 70vmin;
        height: 70vmin;
    }

    .chamber-nav {
        bottom: 16px;
        left: 16px;
    }

    .nav-hex {
        width: 22px;
        height: 26px;
    }
}

@media (max-width: 480px) {
    .grid-hex-clip,
    .grid-hex {
        clip-path: none;
        border-radius: 12px;
    }

    .grid-hex-clip > .waveform-svg {
        clip-path: none;
        border-radius: 12px;
    }

    .grid-hex {
        width: 100px;
        height: 120px;
    }

    .grid-hex-clip {
        width: 100px;
        height: 100px;
    }

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

    .text-hex-content {
        clip-path: none;
        border-radius: 16px;
        padding: 40px 24px;
        min-height: auto;
    }

    .hero-hex,
    .hero-hex-inner {
        clip-path: none;
        border-radius: 20px;
    }

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