/* ============================================
   datatelomere.com — Fluorescence Dark Field
   ============================================ */

/* --- Custom Properties --- */
:root {
    --bg-void: #0A0B1A;
    --bg-secondary: #0F1128;
    --bg-band-dark: #1A1F3D;
    --bg-band-light: #2A3055;
    --accent-cyan: #00E5FF;
    --accent-magenta: #E040FB;
    --accent-gold: #FFD54F;
    --text-primary: #E0F7FA;
    --text-secondary: #B0BEC5;
    --text-muted: #78909C;
    --alert-red: #E84855;
    --vitality-teal: #44BBA4;
    --nt-t: #E84855;
    --nt-a: #44BBA4;
    --nt-g: #E7BB41;
    --senescence-warm: #1A1508;
    --ticker-speed: 60s;
    --spacing-unit: 6px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-void);
    color: var(--text-secondary);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    line-height: 1.65;
    overflow-x: hidden;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0.05 0 0.9 0 0 0.04 0 0 0.8 0 0.02 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Typography --- */
.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(2rem, 6vw, 5rem);
    line-height: 1.0;
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit) * 8);
}

.section-body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
    line-height: 1.65;
    color: var(--text-secondary);
    max-width: 680px;
    margin-bottom: calc(var(--spacing-unit) * 8);
}

.section-body-centered {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.sequence-font {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    letter-spacing: 0.15em;
}

/* --- Nucleotide Colors --- */
.nt-t { color: var(--nt-t); }
.nt-a { color: var(--nt-a); }
.nt-g { color: var(--nt-g); }

/* --- Resolution Layers --- */
.resolution-layer {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding-left: 64px;
    transition: filter 0.2s ease;
}

.resolution-layer[data-layer="1"] { min-height: 100vh; }
.resolution-layer[data-layer="2"] { min-height: 120vh; }
.resolution-layer[data-layer="3"] { min-height: 150vh; }
.resolution-layer[data-layer="4"] { min-height: 100vh; }
.resolution-layer[data-layer="5"] { min-height: 100vh; }

.resolution-layer.transitioning {
    filter: blur(3px);
}

/* --- Karyotype Sidebar --- */
#karyotype-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: rgba(10, 11, 26, 0.85);
    border-right: 1px solid rgba(0, 229, 255, 0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
    padding: 12px 0;
    max-height: 90vh;
    overflow: hidden;
}

.sidebar-chromosome {
    width: 6px;
    border-radius: 3px;
    background: repeating-linear-gradient(
        to bottom,
        var(--bg-band-dark) 0px,
        var(--bg-band-dark) 2px,
        var(--bg-band-light) 2px,
        var(--bg-band-light) 4px
    );
    cursor: pointer;
    position: relative;
    transition: box-shadow 0.4s ease, opacity 0.4s ease;
    opacity: 0.4;
}

.sidebar-chromosome::before,
.sidebar-chromosome::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: var(--accent-cyan);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.sidebar-chromosome::before { top: 0; }
.sidebar-chromosome::after { bottom: 0; }

.sidebar-chromosome.active {
    opacity: 1;
    box-shadow: 0 0 8px var(--accent-cyan);
}

.sidebar-chromosome.active::before,
.sidebar-chromosome.active::after {
    opacity: 1;
    animation: telomerePulse 3s ease-in-out infinite;
}

/* --- Telomere Pulse Animation --- */
@keyframes telomerePulse {
    0%, 100% {
        opacity: 0.6;
        filter: drop-shadow(0 0 4px var(--accent-cyan));
    }
    50% {
        opacity: 1.0;
        filter: drop-shadow(0 0 10px var(--accent-cyan));
    }
}

/* ============================================
   LAYER 1: Genome Overview
   ============================================ */
#layer-genome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
    padding-top: calc(var(--spacing-unit) * 16);
    padding-bottom: calc(var(--spacing-unit) * 16);
}

.genome-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px 18px;
    max-width: 700px;
    width: 90%;
    margin: 0 auto calc(var(--spacing-unit) * 12);
    position: relative;
    z-index: 2;
}

.chromosome-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.chromosome-svg-small {
    width: 100%;
    height: auto;
    will-change: opacity, filter;
}

.chromosome-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chromosome-cell:hover .chromosome-label {
    opacity: 1;
}

.chr-body {
    fill: none;
    stroke: none;
}

.chr-band {
    opacity: 0.9;
}

.chr-telomere-cap {
    fill: var(--accent-cyan);
    filter: drop-shadow(0 0 6px var(--accent-cyan));
    animation: telomerePulse 3s ease-in-out infinite;
}

.chromosome-cell:nth-child(even) .chr-telomere-cap {
    animation-delay: -1.5s;
}

/* Domain lockup */
.domain-lockup {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 8vw, 7rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
    line-height: 1.0;
    margin-bottom: calc(var(--spacing-unit) * 4);
    text-align: center;
}

.domain-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.domain-letter.revealed {
    opacity: 1;
    transform: translateY(0);
}

.layer-subtitle {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease 0.6s;
}

.layer-subtitle.revealed {
    opacity: 1;
}

/* ============================================
   HELIX DIVIDERS
   ============================================ */
.helix-divider {
    position: relative;
    width: 100%;
    height: 120px;
    margin-left: 64px;
    overflow: hidden;
}

.helix-svg {
    width: calc(100% - 64px);
    height: 100%;
}

.helix-strand {
    fill: none;
    stroke: var(--accent-cyan);
    stroke-width: 2;
    stroke-opacity: 0.4;
}

.strand-2 {
    stroke-opacity: 0.3;
}

.rung {
    stroke-width: 1.5;
    stroke-opacity: 0.3;
}

.rung-magenta { stroke: var(--accent-magenta); }
.rung-gold { stroke: var(--accent-gold); }

/* ============================================
   LAYER 2: Chromosome Focus
   ============================================ */
#layer-chromosome {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
}

.chromosome-focus-container {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 16);
    max-width: 1100px;
    width: 90%;
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 16) 0;
    position: relative;
    z-index: 2;
}

.chromosome-focus-wrapper {
    position: relative;
    flex-shrink: 0;
}

.focused-chromosome-svg {
    width: 120px;
    height: 600px;
}

.focused-chr-band {
    transition: opacity 0.4s ease;
}

.focused-chr-telomere {
    fill: var(--accent-cyan);
    filter: drop-shadow(0 0 8px var(--accent-cyan));
    animation: telomerePulse 3s ease-in-out infinite;
}

.focused-chr-centromere {
    fill: var(--bg-void);
}

.locus-labels {
    position: absolute;
    top: 0;
    left: 130px;
    width: 180px;
    height: 100%;
    pointer-events: none;
}

.locus-label {
    position: absolute;
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.locus-label.visible {
    opacity: 1;
    transform: translateX(0);
}

.chromosome-info {
    max-width: 500px;
}

.telomere-callout {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
    margin-top: calc(var(--spacing-unit) * 4);
}

.callout-marker {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.telomere-p {
    background: rgba(0, 229, 255, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.telomere-q {
    background: rgba(0, 229, 255, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.callout-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: calc(var(--spacing-unit) * 2);
    border-left: 2px solid rgba(0, 229, 255, 0.2);
}

/* ============================================
   LAYER 3: Telomere Structure / Shelterin
   ============================================ */
#layer-telomere {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
}

.telomere-structure-container {
    max-width: 1000px;
    width: 90%;
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 16) 0;
    position: relative;
    z-index: 2;
    text-align: center;
}

.shelterin-diagram {
    position: relative;
    margin: calc(var(--spacing-unit) * 8) auto;
    max-width: 900px;
}

.shelterin-svg {
    width: 100%;
    height: auto;
}

.dna-strand {
    fill: none;
    stroke: var(--accent-cyan);
    stroke-width: 3;
    stroke-opacity: 0.35;
}

.ss-strand {
    stroke-dasharray: 8 6;
    stroke-opacity: 0.25;
}

.tloop-strand {
    stroke-opacity: 0.3;
}

.shelterin-protein {
    cursor: pointer;
    transition: filter 0.3s ease, opacity 0.3s ease;
    opacity: 0.85;
}

#prot-trf1 { fill: var(--accent-cyan); filter: drop-shadow(0 0 4px rgba(0, 229, 255, 0.5)); }
#prot-trf2 { fill: var(--accent-magenta); filter: drop-shadow(0 0 4px rgba(224, 64, 251, 0.5)); }
#prot-tin2 { fill: var(--vitality-teal); filter: drop-shadow(0 0 4px rgba(68, 187, 164, 0.5)); }
#prot-tpp1 { fill: var(--text-secondary); filter: drop-shadow(0 0 4px rgba(176, 190, 197, 0.5)); }
#prot-pot1 { fill: var(--accent-gold); filter: drop-shadow(0 0 4px rgba(255, 213, 79, 0.5)); }
#prot-rap1 { fill: var(--alert-red); filter: drop-shadow(0 0 4px rgba(232, 72, 85, 0.5)); }

.shelterin-protein:hover {
    opacity: 1;
    filter: drop-shadow(0 0 12px currentColor) brightness(1.2);
}

.protein-label {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    fill: var(--text-primary);
    text-anchor: middle;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.protein-tooltip {
    position: absolute;
    background: rgba(15, 17, 40, 0.95);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 6px;
    padding: 12px 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 10;
    max-width: 280px;
    backdrop-filter: blur(8px);
}

.protein-tooltip.visible {
    opacity: 1;
}

.tooltip-name {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tooltip-desc {
    display: block;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tloop-annotation {
    margin-top: calc(var(--spacing-unit) * 8);
    text-align: center;
}

.annotation-label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.annotation-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.65;
}

/* ============================================
   LAYER 4: Sequence Level
   ============================================ */
#layer-sequence {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-void);
}

.sequence-container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 16) 0;
    position: relative;
    z-index: 2;
}

.sequence-container .section-title,
.sequence-container .section-body {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* Electropherogram canvas */
.electropherogram {
    display: block;
    width: 100%;
    height: 200px;
    margin-bottom: calc(var(--spacing-unit) * 4);
    opacity: 0.4;
}

/* Sequence Ticker */
.sequence-ticker-wrapper {
    overflow: hidden;
    width: 100%;
    margin-bottom: calc(var(--spacing-unit) * 12);
    padding: calc(var(--spacing-unit) * 4) 0;
    border-top: 1px solid rgba(0, 229, 255, 0.1);
    border-bottom: 1px solid rgba(0, 229, 255, 0.1);
}

.sequence-ticker {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll var(--ticker-speed) linear infinite;
    will-change: transform;
}

.sequence-ticker .nt {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.15em;
    display: inline-block;
    padding: 0 1px;
}

@keyframes tickerScroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Data Panels */
.data-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 8);
}

.data-panel {
    background: rgba(15, 17, 40, 0.6);
    border: 1px solid rgba(0, 229, 255, 0.12);
    border-radius: 8px;
    padding: calc(var(--spacing-unit) * 4);
}

.panel-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.scatter-plot-canvas {
    display: block;
    width: 100%;
    height: 200px;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.panel-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-healthy .legend-dot { background: var(--vitality-teal); }
.legend-short .legend-dot { background: var(--alert-red); }

.legend-line {
    width: 16px;
    height: 2px;
    display: inline-block;
    background: var(--accent-gold);
}

.stat-readout {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 3);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: calc(var(--spacing-unit) * 2);
    border-bottom: 1px solid rgba(0, 229, 255, 0.06);
}

.stat-label {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-primary);
    letter-spacing: 0.1em;
}

/* ============================================
   LAYER 5: Senescence Horizon
   ============================================ */
#layer-senescence {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, var(--bg-void), var(--senescence-warm));
}

.senescence-container {
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 24) 0;
    position: relative;
    z-index: 2;
    text-align: center;
}

.senescence-content {
    transition: filter 1s ease;
}

.senescence-title {
    transition: opacity 1s ease;
}

.senescence-text {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    transition: opacity 1s ease;
}

.senescence-closing {
    margin-top: calc(var(--spacing-unit) * 12);
    margin-bottom: calc(var(--spacing-unit) * 12);
}

.closing-statement {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.2em;
    color: var(--text-primary);
    text-transform: uppercase;
    line-height: 1.3;
}

.senescence-sequence {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: calc(var(--spacing-unit) * 8);
}

.fading-repeat {
    font-family: 'Fira Code', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.15em;
}

.dim-1 { opacity: 0.9; }
.dim-2 { opacity: 0.65; }
.dim-3 { opacity: 0.4; }
.dim-4 { opacity: 0.2; }
.dim-5 { opacity: 0.08; }

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
.resolution-layer {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease, filter 0.2s ease;
}

.resolution-layer.in-view {
    opacity: 1;
    transform: translateY(0);
}

.helix-divider {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.helix-divider.in-view {
    opacity: 1;
}

/* ============================================
   RESPONSIVE: Mobile < 768px
   ============================================ */
@media (max-width: 768px) {
    #karyotype-sidebar {
        width: 4px;
        border-right: none;
        background: rgba(10, 11, 26, 0.6);
    }

    .sidebar-inner {
        gap: 2px;
        padding: 8px 0;
    }

    .sidebar-chromosome {
        width: 4px;
        border-radius: 2px;
    }

    .resolution-layer {
        padding-left: 12px;
    }

    .helix-divider {
        margin-left: 12px;
    }

    .helix-svg {
        width: calc(100% - 12px);
    }

    .genome-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px 12px;
    }

    .domain-lockup {
        font-size: clamp(1.8rem, 10vw, 4rem);
    }

    .chromosome-focus-container {
        flex-direction: column;
        gap: calc(var(--spacing-unit) * 8);
    }

    .focused-chromosome-svg {
        width: 80px;
        height: 400px;
    }

    .locus-labels {
        left: 90px;
    }

    .data-panels {
        grid-template-columns: 1fr;
    }

    .sequence-ticker .nt {
        font-size: 0.7rem;
    }

    .senescence-sequence {
        flex-wrap: wrap;
        gap: 8px;
    }

    .fading-repeat {
        font-size: 0.9rem;
    }

    .shelterin-svg {
        height: 300px;
    }
}

/* ============================================
   RESPONSIVE: Tablet 769-1024px
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .genome-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .chromosome-focus-container {
        gap: calc(var(--spacing-unit) * 8);
    }
}
