/* ncbd.dev - Navy Metallic Honeycomb Design */

/* ===== CSS Custom Properties ===== */
:root {
    --bg-deep: #0b1628;
    --bg-mid: #132238;
    --bg-alt: #162640;
    --fg-primary: #c8cdd5;
    --fg-secondary: #7b8a9e;
    --accent-warm: #c9923e;
    --accent-cool: #4a8c7f;
    --border-rule: #2a3a52;
    --vein-overlay: #1a2744;
    --highlight: #e8a832;
    --cell-width: 260px;
    --cell-height: calc(var(--cell-width) * 1.1547);
    --hex-gap: 8px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-deep);
    color: var(--fg-primary);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== Leaf Venation SVG Underlay ===== */
#leaf-venation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

#vein-paths path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawVein 4s ease-out forwards;
}

.vein-main {
    animation-delay: 0s !important;
}

.vein-branch:nth-child(2) { animation-delay: 0.3s !important; }
.vein-branch:nth-child(3) { animation-delay: 0.5s !important; }
.vein-branch:nth-child(4) { animation-delay: 0.7s !important; }
.vein-branch:nth-child(5) { animation-delay: 0.9s !important; }
.vein-branch:nth-child(6) { animation-delay: 1.1s !important; }
.vein-branch:nth-child(7) { animation-delay: 1.3s !important; }
.vein-branch:nth-child(8) { animation-delay: 0.4s !important; }
.vein-branch:nth-child(9) { animation-delay: 0.6s !important; }
.vein-branch:nth-child(10) { animation-delay: 0.8s !important; }
.vein-branch:nth-child(11) { animation-delay: 1.0s !important; }
.vein-branch:nth-child(12) { animation-delay: 1.2s !important; }
.vein-branch:nth-child(13) { animation-delay: 1.4s !important; }

.vein-secondary {
    stroke: var(--vein-overlay);
    stroke-width: 0.8;
    opacity: 0.05;
}

.vein-secondary:nth-child(14) { animation-delay: 1.5s !important; }
.vein-secondary:nth-child(15) { animation-delay: 1.7s !important; }
.vein-secondary:nth-child(16) { animation-delay: 1.9s !important; }
.vein-secondary:nth-child(17) { animation-delay: 2.1s !important; }
.vein-secondary:nth-child(18) { animation-delay: 1.6s !important; }
.vein-secondary:nth-child(19) { animation-delay: 1.8s !important; }
.vein-secondary:nth-child(20) { animation-delay: 2.0s !important; }
.vein-secondary:nth-child(21) { animation-delay: 2.2s !important; }

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

/* ===== Phases / Sections ===== */
.phase {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

#phase-genesis {
    min-height: 100vh;
}

/* ===== Honeycomb Container ===== */
.honeycomb-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--hex-gap);
    max-width: 1400px;
    margin: 0 auto;
}

.genesis-container {
    justify-content: center;
}

.ring1-container {
    max-width: 900px;
}

.ring2-container {
    max-width: 1200px;
}

.utility-container {
    max-width: 900px;
}

/* ===== Hexagonal Cells ===== */
.hex-cell {
    width: clamp(180px, 22vw, 280px);
    height: 0;
    padding-bottom: calc(clamp(180px, 22vw, 280px) * 1.1547);
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    transition: transform 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
}

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

.hex-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-mid);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.4s ease;
}

.hex-cell:hover .hex-inner {
    background-color: var(--bg-alt);
}

.hex-cell:hover {
    transform: scale(1.02);
}

.hex-content {
    padding: 15%;
    text-align: center;
    width: 100%;
    overflow: hidden;
}

/* ===== Hexagonal Border Effect ===== */
.hex-cell::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background-color: var(--border-rule);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: -1;
    transition: background-color 0.4s ease;
}

.hex-cell:hover::before {
    background-color: var(--accent-warm);
}

/* ===== Hexagonal Pulse Animation ===== */
@keyframes hexPulse {
    0%, 100% { background-color: var(--bg-mid); }
    50% { background-color: var(--bg-alt); }
}

.hex-cell[data-ring='0'] .hex-inner { animation: hexPulse 6s ease-in-out infinite; animation-delay: 0s; }
.hex-cell[data-ring='1'] .hex-inner { animation: hexPulse 6s ease-in-out infinite; animation-delay: 1s; }
.hex-cell[data-ring='2'] .hex-inner { animation: hexPulse 6s ease-in-out infinite; animation-delay: 2s; }
.hex-cell[data-ring='3'] .hex-inner { animation: hexPulse 6s ease-in-out infinite; animation-delay: 3s; }

/* ===== Stomata Breathing Animation ===== */
@keyframes stomataBreath {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.hex-cell:hover {
    animation: stomataBreath 3s ease-in-out infinite;
}

/* ===== Genesis Node ===== */
.genesis-node {
    width: clamp(220px, 28vw, 340px);
    padding-bottom: calc(clamp(220px, 28vw, 340px) * 1.1547);
}

.genesis-node .hex-inner {
    background-color: var(--bg-mid);
}

.genesis-node::before {
    background-color: var(--accent-warm);
}

/* ===== Typography ===== */
.logotype {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: 4.5rem;
    letter-spacing: 0.15em;
    color: var(--fg-primary);
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.tagline {
    font-family: 'IBM Plex Sans', sans-serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--fg-secondary);
    letter-spacing: 0.05em;
}

h2 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-primary);
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.hex-content p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--fg-secondary);
}

.quote {
    font-style: italic;
    color: var(--accent-cool) !important;
    font-size: 0.82rem !important;
    line-height: 1.65 !important;
}

/* ===== Code Blocks ===== */
.code-block {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--accent-cool);
    text-align: left;
    white-space: pre;
    overflow: hidden;
}

.code-block code {
    font-family: inherit;
}

/* ===== Utility Cells ===== */
.utility-label {
    display: block;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-secondary);
    margin-bottom: 0.3rem;
}

.mono-text {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent-cool);
}

/* ===== Underline Draw Animation ===== */
.underline-draw {
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 2px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 400ms cubic-bezier(0.4, 0, 0.2, 1);
    display: inline;
}

.underline-draw.drawn {
    background-size: 100% 2px;
}

/* ===== Ring 1 Honeycomb Layout ===== */
.ring1-container {
    display: grid;
    grid-template-columns: repeat(3, clamp(180px, 22vw, 280px));
    gap: var(--hex-gap);
    justify-content: center;
}

.ring1-container .hex-cell:nth-child(n+4) {
    transform-origin: center top;
}

/* Offset odd rows for honeycomb */
.ring1-container .hex-cell:nth-child(4),
.ring1-container .hex-cell:nth-child(5),
.ring1-container .hex-cell:nth-child(6) {
    margin-top: calc(clamp(180px, 22vw, 280px) * -0.28);
}

/* ===== Ring 2 Honeycomb Layout ===== */
.ring2-container {
    display: grid;
    grid-template-columns: repeat(4, clamp(160px, 18vw, 240px));
    gap: var(--hex-gap);
    justify-content: center;
}

.ring2-container .hex-cell {
    width: clamp(160px, 18vw, 240px);
    padding-bottom: calc(clamp(160px, 18vw, 240px) * 1.1547);
}

/* Offset rows for honeycomb */
.ring2-container .hex-cell:nth-child(5),
.ring2-container .hex-cell:nth-child(6),
.ring2-container .hex-cell:nth-child(7),
.ring2-container .hex-cell:nth-child(8) {
    margin-top: calc(clamp(160px, 18vw, 240px) * -0.28);
    margin-left: calc(clamp(160px, 18vw, 240px) * 0.5);
}

.ring2-container .hex-cell:nth-child(5) {
    margin-left: calc(clamp(160px, 18vw, 240px) * -0.25);
}

.ring2-container .hex-cell:nth-child(9),
.ring2-container .hex-cell:nth-child(10),
.ring2-container .hex-cell:nth-child(11),
.ring2-container .hex-cell:nth-child(12) {
    margin-top: calc(clamp(160px, 18vw, 240px) * -0.28);
}

/* ===== Utility Layout ===== */
.utility-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hex-gap);
    justify-content: center;
}

.utility-cell {
    width: clamp(150px, 18vw, 220px);
    padding-bottom: calc(clamp(150px, 18vw, 220px) * 1.1547);
}

/* ===== Compass Rose ===== */
#compass-rose {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
    cursor: pointer;
}

#compass-rose.visible {
    opacity: 1;
}

#compass-rose svg {
    filter: drop-shadow(0 0 8px rgba(11, 22, 40, 0.6));
}

.compass-arm {
    transition: stroke 0.3s ease, stroke-width 0.3s ease;
    cursor: pointer;
}

.compass-arm:hover {
    stroke: var(--accent-warm) !important;
    stroke-width: 2.5 !important;
}

.compass-arm.active {
    stroke: var(--highlight) !important;
    stroke-width: 2 !important;
}

#compass-needle {
    transform-origin: 60px 60px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Cell Reveal Transitions ===== */
.hex-cell {
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.genesis-node {
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.genesis-node.visible {
    opacity: 1;
    transform: scale(1);
}

.ring1-cell {
    transition-delay: calc(var(--cell-index, 0) * 100ms + 200ms);
}

.ring2-cell {
    transition-delay: calc(var(--cell-index, 0) * 80ms + 200ms);
}

/* ===== Hex Border Draw Animation ===== */
@keyframes borderDraw {
    0% {
        clip-path: polygon(50% 0%, 50% 0%, 50% 0%, 50% 0%, 50% 0%, 50% 0%);
    }
    16% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 25%, 100% 25%, 100% 25%, 100% 25%);
    }
    33% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 100% 75%, 100% 75%, 100% 75%);
    }
    50% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 50% 100%, 50% 100%);
    }
    66% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 75%);
    }
    83% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    }
    100% {
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    }
}

.hex-cell.border-draw::before {
    animation: borderDraw 600ms ease-out forwards;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .ring1-container {
        grid-template-columns: repeat(2, clamp(150px, 35vw, 240px));
    }
    
    .ring1-container .hex-cell {
        width: clamp(150px, 35vw, 240px);
        padding-bottom: calc(clamp(150px, 35vw, 240px) * 1.1547);
    }
    
    .ring1-container .hex-cell:nth-child(4),
    .ring1-container .hex-cell:nth-child(5),
    .ring1-container .hex-cell:nth-child(6) {
        margin-top: calc(clamp(150px, 35vw, 240px) * -0.28);
    }

    .ring2-container {
        grid-template-columns: repeat(2, clamp(140px, 32vw, 220px));
    }
    
    .ring2-container .hex-cell {
        width: clamp(140px, 32vw, 220px);
        padding-bottom: calc(clamp(140px, 32vw, 220px) * 1.1547);
    }
    
    .ring2-container .hex-cell:nth-child(5),
    .ring2-container .hex-cell:nth-child(6),
    .ring2-container .hex-cell:nth-child(7),
    .ring2-container .hex-cell:nth-child(8) {
        margin-left: 0;
    }

    .ring2-container .hex-cell:nth-child(5) {
        margin-left: 0;
    }

    .logotype {
        font-size: 3rem;
    }

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

    .code-block {
        font-size: 0.6rem;
    }
}

@media (max-width: 600px) {
    .ring1-container,
    .ring2-container {
        grid-template-columns: repeat(1, clamp(180px, 60vw, 260px));
    }
    
    .ring1-container .hex-cell,
    .ring2-container .hex-cell {
        width: clamp(180px, 60vw, 260px);
        padding-bottom: calc(clamp(180px, 60vw, 260px) * 1.1547);
    }
    
    .ring1-container .hex-cell:nth-child(4),
    .ring1-container .hex-cell:nth-child(5),
    .ring1-container .hex-cell:nth-child(6),
    .ring2-container .hex-cell:nth-child(5),
    .ring2-container .hex-cell:nth-child(6),
    .ring2-container .hex-cell:nth-child(7),
    .ring2-container .hex-cell:nth-child(8),
    .ring2-container .hex-cell:nth-child(9),
    .ring2-container .hex-cell:nth-child(10),
    .ring2-container .hex-cell:nth-child(11),
    .ring2-container .hex-cell:nth-child(12) {
        margin-top: -2rem;
        margin-left: 0;
    }

    .phase {
        padding: 2rem 1rem;
    }

    #compass-rose {
        right: 1rem;
        bottom: 1rem;
    }

    #compass-rose svg {
        width: 60px;
        height: 60px;
    }
}

/* ===== Blend Mode Overlay on Hex Edges ===== */
.hex-cell::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    mix-blend-mode: screen;
    pointer-events: none;
    transition: background 0.4s ease;
}

.hex-cell:hover::after {
    background: rgba(201, 146, 62, 0.04);
}