/* ============================================
   datatelomere.com — Styles
   A five-panel vertical research journal
   ============================================ */

:root {
    /* Palette */
    --parchment: #f5f0e8;
    --aubergine: #1a1423;
    --amber: #d4a04a;
    --teal: #00c9a7;
    --lavender: #8b7aa0;
    --deep-indigo: #2d2438;
    --taupe: #e8ddd0;
    --coral: #ff6b6b;
    --plum: #4a3f55;

    /* Dynamic properties (set by JS) */
    --decay: 0;
    --scroll-weight: 400;

    /* Typography */
    --font-display: 'Instrument Serif', serif;
    --font-body: 'Caveat', cursive;
    --font-data: 'Space Grotesk', sans-serif;
}

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

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--parchment);
    color: var(--aubergine);
    overflow-x: hidden;
}

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

/* ============================================
   Scroll Container
   ============================================ */
.scroll-container {
    position: relative;
    width: 100%;
}

/* ============================================
   Panels (Sections)
   ============================================ */
.panel {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.panel-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Section backgrounds - decay gradient */
.panel-0 {
    background-color: #f5f0e8;
    z-index: 5;
}
.panel-1 {
    background-color: #ede5d8;
    z-index: 4;
}
.panel-2 {
    background-color: #d8d0c5;
    z-index: 3;
}
.panel-3 {
    background-color: #4a3f55;
    z-index: 2;
}
.panel-4 {
    background-color: #2d2438;
    z-index: 1;
}

/* Panel transition states */
.panel.is-covered {
    transform: scale(0.97);
    opacity: 0.3;
}

/* ============================================
   Typography
   ============================================ */
.title {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 9vw, 7.5rem);
    color: var(--aubergine);
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 400;
    position: relative;
    z-index: 2;
}

.subtitle {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--plum);
    letter-spacing: 0.01em;
    line-height: 1.65;
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--aubergine);
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 0.8rem;
    font-weight: 400;
    position: relative;
    z-index: 2;
}

.panel-3 .section-title,
.panel-4 .section-title {
    color: var(--taupe);
}

.section-title-faded {
    opacity: 0.4;
}

.section-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--plum);
    letter-spacing: 0.01em;
    line-height: 1.65;
    text-align: center;
    max-width: 600px;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
}

.panel-3 .section-text,
.panel-4 .section-text {
    color: var(--lavender);
}

.section-text-faded {
    opacity: 0.35;
}

/* ============================================
   Helix SVGs
   ============================================ */
.helix-svg {
    width: clamp(200px, 40vw, 400px);
    height: auto;
    max-height: 50vh;
    position: relative;
    z-index: 1;
}

/* Strand draw animation */
.strand {
    animation: drawStrand 2.5s ease-out forwards;
}

@keyframes drawStrand {
    to {
        stroke-dashoffset: 0;
    }
}

.strand-a {
    animation-delay: 0.2s;
}

.strand-b {
    animation-delay: 0.5s;
}

/* ============================================
   Scroll Arrow
   ============================================ */
.scroll-arrow {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    animation: arrowBob 2s ease-in-out infinite;
    opacity: 0.6;
    z-index: 2;
}

@keyframes arrowBob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(10px); }
}

/* ============================================
   Marginalia
   ============================================ */
.marginalia {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 3;
}

.marginalia-left {
    left: 2rem;
    align-items: flex-start;
}

.marginalia-right {
    right: 2rem;
    align-items: flex-end;
    text-align: right;
}

.annotation {
    font-family: var(--font-body);
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: var(--lavender);
    line-height: 1.5;
    display: block;
    opacity: 0.8;
}

.annotation.urgent {
    color: var(--coral);
    font-weight: 600;
}

.annotation.fading {
    opacity: 0.25;
    color: var(--lavender);
}

.margin-sketch {
    opacity: 0.6;
}

/* ============================================
   Page Numbers
   ============================================ */
.page-number {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--lavender);
    opacity: 0.5;
    letter-spacing: 0.05em;
}

.panel-3 .page-number,
.panel-4 .page-number {
    color: var(--plum);
}

/* ============================================
   Section Dividers
   ============================================ */
.section-divider {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 400px;
    opacity: 0.4;
}

.divider-line {
    width: 100%;
    height: 20px;
}

/* ============================================
   Water Bubbles
   ============================================ */
.bubble-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6), rgba(0,201,167,0.08));
    box-shadow: inset 0 -4px 12px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rise var(--duration) ease-in-out var(--delay) infinite;
    opacity: 0;
}

.bubble span {
    font-family: var(--font-data);
    font-size: clamp(0.5rem, 1vw, 0.75rem);
    font-feature-settings: 'tnum';
    color: var(--teal);
    text-align: center;
    padding: 0.3em;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0.7;
    max-width: 90%;
}

.panel-3 .bubble span,
.panel-4 .bubble span {
    color: var(--coral);
    opacity: 0.5;
}

@keyframes rise {
    0% {
        transform: translateY(100vh) translateX(0);
        opacity: 0;
    }
    8% {
        opacity: 0.65;
    }
    25% {
        transform: translateY(60vh) translateX(calc(var(--drift) * 0.3));
    }
    50% {
        transform: translateY(30vh) translateX(var(--drift));
    }
    75% {
        transform: translateY(5vh) translateX(calc(var(--drift) * 0.6));
    }
    92% {
        opacity: 0.65;
    }
    100% {
        transform: translateY(-20vh) translateX(calc(var(--drift) * -0.2));
        opacity: 0;
    }
}

/* ============================================
   Final Bubble (Section 4)
   ============================================ */
.final-bubble {
    position: absolute;
    bottom: -150px;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(160px, 25vw, 220px);
    height: clamp(160px, 25vw, 220px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.45), rgba(0,201,167,0.12));
    box-shadow: inset 0 -6px 20px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: all 2s ease-out;
    z-index: 10;
}

.final-bubble.visible {
    bottom: 50%;
    transform: translateX(-50%) translateY(50%);
    opacity: 1;
}

.final-bubble span {
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--teal);
    text-align: center;
    line-height: 1.5;
}

/* ============================================
   Phosphor Grid Overlay
   ============================================ */
.phosphor-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(0,201,167,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,201,167,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: gridPulse 4s ease-in-out infinite;
}

.phosphor-grid-strong {
    background-image:
        linear-gradient(rgba(0,201,167,0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,201,167,0.07) 1px, transparent 1px);
    background-size: 30px 30px;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.03; }
    50% { opacity: 0.08; }
}

/* ============================================
   Progress Chromosome
   ============================================ */
.progress-chromosome {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60vh;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
}

.chromosome-segment {
    flex: 1;
    background-color: rgba(139,122,160,0.2);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

.chromosome-segment.active {
    background-color: var(--amber);
    box-shadow: 0 0 8px rgba(212,160,74,0.4);
}

.chromosome-segment.depleted {
    background-color: rgba(139,122,160,0.08);
}

.telomere-marks {
    position: absolute;
    top: 0;
    left: -3px;
    width: 10px;
    height: 100%;
    font-family: var(--font-data);
    font-size: 4px;
    color: var(--amber);
    writing-mode: vertical-rl;
    letter-spacing: 1px;
    opacity: 0.8;
    overflow: hidden;
    transition: opacity 0.5s ease;
}

.chromosome-segment.depleted .telomere-marks {
    opacity: 0;
}

/* ============================================
   Responsive adjustments
   ============================================ */
@media (max-width: 768px) {
    .marginalia {
        position: relative;
        top: auto;
        transform: none;
        width: 100%;
        padding: 0 1rem;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .marginalia-left,
    .marginalia-right {
        left: auto;
        right: auto;
        text-align: left;
        align-items: flex-start;
    }

    .panel-content {
        padding: 1rem;
    }

    .progress-chromosome {
        right: 4px;
    }

    .helix-svg {
        max-height: 40vh;
    }

    .annotation {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .marginalia {
        display: none;
    }

    .title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

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