/* ============================================
   datatelomere.com — Styles
   Magazine-spread editorial / ethereal blue
   ============================================ */

/* --- Google Fonts imported in HTML --- */

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

html {
    scroll-behavior: smooth;
    overflow: hidden;
    height: 100%;
}

body {
    background: #0A1628;
    color: #C4D8E8;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.75;
    overflow: hidden;
    height: 100%;
    -webkit-font-smoothing: antialiased;
}

/* --- Scroll Container with Snap --- */
#scroll-container {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* --- Background Gradient Animation --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 30%, #132240 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, #132240 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, #0A1628 0%, #050D1A 100%);
    z-index: -2;
    animation: bgShift 60s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes bgShift {
    0% {
        background-position: 0% 0%, 100% 100%, center;
    }
    50% {
        background-position: 30% 60%, 70% 40%, center;
    }
    100% {
        background-position: 60% 20%, 40% 80%, center;
    }
}

/* --- Spread (each full-viewport page) --- */
.spread {
    position: relative;
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

/* --- Voronoi Background --- */
.voronoi-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.08;
}

.voronoi-bg svg {
    width: 100%;
    height: 100%;
}

.voronoi-bg polygon {
    fill: none;
    stroke: #7EB8D8;
    stroke-width: 0.5;
}

/* Denser mesh for early spreads, sparser for later */
#spread-5 .voronoi-bg,
#spread-6 .voronoi-bg {
    opacity: 0.03;
}

#spread-4 .voronoi-bg {
    opacity: 0.05;
}

/* --- Voronoi mesh drift animation --- */
.voronoi-bg svg {
    animation: meshDrift 120s linear infinite;
}

@keyframes meshDrift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(10px, -8px) rotate(0.5deg);
    }
    50% {
        transform: translate(-5px, 12px) rotate(-0.3deg);
    }
    75% {
        transform: translate(8px, 5px) rotate(0.4deg);
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* --- Telomere Margins --- */
.telomere-margin {
    position: absolute;
    top: 0;
    width: 40px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 20vh 6px;
    z-index: 2;
}

.telomere-margin-left {
    left: 0;
}

.telomere-margin-right {
    right: 0;
}

.telomere-bar {
    width: 100%;
    height: 12px;
    border-radius: 2px;
    transition: opacity 0.6s ease, height 0.6s ease;
}

.telomere-bar.color-a { background: #7EB8D8; }
.telomere-bar.color-b { background: #B8D4E3; }
.telomere-bar.color-c { background: #D4A86C; }
.telomere-bar.color-d { background: #5A8BA8; }

.telomere-bar.eroded {
    opacity: 0 !important;
    height: 0 !important;
    margin: 0;
}

/* --- Spread Columns (55/45 split) --- */
.spread-columns {
    display: grid;
    grid-template-columns: 55% 45%;
    width: 100%;
    height: 100%;
    padding: 0 60px;
    gap: 0;
    position: relative;
    z-index: 1;
}

.col-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 40px 60px 40px;
    position: relative;
    z-index: 2;
}

.col-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

/* Right column bleeds leftward under text */
.col-right::before {
    content: '';
    position: absolute;
    left: -30%;
    top: 0;
    width: 130%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* --- Typography --- */

/* Headlines: Zilla Slab 700, 48-80px */
.spread-title {
    font-family: 'Zilla Slab', 'Rockwell', serif;
    font-weight: 700;
    font-size: clamp(48px, 5vw, 80px);
    color: #B8D4E3;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 32px;
    text-align: left;
}

/* Title character animation (stagger) */
.spread-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

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

/* Whitespace char should not have block display issues */
.spread-title .char-space {
    display: inline-block;
    width: 0.3em;
}

/* Body text: Source Serif 4, 17-19px */
.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(17px, 1.2vw, 19px);
    font-weight: 400;
    color: #C4D8E8;
    line-height: 1.75;
    margin-bottom: 20px;
    max-width: 60ch;
}

/* Magazine convention: indent all paragraphs except first */
.body-text + .body-text {
    text-indent: 3em;
}

.body-text.first-paragraph {
    text-indent: 0;
}

.body-text.first-paragraph::first-letter {
    font-family: 'Zilla Slab', serif;
    font-size: 3.2em;
    font-weight: 700;
    float: left;
    color: #B8D4E3;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 6px;
}

/* Pull-quotes: Zilla Slab 300, 28-36px */
.pull-quote {
    position: relative;
    background: rgba(10, 22, 40, 0.6);
    padding: 24px 28px;
    margin: 28px 0;
    margin-right: -30%;
    border-left: 2px solid #7EB8D8;
    border-radius: 0 8px 8px 0;
    z-index: 3;
}

.pull-quote-text {
    font-family: 'Zilla Slab', serif;
    font-weight: 300;
    font-size: clamp(24px, 2.2vw, 36px);
    color: #E8F4FD;
    line-height: 1.6;
    display: block;
}

/* Data labels and annotations: IBM Plex Mono */
.data-annotation {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 16px;
}

.annotation-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    color: #5A8BA8;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* --- SVG Illustrations --- */
.chromosome-illustration,
.replication-fork-illustration,
.packet-timeline-illustration,
.eroded-chromosome,
.telomerase-illustration,
.dissolution-illustration {
    width: 100%;
    max-width: 400px;
    height: auto;
    opacity: 0.85;
    filter: drop-shadow(0 0 20px rgba(126, 184, 216, 0.1));
}

/* Right column illustrations bleed leftward */
.col-right svg {
    margin-left: -15%;
    opacity: 0.8;
}

/* --- Telomere Cap Tiles --- */
.telomere-caps-decoration {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
}

.cap-tile {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 400;
    color: #7EB8D8;
    background: rgba(10, 22, 40, 0.5);
    padding: 6px 10px;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(126, 184, 216, 0.3);
    letter-spacing: 0.1em;
}

/* --- Binary Telomere Strip --- */
.binary-telomere-strip {
    display: flex;
    gap: 2px;
    margin-top: 16px;
    justify-content: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: #5A8BA8;
    letter-spacing: 0.1em;
}

.binary-char {
    display: inline-block;
    width: 16px;
    text-align: center;
    transition: color 0.5s ease, transform 0.3s ease;
}

.binary-char.morphed {
    color: #D4A86C;
    transform: scale(1.1);
}

/* --- Central Gutter Helix --- */
#gutter-helix {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#helix-svg {
    width: 60px;
    height: 100%;
    opacity: 0.5;
}

.helix-strand-a {
    fill: none;
    stroke: #7EB8D8;
    stroke-width: 1.2;
}

.helix-strand-b {
    fill: none;
    stroke: #D4A86C;
    stroke-width: 1;
}

.helix-rung {
    stroke: #5A8BA8;
    stroke-width: 0.5;
    opacity: 0.4;
}

#gutter-helix:hover {
    pointer-events: auto;
}

.helix-fragment {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: #D4A86C;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    text-align: center;
}

.helix-fragment.visible {
    opacity: 0.8;
}

/* Helix unwinding effect */
.helix-strand-a.unwound {
    transform: translateX(-10px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.helix-strand-b.unwound {
    transform: translateX(10px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Continuous slow rotation */
#helix-svg {
    animation: helixRotate 30s linear infinite;
}

@keyframes helixRotate {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50px); }
}

/* --- Navigation Dots --- */
#spread-nav {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}

.nav-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(126, 184, 216, 0.2);
    border: 1.5px solid #5A8BA8;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.nav-dot:hover {
    background: rgba(126, 184, 216, 0.4);
    box-shadow: 0 0 16px rgba(126, 184, 216, 0.3);
    transform: scale(1.2);
}

.nav-dot.active {
    background: #D4A86C;
    border-color: #D4A86C;
    animation: navPulse 3s ease-in-out infinite;
}

@keyframes navPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(212, 168, 108, 0.4); }
    50% { box-shadow: 0 0 20px rgba(212, 168, 108, 0.8); }
}

/* Bioluminescent hover glow */
.nav-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(126, 184, 216, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease-out, height 0.3s ease-out;
    pointer-events: none;
}

.nav-dot:hover::after {
    width: 40px;
    height: 40px;
}

/* --- Bioluminescent Hover Effect (global) --- */
.bio-glow {
    position: fixed;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(126, 184, 216, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease-out;
    opacity: 0;
}

.bio-glow.visible {
    opacity: 1;
}

/* --- Spread-specific Styles --- */

/* Spread 1: Genesis - full vitality */
#spread-1 {
    background: radial-gradient(ellipse at 30% 40%, #132240 0%, transparent 60%),
                linear-gradient(to bottom, #0A1628, #050D1A);
}

/* Spread 2: Replication */
#spread-2 {
    background: radial-gradient(ellipse at 60% 50%, #132240 0%, transparent 55%),
                linear-gradient(to bottom, #050D1A, #0A1628);
}

/* Spread 3: Transmission */
#spread-3 {
    background: radial-gradient(ellipse at 40% 60%, rgba(19, 34, 64, 0.7) 0%, transparent 50%),
                linear-gradient(to bottom, #0A1628, #050D1A);
}

/* Spread 4: Erosion - darker */
#spread-4 {
    background: radial-gradient(ellipse at 50% 50%, rgba(19, 34, 64, 0.4) 0%, transparent 40%),
                linear-gradient(to bottom, #050D1A, #050D1A);
}

/* Spread 5: Renewal - warm glow */
#spread-5 {
    background: radial-gradient(ellipse at 60% 40%, rgba(212, 168, 108, 0.05) 0%, transparent 40%),
                radial-gradient(ellipse at 40% 60%, #132240 0%, transparent 50%),
                linear-gradient(to bottom, #050D1A, #0A1628);
}

/* Spread 6: Dissolution - near void */
#spread-6 {
    background: radial-gradient(ellipse at 50% 50%, rgba(126, 184, 216, 0.03) 0%, transparent 50%),
                linear-gradient(to bottom, #050D1A, #050D1A);
}

/* --- Scroll-linked Fade States --- */
.spread.in-view .spread-title .char {
    opacity: 1;
    transform: translateY(0);
}

/* --- Morph Transitions --- */
.spread svg {
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.spread.in-view svg {
    opacity: 0.85;
}

.spread:not(.in-view) svg {
    opacity: 0.3;
    transform: scale(0.95);
}

/* --- Pull Quote Entrance --- */
.pull-quote {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.8s ease 0.4s, transform 0.8s ease 0.4s;
}

.spread.in-view .pull-quote {
    opacity: 1;
    transform: translateX(0);
}

/* --- Body Text Fade --- */
.body-text {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.spread.in-view .body-text {
    opacity: 1;
    transform: translateY(0);
}

.spread.in-view .body-text:nth-child(2) { transition-delay: 0.1s; }
.spread.in-view .body-text:nth-child(3) { transition-delay: 0.2s; }
.spread.in-view .body-text:nth-child(4) { transition-delay: 0.3s; }
.spread.in-view .body-text:nth-child(5) { transition-delay: 0.4s; }
.spread.in-view .body-text:nth-child(6) { transition-delay: 0.5s; }

/* --- Chromosome Pair Glow --- */
.chromosome-pair {
    animation: chromoGlow 6s ease-in-out infinite alternate;
}

@keyframes chromoGlow {
    0% { filter: drop-shadow(0 0 4px rgba(126, 184, 216, 0.2)); }
    100% { filter: drop-shadow(0 0 12px rgba(126, 184, 216, 0.4)); }
}

/* --- Dissolution Particles Float --- */
.dissolution-particles circle {
    animation: particleFloat 8s ease-in-out infinite;
}

.dissolution-particles circle:nth-child(odd) {
    animation-direction: alternate-reverse;
    animation-duration: 10s;
}

.dissolution-particles circle:nth-child(3n) {
    animation-delay: -2s;
    animation-duration: 12s;
}

@keyframes particleFloat {
    0% { transform: translate(0, 0); }
    25% { transform: translate(8px, -12px); }
    50% { transform: translate(-5px, 6px); }
    75% { transform: translate(10px, 8px); }
    100% { transform: translate(0, 0); }
}

/* --- Replication Fork Pulse --- */
.replication-fork-illustration circle {
    animation: forkPulse 4s ease-in-out infinite;
}

@keyframes forkPulse {
    0%, 100% { opacity: 0.4; r: 6; }
    50% { opacity: 0.7; r: 8; }
}

/* --- Data Annotation Flicker --- */
.annotation-text {
    animation: dataFlicker 5s steps(2) infinite;
}

.annotation-text:nth-child(2) { animation-delay: 1.5s; }
.annotation-text:nth-child(3) { animation-delay: 3s; }

@keyframes dataFlicker {
    0%, 95%, 100% { opacity: 0.7; }
    96% { opacity: 0.3; }
    97% { opacity: 0.8; }
    98% { opacity: 0.4; }
}

/* --- Cap Tile Glow Animation --- */
.cap-tile {
    animation: tileGlow 4s ease-in-out infinite;
}

.cap-tile:nth-child(2n) { animation-delay: 0.5s; }
.cap-tile:nth-child(3n) { animation-delay: 1s; }

@keyframes tileGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(126, 184, 216, 0.3); }
    50% { box-shadow: 0 0 16px rgba(126, 184, 216, 0.5); }
}

/* --- Binary Morph Transition --- */
.binary-telomere-strip {
    opacity: 0.7;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .spread-columns {
        grid-template-columns: 1fr;
        padding: 0 40px;
    }

    .col-right {
        display: none;
    }

    .col-left {
        padding: 40px 20px;
    }

    .pull-quote {
        margin-right: 0;
    }

    .telomere-margin {
        width: 24px;
        padding: 20vh 4px;
    }

    #gutter-helix {
        display: none;
    }

    .spread-columns {
        padding: 0 30px;
    }

    .body-text.first-paragraph::first-letter {
        font-size: 2.4em;
    }
}

@media (max-width: 640px) {
    .spread-title {
        font-size: 36px;
    }

    .body-text {
        font-size: 16px;
    }

    .pull-quote-text {
        font-size: 20px;
    }

    .telomere-margin {
        width: 16px;
    }

    #spread-nav {
        bottom: 20px;
        right: 20px;
    }

    .nav-dot {
        width: 10px;
        height: 10px;
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(126, 184, 216, 0.3);
    color: #E8F4FD;
}

/* --- Scrollbar Styling --- */
#scroll-container::-webkit-scrollbar {
    width: 4px;
}

#scroll-container::-webkit-scrollbar-track {
    background: #050D1A;
}

#scroll-container::-webkit-scrollbar-thumb {
    background: #5A8BA8;
    border-radius: 2px;
}

#scroll-container::-webkit-scrollbar-thumb:hover {
    background: #7EB8D8;
}
