/* ============================================================
   layer-2.quest — Hexagonal Honeycomb Narrative
   Scandinavian warmth + blockchain protocol documentation
   ============================================================ */

:root {
    --bg: #FBF4EC;
    --surface: #F5DCC3;
    --accent: #E8915A;
    --accent2: #D4885C;
    --deep: #8B4E2A;
    --text: #3D2E24;
    --text-muted: #9A8576;
    --lavender: #C4A6B8;
    --grid-line: #EDDCCC;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --spring: cubic-bezier(0.2, 0.8, 0.3, 1.0);
    --spring-overshoot: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ============================================================
   Canvas Hex Grid Background (Layer 0 atmospheric)
   ============================================================ */

#hex-grid-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
    transition: opacity 1.5s ease;
}

body.layer-active-2 #hex-grid-canvas {
    opacity: 0.45;
}

/* ============================================================
   Hero Section
   ============================================================ */

.section-hero {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-diagram {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 320px;
    height: 280px;
    pointer-events: none;
}

.hero-diagram-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transition: transform 0.1s linear;
}

.hero-diagram-layer--0 {
    transform: translate(-50%, -50%);
    z-index: 1;
}

.hero-diagram-layer--1 {
    transform: translate(-50%, -50%);
    z-index: 2;
}

.hero-diagram-layer--2 {
    transform: translate(-50%, -50%);
    z-index: 3;
}

.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    opacity: 0;
    animation: heroFadeIn 1.2s ease-out 0.3s forwards;
}

@keyframes heroFadeIn {
    0% { opacity: 0; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.8rem, 8vw, 6rem);
    color: var(--deep);
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.scroll-chevron {
    position: absolute;
    bottom: 3rem;
    z-index: 5;
    opacity: 0;
    animation: chevronAppear 1s ease-out 1.5s forwards, chevronPulse 2.5s ease-in-out 2.5s infinite;
}

@keyframes chevronAppear {
    0% { opacity: 0; transform: translateY(-8px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.5; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(8px); }
}

/* ============================================================
   Section Base
   ============================================================ */

.section {
    position: relative;
    z-index: 1;
}

.section-layer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 120px 2rem 80px;
}

/* ============================================================
   Hex Module System
   ============================================================ */

.hex-cluster {
    text-align: center;
    margin-bottom: 3.5rem;
}

.hex-module {
    position: relative;
}

.hex-module--header {
    display: inline-block;
    padding: 2.5rem;
}

.hex-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--deep);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.section-sub {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--text-muted);
    line-height: 1.6;
}

/* Content Grid */
.hex-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 960px;
    margin: 0 auto;
}

.hex-module--content {
    background: var(--surface);
    padding: 2rem 1.75rem;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 340px;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(212, 136, 92, 0.08);
    transition: transform 0.4s var(--ease-smooth), box-shadow 0.4s var(--ease-smooth);
}

.hex-module--content::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    transition: background 0.4s ease;
    z-index: -1;
}

/* Layer 1 modules - slightly elevated */
.section-layer--elevated .hex-module--content {
    transform: scale(1.02);
    box-shadow: 0 12px 32px rgba(212, 136, 92, 0.1);
}

/* Layer 2 modules - maximum elevation */
.hex-module--elevated {
    transform: scale(1.05);
    box-shadow: 0 16px 48px rgba(212, 136, 92, 0.12);
}

/* Focus state on scroll (Layer 2 focus) */
.hex-module--focused {
    transform: scale(1.08);
    box-shadow: 0 20px 56px rgba(232, 145, 90, 0.15);
}

.hex-module--focused::before {
    background: rgba(232, 145, 90, 0.03);
}

.hex-module-icon {
    margin-bottom: 1rem;
    opacity: 0.9;
}

.hex-module-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.1rem, 1.8vw, 1.35rem);
    color: var(--deep);
    letter-spacing: 0.02em;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.hex-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.88rem, 1.1vw, 1rem);
    line-height: 1.72;
    color: var(--text);
    letter-spacing: 0.005em;
    max-width: 280px;
}

/* Monospace technical labels */
.mono-label {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85em;
    color: var(--accent2);
    background: rgba(212, 136, 92, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

/* Layer 2 specific accents */
.hex-content-grid--layer2 .hex-module--content {
    background: linear-gradient(180deg, var(--surface) 0%, rgba(196, 166, 184, 0.08) 100%);
}

/* ============================================================
   Shake Micro-Interaction
   ============================================================ */

@keyframes hexShake {
    0%, 100% { transform: translateX(0); }
    16.6% { transform: translateX(3px); }
    33.3% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    66.6% { transform: translateX(-3px); }
    83.3% { transform: translateX(3px); }
}

.hex-module--shake {
    animation: hexShake 0.3s ease-out;
}

/* ============================================================
   Transition Zones
   ============================================================ */

.transition-zone {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    min-height: 50vh;
}

.transition-text {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-align: center;
    position: relative;
    z-index: 2;
}

.decorative-hex-cluster {
    position: absolute;
    pointer-events: none;
}

.decorative-hex-cluster--left {
    left: 8%;
    top: 50%;
    transform: translateY(-50%);
}

.decorative-hex-cluster--right {
    right: 8%;
    top: 50%;
    transform: translateY(-50%);
}

.decorative-hex-cluster--center {
    position: relative;
}

.transition-zone--subtle {
    padding: 4rem 2rem;
    min-height: 20vh;
}

/* ============================================================
   Closing Section
   ============================================================ */

.section-closing {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

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

.closing-hex-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    filter: blur(0px);
    transition: opacity 1.5s ease, filter 1.5s ease;
}

.closing-content.visible .closing-hex-glow {
    opacity: 1;
    filter: blur(2px);
}

.closing-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    color: var(--deep);
    letter-spacing: 0.02em;
    line-height: 1.1;
    position: relative;
    z-index: 2;
    text-shadow: 0 0 60px rgba(232, 145, 90, 0.2);
}

.closing-sub {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--text-muted);
    margin-top: 1rem;
    position: relative;
    z-index: 2;
}

/* ============================================================
   Hex Rosette Navigation
   ============================================================ */

.hex-rosette-nav {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hex-rosette-nav.visible {
    opacity: 1;
}

.rosette-container {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: rgba(251, 244, 236, 0.92);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(237, 220, 204, 0.6);
    box-shadow: 0 4px 20px rgba(139, 78, 42, 0.06);
}

.rosette-hex {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--accent2);
    transition: color 0.3s ease, transform 0.3s var(--spring-overshoot);
}

.rosette-hex:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.rosette-hex.active {
    color: var(--accent);
    transform: scale(1.15);
}

.rosette-hex.active svg polygon,
.rosette-hex.active svg circle {
    fill: var(--accent);
    fill-opacity: 0.25;
}

.rosette-hex--shrink {
    transform: scale(0.9);
}

/* ============================================================
   Hex Reveal Animations
   ============================================================ */

.hex-reveal {
    opacity: 0;
    transform: translateY(28px) scale(0.92);
    transition: opacity 0.5s ease-out, transform 0.5s var(--spring);
}

.hex-reveal.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Stagger delays applied via JS data-delay attribute */

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

@media (max-width: 768px) {
    .hex-content-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .hex-module--content {
        clip-path: polygon(50% 2%, 98% 25%, 98% 75%, 50% 98%, 2% 75%, 2% 25%);
        min-height: 300px;
        padding: 2rem 1.5rem;
    }

    .section-layer {
        padding: 80px 1.5rem 60px;
    }

    .hero-diagram {
        width: 240px;
        height: 210px;
    }

    .hero-diagram-layer--0 svg { width: 240px; height: 210px; }
    .hero-diagram-layer--1 svg { width: 210px; height: 180px; }
    .hero-diagram-layer--2 svg { width: 165px; height: 143px; }

    .transition-zone {
        padding: 4rem 1.5rem;
        min-height: 30vh;
    }

    .decorative-hex-cluster--left,
    .decorative-hex-cluster--right {
        display: none;
    }

    .rosette-container {
        gap: 2px;
        padding: 8px 12px;
    }

    .rosette-hex svg {
        width: 24px;
        height: 24px;
    }

    .rosette-hex--center svg {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.2rem;
    }

    .section-heading {
        font-size: 1.5rem;
    }

    .hex-body {
        font-size: 0.88rem;
    }

    .hex-module--content {
        min-height: 280px;
        padding: 1.75rem 1.25rem;
    }

    .closing-title {
        font-size: 2rem;
    }
}

/* ============================================================
   Reduced Motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .hex-reveal {
        transition: none;
        opacity: 1;
        transform: none;
    }

    .scroll-chevron {
        animation: none;
        opacity: 0.6;
    }

    .hero-content {
        animation: none;
        opacity: 1;
    }

    .rosette-hex {
        transition: none;
    }

    .hex-module--content {
        transition: none;
    }

    .closing-hex-glow {
        transition: none;
    }
}
