/* ============================================
   cbdc.studio - Dark Academia x Neon Noir HUD
   ============================================ */

/* CSS Custom Properties - All 8 palette colors */
:root {
    --void: #0a0a12;
    --midnight: #1a1a2e;
    --parchment: #e8d5b5;
    --stone: #c4b8a4;
    --cyan: #00f0ff;
    --magenta: #ff2d6b;
    --charcoal: #2a2438;
    --ghost: #4a4358;
}

/* Animatable custom properties */
@property --dash-offset {
    syntax: '<number>';
    inherits: false;
    initial-value: 1000;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--void);
    color: var(--stone);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 16px;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(255, 45, 107, 0.3);
    color: var(--parchment);
}

/* ============================================
   Typography
   ============================================ */
.headline {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.03em;
    color: var(--parchment);
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.72;
    color: var(--stone);
    max-width: 52ch;
}

.body-text p {
    text-indent: 2em;
    margin-bottom: 1.5em;
}

.body-text p:first-child {
    text-indent: 0;
}

.body-text em {
    font-style: italic;
    color: var(--parchment);
}

.fn-ref {
    color: var(--magenta);
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    cursor: default;
}

.hud-label {
    font-family: 'IBM Plex Sans', 'Helvetica Neue', sans-serif;
    font-weight: 300;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(0, 240, 255, 0.7);
}

.marginalia {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--magenta);
    position: absolute;
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
    white-space: nowrap;
}

.marginalia s {
    text-decoration: line-through;
    opacity: 0.5;
}

.marginalia:nth-child(1) { transform: rotate(-1.5deg); }
.marginalia:nth-child(2) { transform: rotate(1.2deg); }
.marginalia:nth-child(3) { transform: rotate(-0.8deg); }
.marginalia:nth-child(4) { transform: rotate(1.8deg); }
.marginalia:nth-child(5) { transform: rotate(-2deg); }
.marginalia:nth-child(6) { transform: rotate(0.7deg); }
.marginalia:nth-child(7) { transform: rotate(1.5deg); }
.marginalia:nth-child(8) { transform: rotate(-1deg); }

.marginalia.visible {
    opacity: 1;
}

/* ============================================
   Background Layer (z:0)
   ============================================ */
#background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

#cityscape-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 50%;
    opacity: 1;
}

#cityscape-svg path {
    fill: none;
    stroke: var(--cyan);
    stroke-opacity: 0.08;
    stroke-width: 1;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

#cityscape-svg.drawn path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 3s cubic-bezier(0.23, 1, 0.32, 1);
}

#rain-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.rain-streak {
    position: absolute;
    width: 1px;
    height: 60px;
    background: linear-gradient(to bottom, transparent, rgba(0, 240, 255, 0.03), transparent);
    transform: rotate(15deg);
    animation: rain-fall linear infinite;
}

@keyframes rain-fall {
    0% {
        transform: translateY(-100px) rotate(15deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(15deg);
        opacity: 0;
    }
}

#grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease 3s;
}

#grid-overlay.visible {
    opacity: 1;
}

.grid-line-h,
.grid-line-v {
    position: absolute;
    background-color: var(--midnight);
    opacity: 0.15;
}

.grid-line-h {
    width: 100%;
    height: 1px;
}

.grid-line-v {
    width: 1px;
    height: 100%;
}

/* ============================================
   Content Layer (z:10)
   ============================================ */
#content-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Title Screen */
#title-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 15;
    pointer-events: none;
}

#main-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    margin-bottom: 1rem;
    min-height: 1.2em;
    white-space: nowrap;
}

#main-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: settle 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes settle {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#subtitle {
    opacity: 0;
    transition: opacity 1.5s ease;
    font-size: clamp(0.7rem, 1vw, 0.9rem);
}

#subtitle.visible {
    opacity: 0.6;
}

#title-screen.fade-out {
    opacity: 0;
    transition: opacity 1s ease;
    pointer-events: none;
}

/* ============================================
   Navigation Nodes
   ============================================ */
#nav-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#nav-nodes.visible {
    opacity: 1;
}

#node-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#node-connections line {
    stroke: var(--cyan);
    stroke-opacity: 0.1;
    stroke-width: 0.5;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.23, 1, 0.32, 1);
}

#node-connections line.drawn {
    stroke-dashoffset: 0;
}

.nav-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    cursor: pointer;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-node.visible {
    transform: translate(-50%, -50%) scale(1);
}

.node-shape {
    width: 24px;
    height: 24px;
    transition: clip-path 0.3s ease;
}

.node-shape polygon,
.node-shape circle,
.node-shape path {
    stroke: var(--magenta);
    stroke-opacity: 0.4;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease, stroke-opacity 0.3s ease, stroke 0.3s ease;
}

.nav-node.visible .node-shape polygon,
.nav-node.visible .node-shape circle,
.nav-node.visible .node-shape path {
    stroke-dashoffset: 0;
}

.nav-node .node-shape {
    filter: drop-shadow(0 0 8px rgba(255, 45, 107, 0.3));
    animation: node-breathe 4s ease-in-out infinite;
}

@keyframes node-breathe {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 45, 107, 0.2)); }
    50% { filter: drop-shadow(0 0 12px rgba(255, 45, 107, 0.5)); }
}

/* Active node - hexagon to triangle morph + stronger glow */
.nav-node.active .node-shape {
    animation: none;
    filter: drop-shadow(0 0 14px rgba(255, 45, 107, 0.7));
    clip-path: polygon(50% 5%, 95% 90%, 5% 90%);
    transition: clip-path 0.3s ease, filter 0.3s ease;
}

.nav-node:not(.active) .node-shape {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    transition: clip-path 0.3s ease, filter 0.3s ease;
}

.nav-node.active .node-shape polygon {
    stroke-opacity: 0.9;
}

.nav-node.visited .node-shape polygon {
    stroke-opacity: 0.25;
}

/* Visited nodes show as circles via clip-path */
.nav-node.visited .node-shape {
    clip-path: circle(45% at 50% 50%);
}

.node-label {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
    white-space: nowrap;
    font-size: clamp(0.55rem, 0.75vw, 0.7rem);
}

.nav-node.visible .node-label {
    opacity: 1;
    transform: translateY(0);
}

.nav-node:hover .node-label {
    color: var(--parchment);
}

.nav-node:hover .node-shape polygon {
    stroke-opacity: 0.8;
    stroke: var(--parchment);
}

/* ============================================
   Content Panel (HUD Panel)
   ============================================ */
.hud-panel {
    background: rgba(26, 26, 46, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 240, 255, 0.12);
    border-radius: 0;
    padding: 0;
    position: relative;
}

#content-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 700px;
    max-height: 70vh;
    z-index: 12;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    overflow: hidden;
}

#content-panel.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s 0s;
}

#panel-wipe-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 1px;
    background-color: var(--magenta);
    transform: translateX(-50%);
    transition: width 0.2s ease;
    z-index: 2;
}

#content-panel.wiping #panel-wipe-line {
    width: 100%;
}

#panel-content {
    padding: 2.5rem 3rem;
    max-height: 65vh;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease 0.25s;
    position: relative;
    z-index: 1;
}

#content-panel.content-visible #panel-content {
    opacity: 1;
}

/* Custom scrollbar for panel content */
#panel-content::-webkit-scrollbar {
    width: 3px;
}

#panel-content::-webkit-scrollbar-track {
    background: var(--midnight);
}

#panel-content::-webkit-scrollbar-thumb {
    background: var(--magenta);
}

/* Firefox scrollbar */
#panel-content {
    scrollbar-width: thin;
    scrollbar-color: var(--magenta) var(--midnight);
}

/* Panel decorative border - banknote engraving style */
#content-panel::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid rgba(0, 240, 255, 0.06);
    pointer-events: none;
    z-index: 1;
}

/* Corner ornaments - geometric rosettes */
#content-panel::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background:
        radial-gradient(circle at 0 0, rgba(0, 240, 255, 0.15) 0%, transparent 8px),
        radial-gradient(circle at 100% 0, rgba(0, 240, 255, 0.15) 0%, transparent 8px),
        radial-gradient(circle at 0 100%, rgba(0, 240, 255, 0.15) 0%, transparent 8px),
        radial-gradient(circle at 100% 100%, rgba(0, 240, 255, 0.15) 0%, transparent 8px);
    pointer-events: none;
    z-index: 1;
}

/* Guilloche background pattern for panels */
#content-panel .guilloche-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
}

/* Panel close button */
#panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 5;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

#panel-close:hover {
    opacity: 1;
}

#panel-close line {
    stroke: var(--cyan);
    stroke-width: 1.5;
}

/* ============================================
   Overlay Layer (z:20)
   ============================================ */
#overlay-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

#hud-timestamp {
    position: absolute;
    top: 16px;
    right: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.15em;
    opacity: 0;
    transition: opacity 1s ease;
}

#hud-timestamp.visible {
    opacity: 0.7;
}

#hud-status-left {
    position: absolute;
    top: 16px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 1s ease;
}

#hud-status-left.visible {
    opacity: 0.7;
}

#hud-section-counter {
    position: absolute;
    bottom: 16px;
    right: 20px;
    opacity: 0;
    transition: opacity 1s ease;
    font-variant-numeric: tabular-nums;
}

#hud-section-counter.visible {
    opacity: 0.5;
}

.status-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--cyan);
    animation: status-pulse 2s ease-in-out infinite;
}

.status-dot.active {
    background-color: var(--magenta);
}

@keyframes status-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

#marginalia-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Guilloche Corner Decorations */
.guilloche-corner {
    position: absolute;
    width: 150px;
    height: 150px;
    opacity: 0.08;
    pointer-events: none;
}

#guilloche-topleft {
    top: 0;
    left: 0;
}

#guilloche-bottomright {
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.guilloche-corner path {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 0.5;
}

/* Edge Connectors */
#edge-connectors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#edge-connectors line {
    stroke: var(--cyan);
    stroke-opacity: 0.06;
    stroke-width: 0.5;
    stroke-dasharray: 4 6;
}

/* ============================================
   Intersection Shapes
   ============================================ */
#intersection-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.intersection-shape {
    position: absolute;
    width: 12px;
    height: 12px;
    animation: shape-rotate 20s linear infinite;
}

.intersection-shape svg {
    width: 100%;
    height: 100%;
}

.intersection-shape svg * {
    fill: none;
    stroke: var(--magenta);
    stroke-opacity: 0.25;
    stroke-width: 1;
}

@keyframes shape-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   Fine Line Dividers (banknote engraving)
   ============================================ */
.fine-divider {
    width: 100%;
    height: 0;
    border-bottom: 0.5px solid var(--ghost);
    margin: 1.5em 0;
    opacity: 0.4;
}

/* ============================================
   Pull Quotes (Caveat - marginalia style)
   ============================================ */
.pull-quote {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
    color: var(--magenta);
    margin: 1.5em -20px;
    padding: 0.5em 0;
    transform: rotate(-1deg);
    line-height: 1.4;
}

/* ============================================
   Section data (hidden template)
   ============================================ */
#section-data {
    display: none;
}

/* ============================================
   Banknote parallel lines as section dividers
   ============================================ */
.banknote-divider {
    position: relative;
    width: 80%;
    height: 6px;
    margin: 2em auto;
    overflow: hidden;
}

.banknote-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        var(--ghost) 0px,
        var(--ghost) 0.5px,
        transparent 0.5px,
        transparent 2px
    );
    opacity: 0.3;
}

/* ============================================
   Watermark "0" motif
   ============================================ */
.watermark-zero {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-style: italic;
    font-size: 40vw;
    color: var(--ghost);
    opacity: 0.02;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
    user-select: none;
}

/* ============================================
   Neon glow effects on dark backgrounds
   ============================================ */
.neon-glow {
    mix-blend-mode: screen;
}

/* ============================================
   Responsive adjustments
   ============================================ */
@media (max-width: 768px) {
    #content-panel {
        width: 90%;
        max-height: 80vh;
    }

    #panel-content {
        padding: 1.5rem 1.5rem;
    }

    .nav-node {
        gap: 4px;
    }

    .node-shape {
        width: 18px;
        height: 18px;
    }

    .marginalia {
        display: none;
    }

    .guilloche-corner {
        width: 80px;
        height: 80px;
    }

    #hud-section-counter {
        bottom: 12px;
        right: 12px;
    }
}

@media (max-width: 480px) {
    #content-panel {
        width: 95%;
    }

    .headline {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }

    #main-title {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .guilloche-corner {
        display: none;
    }
}
