/* ===================================================
   telomere.dev — Fluorescence Microscopy HUD
   =================================================== */

/* --- CSS Custom Properties --- */
:root {
    --telomere-violet: #7e22ce;
    --replication-emerald: #059669;
    --senescence-ruby: #be123c;
    --vitality-sapphire: #2563eb;
    --shortening-amber: #d97706;
    --dark-field: #0b0c10;
    --panel-glass: rgba(18, 20, 28, 0.78);
    --text-primary: #e2e4e9;
    --text-muted: #71717a;
    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --font-display: 'Recursive', monospace;
    --font-body: 'Nunito Sans', sans-serif;
}

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

html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body.dark-field {
    background: var(--dark-field);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* --- HUD Data Font --- */
.hud-data {
    font-family: var(--font-display);
    font-variation-settings: 'CASL' 0, 'MONO' 1, 'wght' 400;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* --- Particles --- */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    animation: drift linear infinite;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(40px, -80px) scale(1.1);
    }
    50% {
        transform: translate(-30px, -160px) scale(0.9);
    }
    75% {
        transform: translate(20px, -240px) scale(1.05);
    }
    100% {
        transform: translate(-10px, -320px) scale(1);
    }
}

/* --- HUD Navigation --- */
.hud-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    background: linear-gradient(180deg, rgba(11,12,16,0.8) 0%, transparent 100%);
}

.hud-nav__logo {
    font-family: var(--font-display);
    font-variation-settings: 'CASL' 0.5, 'MONO' 0.3, 'wght' 700;
    font-size: 1rem;
    color: var(--telomere-violet);
    letter-spacing: -0.02em;
}

.hud-nav__dots {
    display: flex;
    gap: 12px;
    align-items: center;
}

.hud-nav__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s var(--elastic);
    padding: 0;
}

.hud-nav__dot.active {
    background: var(--telomere-violet);
    border-color: var(--telomere-violet);
    transform: scale(1.3);
}

.hud-nav__dot.pulse {
    animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.hud-nav__label {
    min-width: 100px;
    text-align: right;
}

/* --- Telomere Gauge --- */
.telomere-gauge {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.telomere-gauge__track {
    width: 4px;
    height: 200px;
    background: rgba(113, 113, 122, 0.2);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.telomere-gauge__fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--replication-emerald);
    border-radius: 2px;
    transition: height 0.4s var(--elastic), background-color 0.6s ease;
    will-change: height;
}

.telomere-gauge__fill.pulse-ruby {
    animation: pulseRuby 1.2s ease-in-out infinite;
}

@keyframes pulseRuby {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.telomere-gauge__label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

/* --- Observation Field --- */
.observation-field {
    position: relative;
    z-index: 1;
}

/* --- Cycle Sections --- */
.cycle {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- Bio Canvas --- */
.bio-canvas {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.branch-svg {
    position: absolute;
    width: 100%;
    height: 100%;
}

.branch-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-out;
}

.cycle.in-view .branch-path {
    stroke-dashoffset: 0;
}

.cycle.in-view .branch-path:nth-child(1) { transition-delay: 0s; }
.cycle.in-view .branch-path:nth-child(2) { transition-delay: 0.4s; }
.cycle.in-view .branch-path:nth-child(3) { transition-delay: 0.8s; }
.cycle.in-view .branch-path:nth-child(4) { transition-delay: 1.2s; }
.cycle.in-view .branch-path:nth-child(5) { transition-delay: 1.6s; }
.cycle.in-view .branch-path:nth-child(6) { transition-delay: 2.0s; }
.cycle.in-view .branch-path:nth-child(7) { transition-delay: 2.4s; }

.chromosome-svg {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 20px rgba(126, 34, 206, 0.4));
}

.chromosome-svg--short {
    filter: drop-shadow(0 0 15px rgba(217, 119, 6, 0.4));
}

.chromosome-svg--critical {
    filter: drop-shadow(0 0 15px rgba(190, 18, 60, 0.5));
    animation: criticalPulse 2s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% { filter: drop-shadow(0 0 15px rgba(190, 18, 60, 0.5)); }
    50% { filter: drop-shadow(0 0 30px rgba(190, 18, 60, 0.8)); }
}

.tloop-svg {
    position: relative;
    z-index: 1;
    animation: tloopRotate 90s linear infinite;
    filter: drop-shadow(0 0 12px rgba(126, 34, 206, 0.5));
}

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

.fork-svg {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(5, 150, 105, 0.4));
}

/* --- HUD Panels --- */
.hud-panel {
    position: absolute;
    max-width: 420px;
    padding: 28px 32px;
    background: var(--panel-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 228, 233, 0.15);
    border-radius: 4px;
    z-index: 10;
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.6s var(--elastic), opacity 0.5s ease, backdrop-filter 0.3s var(--elastic), border-color 0.3s ease;
}

.hud-panel:hover {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(226, 228, 233, 0.4);
}

.cycle.in-view .hud-panel {
    transform: scale(1);
    opacity: 1;
}

.hud-panel--top-left {
    top: 15%;
    left: 8%;
}

.hud-panel--top-right {
    top: 15%;
    right: 8%;
}

.hud-panel--bottom-left {
    bottom: 15%;
    left: 8%;
}

.hud-panel--bottom-right {
    bottom: 15%;
    right: 8%;
}

.hud-panel--center {
    position: relative;
    top: auto;
    left: auto;
}

.hud-panel__title {
    font-family: var(--font-display);
    font-variation-settings: 'CASL' 0.5, 'MONO' 0.3, 'wght' 800;
    font-size: clamp(2.8rem, 5vw, 5.5rem);
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.hud-panel__text {
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease 0.2s, transform 0.5s var(--elastic) 0.2s;
}

.cycle.in-view .hud-panel__text {
    opacity: 1;
    transform: translateY(0);
}

.hud-panel__tag {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid rgba(126, 34, 206, 0.4);
    border-radius: 2px;
    color: var(--telomere-violet);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease 0.4s, transform 0.4s var(--elastic) 0.4s;
}

.cycle.in-view .hud-panel__tag {
    opacity: 1;
    transform: translateY(0);
}

/* --- Senescence / Renewal --- */
.cycle--senescence .branch-svg--fade {
    transition: opacity 2s ease;
}

.cycle--senescence.in-view .branch-svg--fade .branch-group {
    opacity: 0 !important;
    transition: opacity 2s ease;
}

.cycle--senescence .branch-svg--emerge .branch-group {
    transition: opacity 2s ease 1s;
}

.cycle--senescence.in-view .branch-svg--emerge .branch-group {
    opacity: 0.35 !important;
}

/* --- Replication Fork Divider between sections (pseudo) --- */

/* --- Responsive --- */
@media (max-width: 768px) {
    .hud-panel {
        max-width: 90%;
        padding: 20px 24px;
    }

    .hud-panel--top-left,
    .hud-panel--top-right,
    .hud-panel--bottom-left,
    .hud-panel--bottom-right {
        top: auto;
        bottom: 10%;
        left: 5%;
        right: 5%;
    }

    .hud-panel__title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .telomere-gauge {
        left: 8px;
    }

    .telomere-gauge__track {
        height: 120px;
    }
}
