/* ============================================================================
   YONGZOON.NET - Surreal Infrastructure with Hexagonal-Honeycomb Grid
   Design Language: Retro-Futuristic Earth with Circuit-Organism Motifs
   ========================================================================== */

:root {
    /* Palette: Retro-Futuristic Earth */
    --bg-warm-basalt: #2a2520;
    --surface-fired-clay: #3d3530;
    --accent-aged-copper: #b87333;
    --accent-patina-teal: #5f9ea0;
    --text-bone-white: #f0e8dc;
    --text-sandstone: #a89882;
    --accent-oxidized-green: #2e8b57;
    --signal-warm-amber: #d4a043;

    /* Typography Scale */
    --font-display: 'Commissioner', sans-serif;
    --font-mono: 'Source Code Pro', monospace;

    /* Hex Grid Sizing */
    --hex-width: clamp(200px, 25vw, 320px);
    --hex-gap: 4px;

    /* Animation Timing */
    --transition-standard: 300ms ease;
    --transition-draw: 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================================================
   GLOBAL STYLES
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-warm-basalt);
    color: var(--text-bone-white);
    font-family: var(--font-display);
    font-weight: 300;
    line-height: 1.72;
    overflow-x: hidden;
}

/* ============================================================================
   TYPOGRAPHY
   ========================================================================== */

h1, h2, h3 {
    font-family: var(--font-display);
    letter-spacing: 0.04em;
}

h1 {
    font-size: clamp(2.5rem, 7vw, 5.5rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(1.3rem, 2.8vw, 2rem);
    font-weight: 700;
}

h3 {
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 600;
    color: var(--signal-warm-amber);
    margin-bottom: 0.5rem;
}

code, .mono {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.1vw, 0.9rem);
    letter-spacing: 0.02em;
    color: var(--accent-patina-teal);
}

body {
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    color: var(--text-bone-white);
}

.text-secondary {
    color: var(--text-sandstone);
}

/* ============================================================================
   HERO SECTION
   ========================================================================== */

.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(180deg, var(--bg-warm-basalt) 0%, var(--surface-fired-clay) 100%);
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.3) 100%);
    pointer-events: none;
}

.hero-hex {
    position: absolute;
    width: clamp(120px, 30vw, 300px);
    height: auto;
    z-index: 1;
}

/* Animate hex outline drawing */
.hex-outline {
    animation: drawHex 1s 0.3s ease-out forwards;
}

@keyframes drawHex {
    from {
        stroke-dashoffset: 600;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Circuit traces branching */
.circuit-branch {
    animation: drawTrace 0.8s 1.2s ease-out forwards;
}

@keyframes drawTrace {
    from {
        stroke-dashoffset: 100;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Circuit nodes appearing */
.circuit-node {
    animation: nodeAppear 0.4s 1.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes nodeAppear {
    from {
        r: 0;
        opacity: 0;
    }
    to {
        r: 5px;
        opacity: 1;
    }
}

.hero-content {
    position: absolute;
    text-align: center;
    z-index: 2;
    animation: fadeIn 0.6s 1.5s ease-out forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-title {
    display: flex;
    justify-content: center;
    gap: 0.05em;
    margin-bottom: 0.5rem;
    color: var(--text-bone-white);
}

.letter {
    display: inline-block;
    opacity: 0;
    animation: letterFade 0.4s ease-out forwards;
    animation-delay: calc(0.05s + var(--letter-index) * 50ms);
}

@keyframes letterFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-domain {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--accent-patina-teal);
    margin-top: 0.5rem;
    letter-spacing: 0.08em;
    animation: fadeIn 0.6s 1.8s ease-out forwards;
    opacity: 0;
}

/* ============================================================================
   HEXAGONAL GRID SYSTEM
   ========================================================================== */

.hex-grid {
    display: grid;
    grid-template-columns: repeat(3, var(--hex-width));
    gap: var(--hex-gap);
    padding: 8vh clamp(1rem, 5vw, 3rem);
    background: var(--bg-warm-basalt);
    justify-content: center;
    position: relative;
}

/* Hex cell base styles */
.hex-cell {
    aspect-ratio: 1.15;
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--surface-fired-clay);
    border: 4px solid var(--accent-aged-copper);
    border-opacity: 0.3;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: opacity, transform;
}

.hex-cell.active {
    opacity: 1;
    transform: scale(1);
    border-color: var(--accent-aged-copper);
}

.hex-cell.active::after {
    content: '';
    position: absolute;
    inset: 4px;
    box-shadow: inset 0 0 20px rgba(184, 115, 51, 0.15);
    pointer-events: none;
}

/* Odd rows (2, 4) are offset */
.hex-r2-c1, .hex-r2-c2, .hex-r2-c3,
.hex-r4-c1, .hex-r4-c2, .hex-r4-c3 {
    transform: translateX(calc(var(--hex-width) / 2 + var(--hex-gap) / 2));
}

/* Surreal break cells are larger */
.hex-surreal {
    grid-column: span 1.5;
    aspect-ratio: 1.3;
    z-index: 10;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.2));
}

.hex-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: clamp(0.8rem, 3vw, 1.5rem);
}

.hex-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}

.hex-content h3 {
    margin: 0;
}

.hex-content p {
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    color: var(--text-sandstone);
    line-height: 1.5;
}

.hex-circuit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 50%;
    opacity: 0.4;
    pointer-events: none;
}

/* Circuit motifs animation */
.trace {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawCircuit 0.8s ease-out forwards;
}

.node {
    r: 0;
    animation: nodeScale 0.2s 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.component {
    opacity: 0;
    animation: componentFade 0.4s 0.7s ease-out forwards;
}

@keyframes drawCircuit {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes nodeScale {
    from {
        r: 0;
    }
    to {
        r: var(--node-size, 2.5px);
    }
}

@keyframes componentFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Surreal illustration styles */
.surreal-inner {
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.surreal-illustration {
    width: 80%;
    height: 80%;
}

#circuitTree {
    animation: treeGrow 1.2s ease-out forwards;
}

@keyframes treeGrow {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.strata {
    animation: strataFade 0.8s ease-out forwards;
}

@keyframes strataFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================================================
   INTERSECTION OBSERVER - Fade Reveal Cascade
   ========================================================================== */

.hex-cell {
    opacity: 0;
    transform: scale(0.85);
}

.hex-cell.reveal {
    animation: revealCell 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes revealCell {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   FOOTER SECTION
   ========================================================================== */

.footer-mirror {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 4rem 2rem;
    background: linear-gradient(180deg, var(--bg-warm-basalt) 0%, var(--surface-fired-clay) 100%);
    text-align: center;
}

.closing-hex {
    width: clamp(80px, 20vw, 180px);
    height: auto;
}

.footer-text {
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--text-sandstone);
    font-weight: 300;
    letter-spacing: 0.04em;
    max-width: 600px;
}

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

@media (max-width: 1024px) {
    .hex-grid {
        grid-template-columns: repeat(2, var(--hex-width));
    }

    .hex-r2-c1, .hex-r2-c2, .hex-r2-c3,
    .hex-r4-c1, .hex-r4-c2, .hex-r4-c3 {
        transform: translateX(calc(var(--hex-width) / 2 + var(--hex-gap) / 2));
    }
}

@media (max-width: 768px) {
    .hex-grid {
        grid-template-columns: 1fr;
        padding: 4vh 1rem;
    }

    .hex-r2-c1, .hex-r2-c2, .hex-r2-c3,
    .hex-r4-c1, .hex-r4-c2, .hex-r4-c3 {
        transform: none;
        grid-column: auto;
    }

    .hex-surreal {
        grid-column: auto;
    }

    .hex-content p {
        font-size: 0.75rem;
    }
}

/* ============================================================================
   ACCESSIBILITY & PERFORMANCE
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Smooth scrolling support */
@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}

/* GPU acceleration for critical elements */
.hex-cell,
.hero-title,
.letter,
.trace,
.node {
    will-change: transform, opacity;
}
