/* ===== CSS Custom Properties ===== */
:root {
    --midnight: #0c1426;
    --blueprint: #111d35;
    --panel: #172743;
    --copper: #c47d2e;
    --copper-bright: #e09540;
    --cream: #e8dcc8;
    --steel: #b8c4d8;
    --twilight: #6b8cae;
    --signal: #d4443b;
    --shadow: #080e1a;
    --bg-warm-1: #0e1628;
    --bg-warm-2: #10182e;
    --bg-warm-3: #121a2a;
    --iso-dark: #172743;
    --iso-mid: #111d35;
    --iso-light: #1e3a5f;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--midnight);
    color: var(--steel);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* ===== Background Color Shift Layer ===== */
.bg-shift {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--midnight);
    z-index: -2;
    transition: background-color 0.3s;
}

/* ===== Blueprint Grid Overlay ===== */
.blueprint-grid {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.8s ease;
    background-image:
        linear-gradient(var(--twilight) 1px, transparent 1px),
        linear-gradient(90deg, var(--twilight) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.blueprint-grid.visible {
    opacity: 0.03;
}

/* ===== Typography ===== */
h1, h2, h3, .zone-title {
    font-family: 'Cormorant Garamond', serif;
    color: var(--cream);
    letter-spacing: -0.02em;
    font-weight: 600;
}

h2.zone-title {
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    margin-bottom: 3rem;
    text-align: center;
}

h3 {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    margin-bottom: 0.75rem;
}

.spec-label, .coord, .callout-label, .version-badge span, .typewriter-text, .typewriter-cursor {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.06em;
}

/* ===== Navigation Cube ===== */
.nav-cube {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1000;
    cursor: pointer;
}

.cube-faces {
    width: 32px;
    height: 36px;
    position: relative;
    animation: cubeRotate 30s linear infinite;
}

.cube-face {
    position: absolute;
}

.cube-top {
    width: 28px; height: 16px;
    background: var(--iso-light);
    clip-path: polygon(50% 0%, 100% 30%, 50% 60%, 0% 30%);
    top: 0; left: 2px;
}

.cube-left {
    width: 14px; height: 20px;
    background: var(--iso-mid);
    clip-path: polygon(0% 0%, 100% 30%, 100% 100%, 0% 70%);
    top: 9px; left: 2px;
}

.cube-right {
    width: 14px; height: 20px;
    background: var(--iso-dark);
    clip-path: polygon(0% 30%, 100% 0%, 100% 70%, 0% 100%);
    top: 9px; left: 16px;
}

@keyframes cubeRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.nav-menu {
    list-style: none;
    position: absolute;
    top: 0;
    left: 48px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.nav-cube:hover .nav-menu {
    opacity: 1;
    pointer-events: all;
}

.nav-menu li {
    margin-bottom: 8px;
}

.nav-menu a {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--cream);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-menu a::after {
    content: ' ' attr(data-version);
    font-family: 'IBM Plex Mono', monospace;
    font-style: normal;
    font-size: 0.7rem;
    color: var(--copper);
    letter-spacing: 0.06em;
}

.nav-menu a:hover {
    color: var(--copper-bright);
}

/* ===== Zone Base ===== */
.zone {
    position: relative;
    min-height: 120vh;
    padding: 8vh 5vw;
}

.zone-inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* ===== Transit Corridors ===== */
.transit-corridor {
    height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.transit-line {
    width: 1px;
    height: 60%;
    background: var(--copper);
    transform: rotate(30deg);
    opacity: 0.4;
}

/* ===== Module Cards ===== */
.module-card {
    background: var(--blueprint);
    position: relative;
    padding: 2rem 2rem 2rem 2rem;
    clip-path: polygon(20px 0%, 100% 0%, calc(100% - 20px) 100%, 0% 100%);
    opacity: 0;
    transform: translate(-12px, 20px);
    transition: opacity 0.4s cubic-bezier(0.16, 1.0, 0.3, 1.0),
                transform 0.4s cubic-bezier(0.16, 1.0, 0.3, 1.0);
}

.module-card.visible {
    opacity: 1;
    transform: translate(0, 0);
}

/* Isometric shadow */
.module-card::after {
    content: '';
    position: absolute;
    top: 8px; left: -8px;
    width: 100%; height: 100%;
    background: var(--shadow);
    clip-path: polygon(20px 0%, 100% 0%, calc(100% - 20px) 100%, 0% 100%);
    z-index: -1;
}

/* Copper top border */
.module-card::before {
    content: '';
    position: absolute;
    top: 0; left: 20px; right: 0;
    height: 2px;
    background: var(--copper);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.6s ease 0.2s;
}

.module-card.visible::before {
    transform: scaleX(1);
}

/* ===== Version Badge ===== */
.version-badge {
    position: absolute;
    top: 8px;
    right: 24px;
    background: var(--midnight);
    border: 1px solid var(--copper);
    padding: 2px 10px;
    clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.16, 1.0, 0.3, 1.0);
    z-index: 2;
}

.module-card.visible .version-badge,
.assembly-module.visible .version-badge {
    transform: scale(1);
    transition-delay: 0.4s;
}

.version-badge span {
    color: var(--copper);
}

/* ===== Isometric Icons ===== */
.iso-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    position: relative;
}

.iso-gear::before {
    content: '';
    position: absolute;
    width: 40px; height: 24px;
    background: var(--iso-light);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    top: 4px; left: 4px;
}
.iso-gear::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid var(--copper);
    border-radius: 0;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    top: 16px; left: 16px;
}

.iso-circuit::before {
    content: '';
    position: absolute;
    width: 36px; height: 36px;
    background: var(--iso-mid);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    border: 1px solid var(--copper);
    top: 6px; left: 6px;
}
.iso-circuit::after {
    content: '';
    position: absolute;
    width: 20px; height: 2px;
    background: var(--copper);
    top: 24px; left: 14px;
    box-shadow: 0 8px 0 var(--copper), 0 -8px 0 var(--copper);
}

.iso-container::before {
    content: '';
    position: absolute;
    width: 32px; height: 20px;
    background: var(--iso-dark);
    clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
    top: 14px; left: 8px;
}
.iso-container::after {
    content: '';
    position: absolute;
    width: 32px; height: 12px;
    background: var(--iso-light);
    clip-path: polygon(50% 0%, 100% 50%, 85% 100%, 15% 100%, 0% 50%);
    top: 4px; left: 8px;
}

.iso-switch::before {
    content: '';
    position: absolute;
    width: 36px; height: 20px;
    background: var(--iso-mid);
    clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
    top: 16px; left: 6px;
}
.iso-switch::after {
    content: '';
    position: absolute;
    width: 8px; height: 18px;
    background: var(--copper);
    top: 0; left: 20px;
    transform: rotate(-20deg);
    transform-origin: bottom center;
}

.iso-dial::before {
    content: '';
    position: absolute;
    width: 36px; height: 36px;
    background: var(--iso-dark);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    top: 6px; left: 6px;
}
.iso-dial::after {
    content: '';
    position: absolute;
    width: 2px; height: 14px;
    background: var(--copper-bright);
    top: 10px; left: 23px;
    transform: rotate(30deg);
    transform-origin: bottom center;
}

.iso-antenna::before {
    content: '';
    position: absolute;
    width: 2px; height: 32px;
    background: var(--twilight);
    top: 4px; left: 23px;
}
.iso-antenna::after {
    content: '';
    position: absolute;
    width: 20px; height: 12px;
    background: none;
    border-left: 2px solid var(--copper);
    border-right: 2px solid var(--copper);
    border-top: 2px solid var(--copper);
    clip-path: polygon(0 100%, 20% 0%, 80% 0%, 100% 100%);
    top: 0; left: 14px;
}

/* ===== Zone 1: Workshop Door ===== */
.zone-1 {
    min-height: 150vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 15vh;
}

.title-assembly {
    width: 100%;
    max-width: 800px;
    margin-bottom: 3rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.title-assembly.visible {
    opacity: 1;
}

.title-svg {
    width: 100%;
    height: auto;
}

.title-text-svg {
    font-family: 'Cormorant Garamond', serif;
    font-size: 72px;
    font-weight: 700;
    fill: none;
    stroke: var(--copper);
    stroke-width: 1;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: fill 0.8s ease 1.2s;
}

.title-text-svg.drawn {
    stroke-dashoffset: 0;
    fill: var(--cream);
}

/* Hero iso cube */
.iso-cube-hero {
    width: 80px;
    height: 92px;
    position: relative;
    margin-bottom: 2rem;
}

.iso-cube-hero .iso-face {
    position: absolute;
    transition: transform 0.6s cubic-bezier(0.16, 1.0, 0.3, 1.0), opacity 0.4s;
}

.iso-cube-hero .iso-top {
    width: 70px; height: 40px;
    background: var(--iso-light);
    clip-path: polygon(50% 0%, 100% 25%, 50% 50%, 0% 25%);
    top: 0; left: 5px;
    transform: translateY(-30px) scale(0.5);
    opacity: 0;
}

.iso-cube-hero .iso-left {
    width: 35px; height: 52px;
    background: var(--iso-mid);
    clip-path: polygon(0% 0%, 100% 25%, 100% 75%, 0% 50%);
    top: 19px; left: 5px;
    transform: translateX(-30px) scale(0.5);
    opacity: 0;
}

.iso-cube-hero .iso-right {
    width: 35px; height: 52px;
    background: var(--iso-dark);
    clip-path: polygon(0% 25%, 100% 0%, 100% 50%, 0% 75%);
    top: 19px; left: 40px;
    transform: translateX(30px) scale(0.5);
    opacity: 0;
}

.iso-cube-hero.assembled .iso-top,
.iso-cube-hero.assembled .iso-left,
.iso-cube-hero.assembled .iso-right {
    transform: translate(0, 0) scale(1);
    opacity: 1;
}

/* Typewriter */
.subtitle-typewriter {
    margin-bottom: 4rem;
    text-align: center;
}

.typewriter-text {
    color: var(--twilight);
}

.typewriter-cursor {
    color: var(--copper);
    animation: cursorBlink 0.8s steps(1) infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Zone 1 grid */
.zone1-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
    width: 100%;
    max-width: 1000px;
}

/* ===== Zone 2: Parts Catalog ===== */
.zone-2 {
    min-height: 180vh;
}

.zone2-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.zone2-grid .col-left {
    margin-top: 60px;
}

.zone2-grid .col-center {
    margin-top: 0;
}

.zone2-grid .col-right {
    margin-top: 120px;
}

/* ===== Zone 3: Blueprint Wall ===== */
.zone-3 {
    min-height: 150vh;
}

.blueprint-wall {
    position: relative;
    min-height: 80vh;
}

.blueprint-grid-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(var(--twilight) 1px, transparent 1px),
        linear-gradient(90deg, var(--twilight) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.15;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.grid-coords {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.coord {
    position: absolute;
    color: var(--twilight);
    font-size: 0.7rem;
}

/* Callouts */
.callout {
    position: absolute;
    max-width: 280px;
    opacity: 0;
    transform: translate(-12px, 20px);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1.0, 0.3, 1.0);
}

.callout.visible {
    opacity: 0.7;
    transform: translate(0, 0);
}

.callout.highlight {
    opacity: 1;
}

.callout-label {
    color: var(--copper);
    display: block;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.callout-content {
    background: rgba(17, 29, 53, 0.8);
    padding: 1rem;
    border-left: 2px solid var(--copper);
}

.callout-content p {
    font-size: clamp(0.8rem, 1vw, 0.9rem);
    line-height: 1.6;
}

.callout-arrow {
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid var(--copper);
    margin-bottom: 4px;
    transform: rotate(30deg);
}

.callout-line {
    position: absolute;
    width: 100px; height: 80px;
    bottom: -80px; left: 0;
    opacity: 0.3;
}

.cursor-dot {
    position: absolute;
    width: 8px; height: 8px;
    background: var(--copper-bright);
    border-radius: 0;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.cursor-dot.active {
    opacity: 1;
    animation: dotPulse 0.6s ease-out;
}

@keyframes dotPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(2); opacity: 0.5; }
    100% { transform: scale(1); opacity: 0; }
}

/* ===== Zone 4: Assembly Line ===== */
.zone-4 {
    min-height: 150vh;
}

.assembly-band {
    overflow: hidden;
    position: relative;
    min-height: 400px;
}

.assembly-track {
    display: flex;
    gap: 2rem;
    padding: 2rem 0;
    position: relative;
}

.assembly-module {
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    background: var(--blueprint);
    padding: 2rem;
    position: relative;
    clip-path: polygon(16px 0%, 100% 0%, calc(100% - 16px) 100%, 0% 100%);
    border-top: 2px solid var(--copper);
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1.0, 0.3, 1.0);
}

.assembly-module.visible {
    opacity: 1;
    transform: translateX(0);
}

.assembly-module::after {
    content: '';
    position: absolute;
    top: 8px; left: -8px;
    width: 100%; height: 100%;
    background: var(--shadow);
    clip-path: polygon(16px 0%, 100% 0%, calc(100% - 16px) 100%, 0% 100%);
    z-index: -1;
}

.assembly-module h3 {
    font-size: clamp(1.2rem, 2vw, 1.6rem);
}

/* ===== Zone 5: Launch Pad ===== */
.zone-5 {
    min-height: 120vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.launch-spec-sheet {
    max-width: 560px;
    width: 100%;
    background: var(--blueprint);
    position: relative;
    padding: 3rem;
    border: 2px solid var(--copper);
    margin-top: 2rem;
}

.launch-spec-sheet::after {
    content: '';
    position: absolute;
    top: 10px; left: -10px;
    width: 100%; height: 100%;
    background: var(--shadow);
    z-index: -1;
}

.spec-watermark {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-family: 'Cormorant Garamond', serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--cream);
    opacity: 0.04;
    white-space: nowrap;
    pointer-events: none;
}

.final-badge {
    position: absolute;
    top: -14px; right: 24px;
    background: var(--copper);
    border: none;
    padding: 4px 16px;
}

.final-badge span {
    color: var(--midnight);
    font-weight: 500;
}

.spec-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(107, 140, 174, 0.15);
}

.spec-label {
    color: var(--twilight);
    text-transform: uppercase;
    flex-shrink: 0;
    margin-right: 1rem;
}

.spec-value {
    color: var(--cream);
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.95rem;
    text-align: right;
}

.status-active {
    color: var(--copper-bright);
}

.spec-divider {
    height: 1px;
    background: var(--copper);
    opacity: 0.3;
    margin: 1.5rem 0;
}

.spec-body p {
    margin-bottom: 1rem;
    color: var(--steel);
}

.spec-body p:last-child {
    color: var(--cream);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-style: italic;
}

.spec-footer {
    text-align: center;
    margin-top: 2rem;
}

.spec-stamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    color: var(--copper-bright);
    border: 2px solid var(--copper-bright);
    padding: 0.5rem 1.5rem;
    display: inline-block;
    transform: rotate(-2deg);
}

/* ===== Copper Wires ===== */
.copper-wire {
    position: absolute;
    bottom: -150px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 300px;
    z-index: 5;
    pointer-events: none;
}

.wire-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 0.6s ease;
}

.wire-path.drawn {
    stroke-dashoffset: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .zone2-grid {
        grid-template-columns: 1fr;
    }

    .zone2-grid .col-left,
    .zone2-grid .col-center,
    .zone2-grid .col-right {
        margin-top: 0;
    }

    .assembly-track {
        flex-direction: column;
        align-items: center;
    }

    .assembly-module {
        min-width: auto;
        max-width: 100%;
        width: 100%;
        transform: translateY(30px);
    }

    .assembly-module.visible {
        transform: translateY(0);
    }

    .callout {
        position: relative;
        left: auto !important;
        top: auto !important;
        max-width: 100%;
        margin-bottom: 1.5rem;
    }

    .blueprint-wall {
        min-height: auto;
    }

    .grid-coords {
        display: none;
    }
}
