/* ===========================================
   HHASSL.com - Candlelit Narrative Experience
   =========================================== */

/* --- CSS Custom Properties --- */
:root {
    --candle-core: #f5a623;
    --molten-amber: #c47d10;
    --flame-blue: #2d5fa1;
    --deep-indigo: #0b1628;
    --parchment: #fdf6e3;
    --ash-gray: #8a9bae;
    --ember-red: #e85d3a;
    --candle-halo: #ffe4a1;
}

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

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

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.8;
    color: var(--parchment);
    background-color: var(--deep-indigo);
    overflow-x: hidden;
    transition: background-color 0.8s ease;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    top: 0;
    right: 16px;
    width: 4px;
    height: 100vh;
    z-index: 1000;
    pointer-events: none;
}

#progress-svg {
    width: 100%;
    height: 100%;
}

#progress-line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.1s linear;
}

.progress-waypoint {
    position: absolute;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--ember-red);
    transform: translate(50%, -50%) scale(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-waypoint.active {
    transform: translate(50%, -50%) scale(1);
    animation: waypoint-pulse 2s ease-in-out infinite;
}

@keyframes waypoint-pulse {
    0%, 100% { transform: translate(50%, -50%) scale(1); }
    50% { transform: translate(50%, -50%) scale(1.4); }
}

/* --- Chapter Navigation Dots --- */
#chapter-nav {
    position: fixed;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 999;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--ash-gray);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.nav-dot:hover {
    border-color: var(--candle-core);
    background-color: rgba(245, 166, 35, 0.3);
}

.nav-dot.active {
    border-color: var(--candle-core);
    background-color: var(--candle-core);
    box-shadow: 0 0 8px rgba(245, 166, 35, 0.5);
}

/* --- Chapter Base Styles --- */
.chapter {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    width: 100%;
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.layer-bg {
    z-index: 1;
}

.layer-mid {
    z-index: 2;
    pointer-events: none;
}

.layer-fg {
    position: relative;
    z-index: 3;
}

.chapter-content {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(2rem, 4vw, 4rem);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* --- Ambient Glow Effects --- */
.ambient-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.glow-indigo {
    background: radial-gradient(ellipse at 50% 60%, rgba(45, 95, 161, 0.15) 0%, transparent 70%);
}

.glow-warm {
    background: radial-gradient(ellipse at 50% 50%, rgba(255, 228, 161, 0.12) 0%, transparent 65%);
}

.glow-parchment {
    background: radial-gradient(ellipse at 50% 40%, rgba(245, 166, 35, 0.08) 0%, transparent 60%);
}

.glow-blue {
    background: radial-gradient(ellipse at 50% 50%, rgba(45, 95, 161, 0.12) 0%, transparent 65%);
}

.glow-ember {
    background: radial-gradient(ellipse at 50% 70%, rgba(232, 93, 58, 0.1) 0%, transparent 60%);
}

/* --- Light Pool Effect (pseudo-element behind content) --- */
.warmth-card::before,
.workshop-text::before,
.path-label::before,
.ember-text::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(ellipse at center, rgba(255, 228, 161, 0.25) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* --- Floating Teardrops --- */
.floating-teardrops {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.teardrop {
    animation: teardrop-float 8s ease-in-out infinite;
}

.td-1 { animation-delay: 0s; animation-duration: 7s; }
.td-2 { animation-delay: 1.2s; animation-duration: 9s; }
.td-3 { animation-delay: 0.6s; animation-duration: 8s; }
.td-4 { animation-delay: 2.0s; animation-duration: 7.5s; }
.td-5 { animation-delay: 0.8s; animation-duration: 8.5s; }
.td-6 { animation-delay: 1.5s; animation-duration: 9.5s; }
.td-7 { animation-delay: 2.2s; animation-duration: 7.2s; }
.td-8 { animation-delay: 0.3s; animation-duration: 8.8s; }

@keyframes teardrop-float {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0.3;
    }
    25% {
        transform: translateY(-120px) translateX(15px);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-250px) translateX(-10px);
        opacity: 0.5;
    }
    75% {
        transform: translateY(-380px) translateX(12px);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-520px) translateX(0);
        opacity: 0.3;
    }
}

/* --- SVG Path-Draw System --- */
.path-draw {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.path-draw.visible {
    stroke-dashoffset: 0;
}

/* --- Wax Drip Dividers --- */
.wax-drip-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 10;
}

/* --- Smoke Wisps --- */
.smoke-wisps {
    position: absolute;
    width: 200px;
    height: 400px;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 1s ease;
}

.smoke-wisps.active {
    opacity: 1;
}

.smoke-wisp {
    animation: smoke-drift 4s ease-in-out infinite alternate;
}

.wisp-1 { animation-delay: 0s; }
.wisp-2 { animation-delay: 0.5s; }
.wisp-3 { animation-delay: 0.3s; }
.wisp-4 { animation-delay: 0s; }
.wisp-5 { animation-delay: 0.7s; }
.wisp-6 { animation-delay: 0.4s; }

@keyframes smoke-drift {
    0% { transform: translateX(0); opacity: 0.3; }
    50% { transform: translateX(8px); opacity: 0.15; }
    100% { transform: translateX(-5px); opacity: 0.3; }
}

.wisps-final {
    width: 300px;
    height: 500px;
    top: 5%;
}

/* =============================================
   CHAPTER 1: THE FLAME
   ============================================= */
#chapter-1 {
    background-color: var(--deep-indigo);
}

.chapter-1-content {
    text-align: center;
}

/* Site Title Arc */
.site-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2.5rem, 7vw, 6rem);
    letter-spacing: -0.02em;
    color: var(--candle-core);
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    gap: 0.05em;
}

.title-letter {
    display: inline-block;
    transform: translateY(calc(var(--i) * var(--i) * 2px - var(--i) * 10px + 12px));
    animation: letter-glow 3s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.15s);
}

@keyframes letter-glow {
    0%, 100% { text-shadow: 0 0 10px rgba(245, 166, 35, 0.3); }
    50% { text-shadow: 0 0 25px rgba(245, 166, 35, 0.6), 0 0 50px rgba(245, 166, 35, 0.2); }
}

/* Candle Hero */
.candle-hero {
    width: clamp(150px, 25vw, 250px);
    margin: 0 auto 2rem;
    position: relative;
}

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

.candle-glow {
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.15; rx: 80; ry: 60; }
    50% { opacity: 0.25; rx: 90; ry: 70; }
}

.chapter-tagline {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--candle-halo);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.chapter-tagline.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   CHAPTER 2: THE WARMTH
   ============================================= */
#chapter-2 {
    background: linear-gradient(180deg, var(--deep-indigo) 0%, #1a2a4a 50%, #1e3a5f 100%);
}

.chapter-2-content {
    gap: 3rem;
}

.chapter-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2.5rem, 7vw, 6rem);
    letter-spacing: -0.02em;
    color: var(--candle-core);
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Card Scatter Layout */
.card-scatter {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(1.5rem, 3vw, 3rem);
    justify-content: center;
    max-width: 1000px;
    padding: 1rem;
}

.warmth-card {
    position: relative;
    background-color: rgba(253, 246, 227, 0.08);
    border: 1px solid var(--molten-amber);
    border-radius: 8px;
    padding: clamp(2rem, 4vw, 4rem);
    width: clamp(280px, 30vw, 320px);
    transform: rotate(var(--rotation, 0deg));
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.warmth-card.visible {
    opacity: 1;
}

.warmth-card:hover {
    border-color: var(--candle-core);
    background-color: rgba(253, 246, 227, 0.12);
    transform: rotate(0deg) translateY(-4px);
    transition: all 0.3s ease;
}

.card-heading {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--candle-core);
    margin-bottom: 1rem;
}

.card-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.8;
    color: var(--parchment);
    opacity: 0.9;
}

/* Floating mid-layer flames */
.floating-flames-mid {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.mid-flame {
    position: absolute;
    width: 30px;
    height: 50px;
}

.mf-1 { top: 20%; left: 10%; animation: flame-float 6s ease-in-out infinite; }
.mf-2 { top: 40%; left: 80%; animation: flame-float 7s ease-in-out infinite 0.5s; }
.mf-3 { top: 60%; left: 30%; animation: flame-float 8s ease-in-out infinite 1s; }
.mf-4 { top: 15%; left: 65%; animation: flame-float 7.5s ease-in-out infinite 1.5s; }
.mf-5 { top: 75%; left: 50%; animation: flame-float 6.5s ease-in-out infinite 0.8s; }

@keyframes flame-float {
    0% { transform: translateY(0) translateX(0) scale(1); opacity: 0.4; }
    25% { transform: translateY(-40px) translateX(10px) scale(1.1); opacity: 0.6; }
    50% { transform: translateY(-80px) translateX(-5px) scale(0.9); opacity: 0.5; }
    75% { transform: translateY(-120px) translateX(8px) scale(1.05); opacity: 0.3; }
    100% { transform: translateY(-160px) translateX(0) scale(1); opacity: 0; }
}

/* =============================================
   CHAPTER 3: THE WORKSHOP
   ============================================= */
#chapter-3 {
    background-color: var(--parchment);
}

#chapter-3 .chapter-title {
    color: var(--deep-indigo);
}

.chapter-3-content {
    padding-top: clamp(3rem, 6vw, 6rem);
    padding-bottom: clamp(3rem, 6vw, 6rem);
}

.workshop-split {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: clamp(1rem, 3vw, 3rem);
    width: 100%;
    min-height: 70vh;
    align-items: start;
}

.workshop-illustration {
    position: relative;
    margin-left: -5vw;
}

.workshop-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.workshop-svg .path-draw {
    stroke-dasharray: var(--path-length, 500);
    stroke-dashoffset: var(--path-length, 500);
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.workshop-svg.visible .path-draw {
    stroke-dashoffset: 0;
}

.workshop-text {
    position: relative;
    padding-right: 1rem;
}

.scroll-text-container {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--molten-amber) transparent;
}

.scroll-text-container::-webkit-scrollbar {
    width: 4px;
}

.scroll-text-container::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-text-container::-webkit-scrollbar-thumb {
    background-color: var(--molten-amber);
    border-radius: 2px;
}

.workshop-text p {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.8;
    color: var(--deep-indigo);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.workshop-text p.visible {
    opacity: 1;
    transform: translateY(0);
}

.workshop-text .chapter-title {
    margin-bottom: 2rem;
}

/* =============================================
   CHAPTER 4: THE PATH
   ============================================= */
#chapter-4 {
    background: linear-gradient(180deg, #1e3a5f 0%, #1a2a4a 100%);
}

.chapter-4-content {
    position: relative;
}

.chapter-4-title {
    margin-bottom: 2rem;
}

.path-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
}

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

.journey-line {
    stroke-dasharray: var(--path-length, 2000);
    stroke-dashoffset: var(--path-length, 2000);
    transition: stroke-dashoffset 3s cubic-bezier(0.4, 0, 0.2, 1);
}

.journey-line.visible {
    stroke-dashoffset: 0;
}

.waypoint {
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.5s ease;
}

.waypoint.visible {
    opacity: 1;
    animation: waypoint-pulse 2s ease-in-out infinite;
}

.wp-inner {
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

.wp-inner.visible {
    opacity: 1;
}

/* Path labels positioned along journey */
.path-label {
    position: absolute;
    text-align: center;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.path-label.visible {
    opacity: 1;
    transform: translateY(0);
}

.path-label h3 {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    letter-spacing: 0.04em;
    color: var(--candle-core);
    margin-bottom: 0.3rem;
}

.path-label p {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--ash-gray);
}

.pl-1 { bottom: 8%; left: 0%; }
.pl-2 { bottom: 38%; left: 12%; }
.pl-3 { top: 38%; left: 42%; }
.pl-4 { top: 20%; left: 68%; }
.pl-5 { top: 10%; right: 0%; }

/* =============================================
   CHAPTER 5: THE EMBER
   ============================================= */
#chapter-5 {
    background-color: var(--deep-indigo);
}

.chapter-5-content {
    text-align: center;
    gap: 2rem;
}

.ember-title {
    opacity: 0.8;
}

.ember-title.visible {
    opacity: 0.7;
}

.ember-text {
    position: relative;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.8;
    color: var(--parchment);
    max-width: 700px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.ember-text.visible {
    opacity: 0.6;
    transform: translateY(0);
}

/* Ember candle */
.ember-candle {
    width: clamp(100px, 15vw, 160px);
    margin: 1rem auto;
}

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

/* --- Footer --- */
.site-footer {
    margin-top: 3rem;
    text-align: center;
    opacity: 0.6;
}

.footer-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    letter-spacing: 0.1em;
    color: var(--ash-gray);
}

.footer-line {
    width: 100px;
    height: 2px;
    margin: 1rem auto;
}

.footer-line svg {
    width: 100%;
    height: 100%;
}

.footer-rule {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-rule.visible {
    stroke-dashoffset: 0;
}

.footer-sub {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(0.8rem, 1vw, 0.9rem);
    letter-spacing: 0.06em;
    color: var(--ash-gray);
    opacity: 0.7;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .workshop-split {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .workshop-illustration {
        margin-left: 0;
        display: flex;
        justify-content: center;
    }

    .workshop-svg {
        max-width: 350px;
    }

    .scroll-text-container {
        max-height: none;
        overflow-y: visible;
    }

    .card-scatter {
        flex-direction: column;
        align-items: center;
    }

    .warmth-card {
        width: 90%;
        max-width: 400px;
    }

    .path-label {
        position: relative;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin-bottom: 1.5rem;
    }

    .path-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #chapter-nav {
        right: 12px;
    }

    #scroll-progress {
        right: 8px;
    }

    .chapter-content {
        padding: clamp(1.5rem, 3vw, 3rem);
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: clamp(2rem, 12vw, 4rem);
    }

    .chapter-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    #chapter-nav {
        display: none;
    }
}

/* --- Chapter entry animations --- */
.chapter .chapter-content > * {
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.chapter.in-view .chapter-content > * {
    opacity: 1;
    transform: translateY(0);
}

.chapter.in-view .chapter-content > *:nth-child(1) { transition-delay: 0.1s; }
.chapter.in-view .chapter-content > *:nth-child(2) { transition-delay: 0.3s; }
.chapter.in-view .chapter-content > *:nth-child(3) { transition-delay: 0.5s; }
.chapter.in-view .chapter-content > *:nth-child(4) { transition-delay: 0.7s; }

/* Override for specific elements that have their own visibility logic */
.chapter.in-view .chapter-title,
.chapter.in-view .chapter-tagline,
.chapter.in-view .warmth-card,
.chapter.in-view .ember-text,
.chapter.in-view .workshop-text p {
    /* Let JS handle these individually */
}

/* Ember chapter dimming */
.chapter-ember.in-view .chapter-content > * {
    opacity: 0.7;
}
