/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --obsidian: #1a1520;
    --manuscript: #2a2233;
    --crimson: #8b2252;
    --plum: #6b3a6e;
    --rose: #c4577a;
    --ivory: #f0e6d8;
    --folio: #a89b8c;
    --gold: #d4b896;
}

html { scroll-behavior: smooth; }

body {
    background: var(--obsidian);
    color: var(--ivory);
    font-family: 'Lora', serif;
    font-weight: 400;
    line-height: 1.72;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ivory);
}

h1 {
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin-bottom: 0.8rem;
    color: var(--rose);
}

.small-caps { font-variant: small-caps; }

.meta-text {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--folio);
}

.decorative-numeral {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(4rem, 10vw, 9rem);
    color: var(--crimson);
    display: block;
    line-height: 1;
    margin-bottom: 0.5rem;
}

/* === ORGANIC BLOBS === */
#blob-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.06;
}

.blob-1 {
    width: 500px; height: 500px;
    background: var(--crimson);
    top: 10%; left: -5%;
    animation: drift1 45s ease-in-out infinite alternate;
}
.blob-2 {
    width: 400px; height: 400px;
    background: var(--plum);
    top: 40%; right: -10%;
    animation: drift2 62s ease-in-out infinite alternate;
}
.blob-3 {
    width: 350px; height: 350px;
    background: var(--crimson);
    bottom: 10%; left: 30%;
    animation: drift3 78s ease-in-out infinite alternate;
}
.blob-4 {
    width: 450px; height: 450px;
    background: var(--plum);
    top: 60%; left: 60%;
    animation: drift4 53s ease-in-out infinite alternate;
}

@keyframes drift1 { to { transform: translate(200px, 150px); } }
@keyframes drift2 { to { transform: translate(-180px, -120px); } }
@keyframes drift3 { to { transform: translate(120px, -200px); } }
@keyframes drift4 { to { transform: translate(-250px, 100px); } }

/* === TTAGGG BACKGROUND === */
#ttaggg-bg {
    position: fixed;
    top: 0; left: 0;
    width: 300%;
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: var(--folio);
    opacity: 0.04;
    letter-spacing: 0.3em;
    word-spacing: 1em;
    line-height: 2.5;
    white-space: nowrap;
    pointer-events: none;
    z-index: -1;
    animation: ttaggg-scroll 120s linear infinite;
}

@keyframes ttaggg-scroll {
    to { transform: translateX(-50%); }
}

/* === HEX NAVIGATION === */
#hex-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 100;
    opacity: 0;
    transition: opacity 500ms ease;
}

#hex-nav.visible { opacity: 1; }

.nav-dot {
    width: 16px;
    height: 18px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 300ms ease;
}

.nav-dot::before {
    content: '';
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--folio);
    opacity: 0.3;
    transition: all 300ms ease;
}

.nav-dot.active::before {
    background: var(--crimson);
    opacity: 1;
}

/* === HERO === */
#hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#telomere-typing {
    font-family: 'DM Mono', monospace;
    font-size: 1.4rem;
    letter-spacing: 0.05em;
    color: var(--rose);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

#telomere-typing.faded {
    opacity: 0.15;
    transform: translate(-50%, -80%);
    transition: all 1s ease;
}

#hero-hex-container {
    position: relative;
    width: 400px;
    height: 460px;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hero-hex-container.visible {
    opacity: 1;
    transition: opacity 800ms ease;
}

#hero-hex-svg {
    position: absolute;
    top: 0;
    left: 0;
}

.hero-hex-outline {
    stroke-dasharray: 1840;
    stroke-dashoffset: 1840;
    transition: stroke-dashoffset 1.2s ease;
}

.hero-hex-outline.drawn {
    stroke-dashoffset: 0;
}

#hero-title {
    text-align: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 800ms ease 0.3s;
}

#hero-title.visible { opacity: 1; }

.hero-subtitle {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--folio);
    margin-top: 1rem;
}

/* Satellite Hexes */
#satellite-hexes {
    position: absolute;
    width: 500px;
    height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.sat-hex {
    position: absolute;
    width: 50px;
    height: 58px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--manuscript);
    display: flex;
    align-items: center;
    justify-content: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-220px) rotate(calc(-1 * var(--angle))) scale(0);
    opacity: 0;
    transition: all 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sat-hex.visible {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-220px) rotate(calc(-1 * var(--angle))) scale(1);
}

.sat-hex span {
    font-family: 'DM Mono', monospace;
    font-size: 0.9rem;
    color: var(--gold);
}

/* === CHAPTER BREAKS === */
.chapter-break {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 2rem 0;
}

.chapter-line {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 1px;
    background: var(--gold);
    opacity: 0.2;
}

.chapter-hex {
    width: 12px;
    height: 14px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--gold);
    opacity: 0.4;
    position: absolute;
    z-index: 1;
}

.chapter-label {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    color: var(--folio);
    background: var(--obsidian);
    padding: 0 2rem;
    position: relative;
    z-index: 2;
}

/* === HEX GRID === */
.hex-section {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem 60px;
}

.hex-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: -30px;
}

.hex-row-even {
    padding: 0 100px;
}

.hex-cell {
    width: 380px;
    height: 420px;
    flex-shrink: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    position: relative;
    will-change: transform;
    transition: transform 700ms ease-out, box-shadow 700ms ease-out;
}

.hex-cell-wide {
    width: 500px;
    height: 540px;
}

.hex-inner {
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 40px;
}

.marble-bg {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(212,184,150,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(107,58,110,0.06) 0%, transparent 40%),
        linear-gradient(135deg, rgba(42,34,51,0.9) 0%, rgba(26,21,32,1) 100%);
    filter: url(#marble-noise);
    transition: all 3s ease;
}

.marble-bg:hover {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(212,184,150,0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(107,58,110,0.15) 0%, transparent 40%),
        linear-gradient(135deg, rgba(42,34,51,0.9) 0%, rgba(26,21,32,1) 100%);
    transform: translate(2px, -2px);
}

.hex-inner p {
    font-size: 0.95rem;
    max-width: 42ch;
    color: var(--ivory);
}

/* Pulse animation for hex cells */
.hex-cell.pulse {
    animation: hex-pulse 700ms ease-out;
}

@keyframes hex-pulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
    40% { transform: scale(1.02); filter: drop-shadow(0 0 20px rgba(196,87,122,0.4)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
    .hex-cell { width: 300px; height: 340px; }
    .hex-inner { padding: 60px 30px; }
    .hex-row-even { padding: 0 50px; }
}

@media (max-width: 768px) {
    #hex-nav { display: none; }
    .hex-section { padding: 1rem 20px; }
    .hex-row, .hex-row-even {
        flex-direction: column;
        align-items: center;
        padding: 0;
        margin-bottom: 0;
    }
    .hex-cell { width: 90vw; max-width: 380px; height: 400px; }
    .hex-cell-wide { width: 90vw; max-width: 500px; }
    .hex-row { gap: 20px; }
    #hero-hex-container { width: 280px; height: 322px; }
    #hero-hex-svg { width: 280px; height: 322px; }
    #satellite-hexes { width: 350px; height: 350px; }
    .sat-hex {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-150px) rotate(calc(-1 * var(--angle))) scale(0);
    }
    .sat-hex.visible {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-150px) rotate(calc(-1 * var(--angle))) scale(1);
    }
}
