:root {
    /* Black / Orange Monolith Palette */
    --c-bg: #030201;
    --c-surface: #0a0602;
    --c-surface-strong: #110902;
    --c-fg: #fff2df;
    --c-muted: #b57532;
    --c-dim: #3a2109;
    --c-accent: #ff9d00;
    --c-accent-strong: #ffb13b;
    --c-accent-soft: rgba(255, 157, 0, 0.1);
    --c-accent-glow: rgba(255, 157, 0, 0.24);
    
    /* Studio Spacing */
    --gap: clamp(1rem, 5vw, 4rem);
    
    /* Typography */
    --f-display: 'Fraunces', serif;
    --f-logic: 'Manrope', sans-serif;
    
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
}

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

body.has-custom-cursor,
body.has-custom-cursor * {
    cursor: none !important;
}

body {
    background: var(--c-bg);
    color: var(--c-fg);
    font-family: var(--f-logic);
    font-weight: 300;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Atmospheric Overlays */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.05;
    pointer-events: none;
    z-index: 9999;
}

.grid-overlay {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255, 157, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 157, 0, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 0;
    pointer-events: none;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
}

/* Transition Mask */
#transition-mask {
    position: fixed;
    inset: 0;
    background: var(--c-bg);
    border-bottom: 4px solid var(--c-accent);
    z-index: 99999;
    clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    transition: clip-path 0.45s var(--ease-in-out);
    pointer-events: none;
}

#transition-mask.is-active {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

/* Custom Cursor */
#cursor {
    position: fixed;
    display: none;
    width: 8px;
    height: 8px;
    background: var(--c-accent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transition: transform 0.04s linear;
    box-shadow: 0 0 10px var(--c-accent);
}

#cursor-follower {
    position: fixed;
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--c-accent);
    opacity: 0.3;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.08s var(--ease-out), width 0.25s, height 0.25s;
}

body.has-custom-cursor #cursor,
body.has-custom-cursor #cursor-follower {
    display: block;
}

.cursor-hover #cursor-follower {
    width: 80px;
    height: 80px;
    background: var(--c-accent-glow);
    border-color: var(--c-accent);
    opacity: 1;
}

/* HUD Header */
#main-hud {
    position: fixed;
    top: 1rem;
    left: var(--gap);
    right: var(--gap);
    width: auto;
    padding: 0.75rem 0.85rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    background: linear-gradient(180deg, rgba(10, 6, 2, 0.96), rgba(5, 3, 1, 0.88));
    border: 1px solid rgba(255, 157, 0, 0.42);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.52), 0 0 34px rgba(255, 157, 0, 0.1);
    backdrop-filter: blur(18px);
    z-index: 1000;
}

.hud-logo a {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    min-width: max-content;
}

.logo-mark {
    font-family: var(--f-display);
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--c-accent);
}

.logo-full {
    font-size: 0.6rem;
    letter-spacing: 0.4em;
    color: var(--c-accent-strong);
    margin-top: 0.2rem;
}

.hud-nav {
    justify-self: center;
    min-width: 0;
}

.hud-nav ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    align-items: center;
    justify-content: center;
}

.hud-nav a {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #ffc57c;
    text-decoration: none;
    transition: color 0.25s, background 0.25s, border-color 0.25s, box-shadow 0.25s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.45rem;
    padding: 0.62rem 0.92rem;
    border: 1px solid rgba(255, 157, 0, 0.22);
    border-radius: 999px;
    background: rgba(255, 157, 0, 0.06);
    white-space: nowrap;
}

.nav-idx {
    font-size: 0.5rem;
    opacity: 0.5;
    color: var(--c-accent);
}

.hud-nav a:hover,
.hud-nav a.active {
    color: #050301;
    background: var(--c-accent);
    border-color: var(--c-accent);
    box-shadow: 0 0 20px rgba(255, 157, 0, 0.22);
}

.btn-hud {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--c-accent);
    border-radius: 2rem;
    color: var(--c-accent);
    line-height: 1.15;
    min-height: 2.45rem;
    text-decoration: none;
    white-space: nowrap;
    background: rgba(255, 157, 0, 0.06);
    transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.btn-hud:hover {
    background: var(--c-accent);
    color: #050301;
    box-shadow: 0 0 20px rgba(255, 157, 0, 0.22);
}

.hud-status {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.status-pulse {
    width: 6px;
    height: 6px;
    background: var(--c-accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--c-accent);
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #ce8b41;
}

@keyframes pulse {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Monolith Hero */
.monolith-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 7rem var(--gap) 4rem;
}

.display-huge {
    font-family: var(--f-display);
    font-weight: 900;
    font-size: clamp(3.1rem, 9vw, 7rem);
    line-height: 1.04;
    letter-spacing: 0;
    color: var(--c-accent-strong);
    text-shadow: 0 0 28px rgba(255, 157, 0, 0.18);
    max-width: 100%;
    padding-bottom: 0.08em;
    white-space: normal;
    text-wrap: balance;
    overflow-wrap: normal;
}

.display-huge[data-scramble] {
    display: block;
}

.hero-title-mask {
    padding-bottom: 0.2rem;
}

[data-scramble] {
    display: inline-block;
    vertical-align: bottom;
    will-change: contents;
    position: relative;
}

.hero-lead {
    font-size: clamp(1rem, 2vw, 1.5rem);
    max-width: 600px;
    color: var(--c-muted);
    margin-top: 3rem;
    font-weight: 300;
}

.hero-footer {
    margin-top: 6rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.hero-stats {
    display: flex;
    gap: 4rem;
}

.stat-block {
    display: flex;
    flex-direction: column;
}

.stat-val {
    font-family: var(--f-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--c-accent);
}

.stat-lbl {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--c-muted);
}

/* Magnetic Button */
.magnetic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 180px;
    text-decoration: none;
    color: #fff;
}

.btn-text {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    z-index: 1;
}

.btn-circle {
    position: absolute;
    inset: 0;
    fill: none;
    stroke: var(--c-dim);
    stroke-width: 1;
    transition: stroke 0.3s;
}

.magnetic-btn:hover .btn-circle {
    stroke: var(--c-accent);
    filter: drop-shadow(0 0 10px var(--c-accent));
}

/* Reveal Masks */
.reveal-mask {
    overflow: hidden;
}

.is-loading .reveal-mask > * {
    transform: translateY(110%);
}

.reveal-mask > * {
    transform: translateY(0);
    transition: transform 0.8s var(--ease-out);
}

/* Monolith Advert */
.monolith-advert {
    padding: 10rem var(--gap);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
    border-top: 1px solid var(--c-dim);
}

.advert-text {
    max-width: 500px;
}

.advert-text.reveal-mask {
    overflow: visible;
}

.label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    color: var(--c-accent);
    display: block;
    margin-bottom: 2rem;
}

.monolith-advert h2 {
    font-family: var(--f-display);
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 2rem;
    color: var(--c-accent-strong);
}

.monolith-advert p {
    color: var(--c-muted);
    font-size: 1.1rem;
}

.mission-cta {
    margin-top: 4rem;
    padding-bottom: 0.15rem;
}

/* Simulated Health Dashboard */
#health-dashboard {
    position: fixed;
    bottom: 2rem;
    left: var(--gap);
    width: min(460px, calc(100vw - 2rem));
    max-height: min(78vh, 720px);
    background: rgba(5, 3, 1, 0.88);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 157, 0, 0.34);
    padding: 1.2rem;
    z-index: 1000;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.52), 0 0 34px rgba(255, 157, 0, 0.1);
}

#health-dashboard.minimized {
    width: min(300px, calc(100vw - 2rem));
}

#health-dashboard.minimized .health-body {
    display: none;
}
#health-dashboard.minimized .health-header {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}
#health-dashboard.minimized .health-chevron {
    transform: rotate(-90deg);
}

.health-header {
    width: 100%;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--c-dim);
    padding: 0 0 0.5rem;
    text-align: left;
}

.health-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--c-accent);
    font-weight: 800;
}

.health-toggle-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.health-chevron {
    color: var(--c-muted);
    display: inline-block;
    font-size: 0.7rem;
    transition: transform 0.3s var(--ease-out), color 0.3s;
}

.health-header:hover .health-chevron {
    color: var(--c-accent);
}

.health-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.health-terminal {
    border: 1px solid rgba(255, 157, 0, 0.22);
    background: rgba(0, 0, 0, 0.48);
    padding: 0.8rem;
    min-height: 86px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    overflow: hidden;
}

.terminal-line {
    font-size: 0.62rem;
    line-height: 1.45;
}

.command-line {
    display: flex;
    gap: 0.45rem;
    color: var(--c-fg);
}

.terminal-prompt {
    color: var(--c-accent);
}

.terminal-output {
    color: #d4934b;
    margin-top: 0.45rem;
}

.probe-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.copy-probe-btn {
    border: 1px solid rgba(255, 157, 0, 0.46);
    border-radius: 999px;
    background: rgba(255, 157, 0, 0.1);
    color: var(--c-accent);
    font: inherit;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    min-height: 2rem;
    padding: 0.35rem 0.85rem;
    text-transform: uppercase;
    transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.copy-probe-btn:hover,
.copy-probe-btn.copied {
    background: var(--c-accent);
    color: #050301;
    box-shadow: 0 0 18px rgba(255, 157, 0, 0.22);
}

.copy-probe-status {
    color: var(--c-accent-strong);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.diagnostic-script {
    max-height: 230px;
    margin-top: 0.8rem;
    overflow: auto;
    padding: 0.85rem;
    border: 1px solid rgba(255, 157, 0, 0.16);
    background: rgba(255, 157, 0, 0.055);
    color: #ffc06f;
    font: inherit;
    font-size: 0.56rem;
    line-height: 1.55;
    white-space: pre;
    scrollbar-color: var(--c-accent) rgba(255, 157, 0, 0.08);
    scrollbar-width: thin;
}

.diagnostic-log {
    display: grid;
    gap: 0.5rem;
    max-height: min(25vh, 240px);
    margin-top: 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.45rem;
    scrollbar-color: var(--c-accent) rgba(255, 157, 0, 0.08);
    scrollbar-width: thin;
}

.diagnostic-log::-webkit-scrollbar {
    width: 6px;
}

.diagnostic-log::-webkit-scrollbar-track {
    background: rgba(255, 157, 0, 0.08);
}

.diagnostic-log::-webkit-scrollbar-thumb {
    background: var(--c-accent);
}

.diagnostic-log-entry {
    border: 1px solid rgba(255, 157, 0, 0.12);
    background: rgba(255, 157, 0, 0.045);
    padding: 0.55rem 0.65rem;
}

.diagnostic-log-command,
.diagnostic-log-output {
    font-size: 0.58rem;
    line-height: 1.45;
}

.diagnostic-log-command {
    color: var(--c-accent-strong);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.diagnostic-log-output {
    color: #d4934b;
    white-space: pre-wrap;
    margin-top: 0.2rem;
}

#diagnostic-command,
.terminal-output,
.diagnostic-log-command,
.diagnostic-log-output {
    overflow-wrap: anywhere;
}

.health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.health-node {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.node-label { font-size: 0.5rem; color: var(--c-muted); text-transform: uppercase; }
.node-status { font-size: 0.6rem; font-family: monospace; display: flex; align-items: center; gap: 0.4rem; color: var(--c-fg); }
.status-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--c-accent); }
.status-dot.pulse { animation: pulse 1s infinite; }

/* Footer */
#main-footer {
    padding: 4rem var(--gap);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--c-dim);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--c-dim);
    background: var(--c-bg);
    position: relative;
    z-index: 100;
}

.footer-right {
    display: flex;
    gap: 3rem;
}

.footer-right a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s;
}

.footer-right a:hover {
    color: var(--c-accent);
}

/* SPA Transitions */
.view-container {
    opacity: 1;
    transition: opacity 0.45s;
}

.view-container.fade-out {
    opacity: 0;
}

#dynamic-view .display-huge,
#dynamic-view .info-text h2,
#dynamic-view .manifest-content h2 {
    color: var(--c-accent-strong) !important;
}

/* Mobile */
@media (max-width: 1024px) {
    #main-hud {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .hud-status {
        display: none;
    }

    .hud-nav {
        justify-self: end;
    }

    .hud-nav ul {
        gap: 0.45rem;
    }

    .hud-nav a {
        font-size: 0.62rem;
        letter-spacing: 0.14em;
        padding-inline: 0.78rem;
    }

    .display-huge {
        font-size: clamp(3.1rem, 10vw, 5.25rem);
    }
    .hero-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 4rem;
    }
    .monolith-advert {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #main-hud {
        top: 0.75rem;
        left: 1rem;
        right: 1rem;
        grid-template-columns: 1fr;
        gap: 0.7rem;
        padding: 0.75rem;
    }

    .hud-logo {
        justify-self: start;
    }

    .hud-nav {
        justify-self: stretch;
        width: 100%;
    }

    .hud-nav ul {
        display: grid;
        grid-template-columns: 1fr 1fr auto;
        width: 100%;
        gap: 0.4rem;
    }

    .hud-nav a {
        min-height: 2.25rem;
        padding: 0.55rem 0.5rem;
        font-size: 0.54rem;
        letter-spacing: 0.08em;
        gap: 0.25rem;
    }

    .nav-idx {
        display: none;
    }

    .logo-full {
        max-width: 190px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .monolith-hero {
        min-height: auto;
        padding: 11rem var(--gap) 5rem;
    }

    .display-huge {
        font-size: 2.85rem;
    }

    .hero-lead {
        margin-top: 2rem;
    }

    .hero-footer {
        margin-top: 4rem;
    }

    .magnetic-btn {
        width: 148px;
        height: 148px;
    }

    .monolith-advert {
        padding: 5.5rem var(--gap) 6rem;
    }

    .monolith-advert h2 {
        font-size: 2.45rem;
    }

    .monolith-advert p {
        font-size: 1rem;
    }

    .mission-cta {
        margin-top: 2.5rem;
    }

    #dynamic-view .monolith-view,
    .monolith-view {
        padding: 6rem var(--gap) 3rem;
    }

    #dynamic-view .view-header,
    .view-header {
        margin-bottom: 4rem;
    }

    #dynamic-view .view-lead,
    .view-lead {
        font-size: 1.05rem;
    }

    #dynamic-view .info-block,
    #dynamic-view .manifest-item,
    .manifest-item {
        flex-direction: column;
        gap: 1.5rem;
        padding: 3rem 0;
    }

    #dynamic-view .manifest-content h2,
    #dynamic-view .info-text h2,
    .manifest-content h2,
    .info-text h2 {
        font-size: 2rem;
    }

    #dynamic-view .manifest-content p,
    #dynamic-view .info-text p,
    .manifest-content p,
    .info-text p {
        font-size: 1rem;
    }

    #dynamic-view .tab-triggers,
    .tab-triggers {
        gap: 1rem;
        flex-wrap: wrap;
        margin-bottom: 3rem;
    }

    #dynamic-view .tab-trigger,
    .tab-trigger {
        font-size: 1.45rem;
    }

    #dynamic-view .detail-list,
    #dynamic-view .security-tier,
    #dynamic-view .architecture-canvas-v2,
    .detail-list,
    .security-tier,
    .architecture-canvas-v2 {
        grid-template-columns: 1fr;
    }

    #dynamic-view .tech-stack,
    .tech-stack {
        flex-wrap: wrap;
    }

    #dynamic-view #layer-details-v2,
    #layer-details-v2 {
        border-left: 0;
        border-top: 1px solid var(--c-dim);
        padding: 2rem 0 0;
    }

    #health-dashboard {
        left: 1rem;
        bottom: 1rem;
        width: calc(100vw - 2rem);
        max-height: min(72vh, 620px);
    }

    .diagnostic-script {
        max-height: 170px;
    }

    .diagnostic-log {
        max-height: 170px;
    }

    #main-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 1.5rem;
    }

    .footer-right {
        flex-wrap: wrap;
        gap: 1.25rem;
    }
}

@media (max-width: 380px) {
    .display-huge {
        font-size: 2.55rem;
    }
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
    body.has-custom-cursor,
    body.has-custom-cursor * {
        cursor: auto !important;
    }

    #cursor,
    #cursor-follower {
        display: none !important;
    }

    [data-magnetic] {
        transform: none !important;
    }
}

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