/* =============================================
   bability.pro - Neomorphic Midnight Aquarium
   ============================================= */

/* ---------- CSS Custom Properties ---------- */
:root {
    --bg-primary: #0a0e1a;           /* Abyssal Navy */
    --bg-secondary: #111828;         /* Midnight Substrate */
    --shadow-dark: #050a1e;          /* Trench Black */
    --shadow-light: #1c2d4e;         /* Deep Glow */
    --text-primary: #c8d0e0;         /* Moonlit Silver */
    --text-heading: #e2e8f4;         /* Pearl Frost */
    --accent-cyan: #4af0e0;          /* Bioluminescent Cyan */
    --accent-warm: #e8a84c;          /* Amber Filament */
    --accent-teal: #2a7a7a;          /* Phosphor Teal */
    --surface-tint: #141e30;         /* Ink Wash */

    --font-heading: 'Libre Franklin', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-accent: 'Nunito Sans', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* ---------- Hidden SVG Defs ---------- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

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

/* ---------- Current Line SVG ---------- */
#current-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6000px;
    z-index: 0;
    pointer-events: none;
}

#current-path {
    stroke-dasharray: 7000;
    stroke-dashoffset: 7000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ---------- Navigation Pill ---------- */
#nav-pill {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 30px;
    padding: 10px 20px;
    box-shadow:
        6px 6px 14px var(--shadow-dark),
        -6px -6px 14px var(--shadow-light);
    overflow: hidden;
    max-width: 170px;
    transition: max-width 400ms ease-out;
    cursor: pointer;
}

#nav-pill:hover {
    max-width: 520px;
}

.nav-brand {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--text-heading);
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 16px;
    margin-left: 24px;
    opacity: 0;
    transition: opacity 300ms ease-out 100ms;
    white-space: nowrap;
}

#nav-pill:hover .nav-links {
    opacity: 1;
}

.nav-link {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 300ms ease;
}

.nav-link:hover {
    color: var(--accent-warm);
}

.nav-link:visited {
    color: var(--accent-teal);
}

/* ---------- Hero Section ---------- */
.hero-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

/* Infinity watermark */
.infinity-watermark {
    position: absolute;
    width: 300px;
    height: 150px;
    opacity: 0.08;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}

/* ---------- Dice Constellation ---------- */
.dice-constellation {
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 1200ms ease-out, transform 1200ms ease-out;
}

.dice-constellation.visible {
    opacity: 1;
    transform: scale(1.0);
}

.constellation-svg {
    width: clamp(280px, 40vw, 440px);
    height: auto;
}

/* Constellation lines */
.constellation-lines line {
    stroke: var(--text-primary);
    stroke-width: 0.5;
    opacity: 0;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.constellation-lines.draw line {
    opacity: 0.08;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1000ms ease-in-out, opacity 400ms ease;
}

/* Dice faces */
.die rect {
    fill: var(--bg-secondary);
    stroke: none;
    rx: 4;
    ry: 4;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    filter: drop-shadow(2px 2px 3px rgba(5,10,30,0.6)) drop-shadow(-1px -1px 2px rgba(28,45,78,0.15));
}

.die .pip {
    fill: var(--accent-cyan);
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.die.lit .pip {
    opacity: 1;
}

/* ---------- Hero Text ---------- */
.hero-text {
    text-align: center;
    margin-top: 40px;
    z-index: 2;
    position: relative;
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(2.2rem, 5.5vw, 4.8rem);
    color: var(--text-heading);
    letter-spacing: 0.04em;
    line-height: 1.15;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: var(--text-primary);
    letter-spacing: 0.01em;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

.hero-subtitle.visible {
    opacity: 1;
}

/* ---------- Content Area ---------- */
.content-area {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 8vh 24px 12vh;
}

/* ---------- Probability Well Modules ---------- */
.probability-well {
    position: relative;
    max-width: 640px;
    border-radius: 32px;
    padding: 0;
    margin-bottom: 2vh;
    /* Entry animation */
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out, box-shadow 500ms ease-out;
}

.probability-well.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Convex variant */
.probability-well.convex {
    background: var(--bg-secondary);
    box-shadow:
        8px 8px 16px rgba(5, 10, 30, 0.35),
        -8px -8px 16px rgba(40, 60, 110, 0.07);
}

.probability-well.convex.revealed {
    box-shadow:
        8px 8px 16px rgba(5, 10, 30, 0.7),
        -8px -8px 16px rgba(40, 60, 110, 0.15);
}

/* Concave variant */
.probability-well.concave {
    background: var(--bg-secondary);
    box-shadow:
        inset 8px 8px 16px rgba(5, 10, 30, 0.35),
        inset -8px -8px 16px rgba(40, 60, 110, 0.07);
}

.probability-well.concave.revealed {
    box-shadow:
        inset 8px 8px 16px rgba(5, 10, 30, 0.7),
        inset -8px -8px 16px rgba(40, 60, 110, 0.15);
}

/* Border animation pseudo-element */
.probability-well::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--accent-cyan);
    border-radius: 32px;
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 3;
}

.probability-well:hover::before,
.probability-well.border-visible::before {
    clip-path: inset(0 0 0 0);
}

/* Reverse animation on mouse leave (faster) */
.probability-well:not(:hover)::before {
    transition: clip-path 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Well inner content */
.well-inner {
    padding: 40px 44px;
    position: relative;
    z-index: 2;
}

.probability-well h2 {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--text-heading);
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin-bottom: 1.2em;
    text-transform: none; /* sentence case */
}

.probability-well p {
    max-width: 38em;
    margin-bottom: 1.5em;
    line-height: 1.72;
}

.probability-well p:last-child {
    margin-bottom: 0;
}

/* ---------- Vintage Image Frame ---------- */
.vintage-image-frame {
    margin: 1.5em 0;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.vintage-image {
    width: 100%;
    border-radius: 16px;
    filter: grayscale(100%) sepia(40%) saturate(60%) hue-rotate(190deg) brightness(0.3) contrast(1.2);
    transition: filter 600ms ease-out 200ms;
}

.probability-well.revealed .vintage-image {
    filter: grayscale(100%) sepia(40%) saturate(60%) hue-rotate(190deg) brightness(0.5) contrast(1.2);
}

/* ---------- Decorative Elements ---------- */
.bell-curve-decoration {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 2vh 0;
    opacity: 0.15;
}

.bell-curve-svg {
    width: clamp(160px, 25vw, 300px);
    height: auto;
}

.bell-curve-path {
    animation: bellPulse 6s ease-in-out infinite;
}

@keyframes bellPulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.2; }
}

.prob-tree-decoration {
    position: relative;
    z-index: 1;
    padding: 1vh 0;
}

.prob-tree-svg {
    width: clamp(100px, 15vw, 160px);
    height: auto;
}

/* ---------- Footer ---------- */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 6vh 24px 8vh;
}

/* Waveform visualization */
.waveform-container {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.waveform-bars {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.wave-bar {
    display: block;
    width: 1px;
    background-color: var(--accent-cyan);
    opacity: 0.2;
    border-radius: 0.5px;
    animation: waveOscillate 3s ease-in-out infinite;
    animation-delay: calc(var(--bar-index) * 125ms);
    height: 8px; /* base height, overridden by animation */
}

@keyframes waveOscillate {
    0%, 100% {
        height: 4px;
    }
    25% {
        height: 12px;
    }
    50% {
        height: 6px;
    }
    75% {
        height: 16px;
    }
}

.footer-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    color: var(--text-primary);
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    opacity: 0.5;
    margin-bottom: 8px;
}

.footer-domain {
    font-family: var(--font-heading);
    font-weight: 300;
    color: var(--text-heading);
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    opacity: 0.3;
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 768px) {
    .content-area {
        padding: 4vh 16px 8vh;
    }

    .probability-well {
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 24px;
    }

    .probability-well:nth-child(odd) {
        margin-left: 4vw !important;
    }

    .probability-well:nth-child(even) {
        margin-right: 4vw !important;
    }

    .probability-well::before {
        border-radius: 24px;
    }

    .well-inner {
        padding: 28px 24px;
    }

    #nav-pill {
        top: 16px;
        left: 16px;
        padding: 8px 16px;
    }

    .nav-links {
        gap: 12px;
        margin-left: 16px;
    }

    .constellation-svg {
        width: clamp(240px, 70vw, 340px);
    }

    .prob-tree-decoration {
        margin-left: 5vw !important;
        margin-right: auto !important;
    }

    .bell-curve-decoration {
        margin-left: 0 !important;
    }

    /* Mobile margin overrides for organic offset */
    .probability-well {
        margin-top: 2vh !important;
    }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-tint);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--shadow-light);
}

/* ---------- Selection ---------- */
::selection {
    background: rgba(74, 240, 224, 0.2);
    color: var(--text-heading);
}
