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

html {
    scroll-behavior: smooth;
}

body {
    background: #0F1318;
    color: #C4CCD6;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

/* === Particle Canvas === */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* === Transaction Path SVG === */
.transaction-path {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* === HUD Corners === */
.hud-corner {
    position: fixed;
    z-index: 100;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    letter-spacing: 0.08em;
    color: #93B2D7;
    text-transform: uppercase;
    opacity: 0.6;
}
.hud-top-left { top: 20px; left: 24px; }
.hud-top-right { top: 20px; right: 24px; }

/* === Z-Layout Main === */
.z-layout {
    position: relative;
    z-index: 10;
    padding: 15vh 5vw 20vh;
    display: flex;
    flex-direction: column;
    gap: 12vh;
}

/* === Glass Panel Base === */
.glass-panel {
    position: relative;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(22, 33, 48, 0.55);
    border: 1px solid rgba(147, 178, 215, 0.18);
    border-radius: 16px;
    padding: clamp(2rem, 4vw, 3.5rem);
    max-width: 620px;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease, box-shadow 0.3s ease;
    /* Glass refraction effect */
    background-image: radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.08) 0%, transparent 70%);
}

.glass-panel:hover {
    transform: translateY(-4px) rotate(var(--rot)) !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.glass-panel.visible {
    opacity: 1;
}

/* === Z-Pattern Positioning === */
.glass-panel[data-z="left"] {
    align-self: flex-start;
    margin-left: 5vw;
}

.glass-panel[data-z="right"] {
    align-self: flex-end;
    margin-right: 5vw;
}

.glass-panel[data-z="center"] {
    align-self: center;
}

.glass-panel[data-z="full"] {
    max-width: 100%;
    width: 100%;
    align-self: stretch;
}

/* === Typography === */
h1, h2 {
    font-family: 'Playfair Display', Georgia, serif;
    color: #E8EDF2;
    letter-spacing: -0.02em;
    text-shadow: 0 0 30px rgba(147, 178, 215, 0.3);
}

h1 {
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 700;
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #C4CCD6;
    margin-top: 0.75rem;
    font-weight: 400;
}

p {
    margin-bottom: 1.2rem;
    color: #C4CCD6;
}

/* === Title Glow Animation === */
.title-glow {
    animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { text-shadow: 0 0 30px rgba(147, 178, 215, 0.2); }
    50% { text-shadow: 0 0 30px rgba(147, 178, 215, 0.4), 0 0 60px rgba(147, 178, 215, 0.15); }
}

/* === HUD Elements === */
.hud-readout {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.hud-data {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    letter-spacing: 0.08em;
    color: #93B2D7;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.glass-panel.visible .hud-data {
    opacity: 1;
}

/* Stagger HUD reveals */
.glass-panel.visible .hud-data:nth-child(1) { transition-delay: 0.2s; }
.glass-panel.visible .hud-data:nth-child(2) { transition-delay: 0.4s; }
.glass-panel.visible .hud-data:nth-child(3) { transition-delay: 0.6s; }

/* === HUD Brackets === */
.hud-brackets {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    pointer-events: none;
}

.bracket-svg {
    width: 100%;
    height: 100%;
}

.bracket-line {
    fill: none;
    stroke: #93B2D7;
    stroke-width: 0.8;
    opacity: 0;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    transition: stroke-dashoffset 1.2s ease, opacity 0.6s ease;
}

.glass-panel.visible .bracket-line {
    stroke-dashoffset: 0;
    opacity: 0.6;
}

/* === Transaction Membrane === */
.panel-membrane {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    background: rgba(33, 28, 38, 0.6);
    background-image: radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.05) 0%, transparent 70%);
    border-radius: 8px;
    text-align: center;
    padding: clamp(3rem, 6vw, 5rem) clamp(2rem, 4vw, 4rem);
}

.membrane-content h2 {
    font-size: clamp(1.8rem, 4.5vw, 3rem);
}

.membrane-counter {
    justify-content: center;
    margin-top: 2rem;
}

.membrane-counter .hud-data {
    font-size: clamp(0.8rem, 1.2vw, 1rem);
}

#txn-counter {
    color: #7ECBA1;
    font-weight: 400;
}

/* === Settlement Zone === */
.panel-settlement {
    background: rgba(22, 33, 48, 0.85);
    border-color: rgba(212, 160, 160, 0.25);
    background-image: radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.06) 0%, transparent 70%);
    box-shadow: 0 0 40px rgba(126, 203, 161, 0.08);
    max-width: 680px;
}

.settlement-title {
    color: #D4A0A0;
    text-shadow: 0 0 30px rgba(212, 160, 160, 0.3);
}

.settlement-text {
    color: #C4CCD6;
}

.settlement-status {
    color: #7ECBA1 !important;
}

.settlement-bracket {
    stroke: #D4A0A0 !important;
}

/* === Whimsical Elements === */
.whimsy {
    position: absolute;
    width: 50px;
    height: 35px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.glass-panel.visible .whimsy {
    opacity: 0.7;
}

.whimsy-airplane {
    top: -25px;
    right: 30px;
    width: 60px;
    height: 40px;
}

.glass-panel.visible .whimsy-airplane {
    animation: flyAcross 3s ease-in-out 0.8s forwards;
}

@keyframes flyAcross {
    0% { transform: translateX(0); opacity: 0; }
    20% { opacity: 0.7; }
    100% { transform: translateX(60px) translateY(-10px); opacity: 0; }
}

.whimsy-clock {
    bottom: -20px;
    left: 20px;
    width: 40px;
    height: 40px;
}

.whimsy-envelope {
    top: -20px;
    left: 40px;
    width: 50px;
    height: 40px;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .z-layout {
        padding: 10vh 4vw 15vh;
        gap: 8vh;
    }

    .glass-panel {
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-self: stretch !important;
    }

    .glass-panel[data-z="left"],
    .glass-panel[data-z="right"] {
        margin-left: 2vw !important;
        margin-right: 2vw !important;
    }

    .hud-corner {
        display: none;
    }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .glass-panel {
        transition: opacity 0.3s ease;
    }

    .title-glow {
        animation: none;
        text-shadow: 0 0 30px rgba(147, 178, 215, 0.3);
    }

    .bracket-line {
        transition: opacity 0.3s ease;
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }

    .glass-panel.visible .whimsy-airplane {
        animation: none;
    }
}
