/* ============================================
   telomere.dev — Ethereal Chrono-Biology
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-void: #050508;
    --midnight-indigo: #0a0e24;
    --twilight-navy: #0e1430;
    --telomere-blue: #6ec8f5;
    --strand-silver: #c4d4e0;
    --sequence-teal: #3d7ca8;
    --erosion-amber: #d4a054;
    --senescence-rose: #8c4a6e;

    --font-primary: 'Space Grotesk', sans-serif;
    --font-display: 'Playfair Display', serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-void);
    color: var(--strand-silver);
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: conic-gradient(var(--telomere-blue) 0deg, rgba(110, 200, 245, 0.15) 0deg);
    border: 1px solid rgba(110, 200, 245, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s ease;
}

#scroll-progress:hover {
    transform: scale(1.5);
}

/* --- Divisions (Sections) --- */
.division {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.division-content {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

/* --- Division 0: Hero --- */
#division-0 {
    background: var(--deep-void);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.hero-container {
    text-align: center;
    width: 90%;
    max-width: 1000px;
    position: relative;
}

#hero-svg {
    width: 100%;
    height: auto;
    display: block;
}

#hero-svg text {
    fill: var(--strand-silver);
}

#ttaggg-grid text,
#ttaggg-grid-reprise text {
    font-family: var(--font-mono);
    font-size: 6px;
    fill: var(--sequence-teal);
}

.hero-suffix {
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--strand-silver);
    opacity: 0.6;
    margin-top: -0.5rem;
    letter-spacing: 0.15em;
}

.hero-container:hover #ttaggg-grid text,
.hero-container:hover #ttaggg-grid-reprise text {
    text-shadow: 0 0 6px rgba(110, 200, 245, 0.5);
}

/* --- Division 1: The First Cut --- */
#division-1 {
    background: var(--deep-void);
    transition: background 2s ease;
}

#division-1.bg-transition {
    background: var(--midnight-indigo);
}

#typewriter-text {
    min-height: 8em;
    margin-bottom: 3rem;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--telomere-blue);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Division 2: Erosion --- */
#division-2 {
    background: var(--midnight-indigo);
}

.erosion-block {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    margin-bottom: 1rem;
}

.erosion-block.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Luminous Threads --- */
.luminous-thread {
    height: 1px;
    background: var(--telomere-blue);
    box-shadow: 0 0 8px 2px rgba(110, 200, 245, 0.4);
    margin: 3rem auto;
    position: relative;
    overflow: hidden;
}

.thread-full {
    width: 100%;
}

.thread-shrinking[data-thread="85"] {
    width: 85%;
    background: linear-gradient(90deg, var(--telomere-blue), var(--senescence-rose));
    box-shadow: 0 0 8px 2px rgba(140, 74, 110, 0.3);
}

.thread-shrinking[data-thread="72"] {
    width: 72%;
    background: linear-gradient(90deg, var(--senescence-rose), var(--senescence-rose));
    box-shadow: 0 0 8px 2px rgba(140, 74, 110, 0.35);
}

.thread-shrinking[data-thread="61"] {
    width: 61%;
    background: linear-gradient(90deg, var(--senescence-rose), var(--erosion-amber));
    box-shadow: 0 0 8px 2px rgba(212, 160, 84, 0.3);
}

.thread-shrinking[data-thread="52"] {
    width: 52%;
    background: var(--senescence-rose);
    box-shadow: 0 0 8px 2px rgba(140, 74, 110, 0.4);
}

.thread-minimal {
    width: 20%;
    background: var(--erosion-amber);
    box-shadow: 0 0 8px 2px rgba(212, 160, 84, 0.4);
}

.thread-renewed {
    width: 100%;
    animation: thread-pulse 2s ease-in-out infinite;
}

@keyframes thread-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Thread traveling spot */
.thread-spot {
    position: absolute;
    top: -3px;
    left: 0;
    width: 30px;
    height: 7px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(110, 200, 245, 0.9) 0%, transparent 70%);
    animation: travel-spot 4s linear infinite;
}

@keyframes travel-spot {
    0% { left: -30px; }
    100% { left: 100%; }
}

/* --- Division 3: Hayflick Limit --- */
#division-3 {
    background: var(--midnight-indigo);
    min-height: 100vh;
}

.hayflick-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    position: relative;
}

.pulse-rings-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -65%);
    width: min(80vw, 500px);
    height: min(80vw, 500px);
    pointer-events: none;
}

.pulse-rings {
    width: 100%;
    height: 100%;
}

.pulse-ring {
    stroke: var(--erosion-amber);
    stroke-width: 1;
    fill: none;
    opacity: 0;
    transform-origin: 200px 200px;
    animation: pulse-expand 3s ease-out infinite;
}

@keyframes pulse-expand {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.hayflick-number {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(8rem, 25vw, 20rem);
    color: var(--erosion-amber);
    line-height: 1;
    animation: hayflick-breathe 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

@keyframes hayflick-breathe {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
}

.hayflick-caption {
    max-width: 480px;
    margin-top: 2rem;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    opacity: 0.7;
    position: relative;
    z-index: 2;
}

/* --- Division 4: Renewal --- */
#division-4 {
    background: var(--twilight-navy);
}

.renewal-block {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
    margin-bottom: 2.5rem;
}

.renewal-block.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Hero Reprise --- */
.hero-reprise {
    text-align: center;
    margin-top: 6rem;
    padding-bottom: 4rem;
}

#hero-svg-reprise {
    width: 100%;
    max-width: 900px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.reprise-suffix {
    opacity: 0.8;
}

/* Letter stagger animation for reprise */
.hero-reprise .letter-fade {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.hero-reprise .letter-fade.visible {
    opacity: 1;
}

/* --- TTAGGG Oscillation --- */
@keyframes ttaggg-oscillate {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* --- Body Text Styles --- */
.body-text {
    color: var(--strand-silver);
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .division-content {
        padding: 3rem 1.25rem;
    }

    .hero-container {
        width: 95%;
    }

    .hayflick-center {
        padding: 2rem 1rem;
    }

    .pulse-rings-container {
        width: 90vw;
        height: 90vw;
    }
}

@media (max-width: 480px) {
    .hero-suffix {
        font-size: 1.2rem;
    }

    .division-content {
        padding: 2rem 1rem;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(110, 200, 245, 0.25);
    color: var(--strand-silver);
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--deep-void);
}

::-webkit-scrollbar-thumb {
    background: var(--sequence-teal);
    border-radius: 2px;
}
