/* ==========================================================================
   HHASSL.com - Styles
   From chaos to clarity: a scroll-driven narrative
   ========================================================================== */

/* CSS Custom Properties - Palette */
:root {
    --chaos-dark: #1B1423;
    --interference: #FF3F5C;
    --static: #8A8D93;
    --spine-line: #4ECDC4;
    --resolve-white: #F7F5F2;
    --clarity-blue: #2C3E6B;
    --breath: #E8DED1;
    --accent-gold: #C9A961;

    /* Dynamic properties that shift per act */
    --bg-primary: #1B1423;
    --text-primary: #F7F5F2;
    --text-secondary: #8A8D93;
    --accent: #FF3F5C;

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Newsreader', serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Transition */
    --transition-smooth: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);

    /* Spine state */
    --spine-dasharray: 4 12;
    --spine-opacity: 0.4;
}

/* ==========================================================================
   Act-based palette transitions
   ========================================================================== */

[data-act="1"] {
    --bg-primary: #1B1423;
    --text-primary: #F7F5F2;
    --text-secondary: #8A8D93;
    --accent: #FF3F5C;
    --spine-dasharray: 4 12;
    --spine-opacity: 0.4;
}

[data-act="2"] {
    --bg-primary: #1B1423;
    --text-primary: #F7F5F2;
    --text-secondary: #8A8D93;
    --accent: #4ECDC4;
    --spine-dasharray: 20 8;
    --spine-opacity: 0.6;
}

[data-act="3"] {
    --bg-primary: #F7F5F2;
    --text-primary: #2C3E6B;
    --text-secondary: #8A8D93;
    --accent: #4ECDC4;
    --spine-dasharray: 100 0;
    --spine-opacity: 0.8;
}

[data-act="4"] {
    --bg-primary: #F7F5F2;
    --text-primary: #2C3E6B;
    --text-secondary: #8A8D93;
    --accent: #C9A961;
    --spine-dasharray: 100 0;
    --spine-opacity: 0.6;
}

[data-act="5"] {
    --bg-primary: #F7F5F2;
    --text-primary: #2C3E6B;
    --text-secondary: #E8DED1;
    --accent: #C9A961;
    --spine-dasharray: 100 0;
    --spine-opacity: 1;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition-smooth);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   SVG Filters (hidden)
   ========================================================================== */

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Noise Overlay
   ========================================================================== */

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

[data-act="1"] .noise-overlay {
    opacity: 0.06;
}

[data-act="5"] .noise-overlay {
    opacity: 0.02;
}

/* ==========================================================================
   Progress Dots Navigation
   ========================================================================== */

.progress-dots {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 40px;
    z-index: 1000;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--static);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
    padding: 0;
}

.dot.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
}

.dot.filled {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
}

.dot-label {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.dot:hover .dot-label {
    opacity: 1;
}

/* ==========================================================================
   The Spine
   ========================================================================== */

.spine {
    position: fixed;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    transform: translateX(-50%);
}

.spine-line {
    stroke: var(--spine-line);
    stroke-dasharray: var(--spine-dasharray);
    opacity: var(--spine-opacity);
    transition: stroke-dasharray 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.8s ease;
}

/* ==========================================================================
   Acts - Common
   ========================================================================== */

.act {
    min-height: 100vh;
    position: relative;
    scroll-snap-align: start;
}

.act-content {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* ==========================================================================
   ACT I: The Tangle
   ========================================================================== */

.act-1 {
    background-color: var(--chaos-dark);
    min-height: 120vh;
    overflow: hidden;
}

.tangle-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(8, auto);
    gap: 0;
    padding: 10vh 5vw;
    min-height: 120vh;
    position: relative;
}

.tangle-block {
    position: relative;
    z-index: 2;
}

.tangle-block-1 {
    grid-column: 2 / 5;
    grid-row: 1;
    transform: rotate(-3deg) translateX(-15px);
    padding: 2rem;
}

.tangle-block-2 {
    grid-column: 4 / 11;
    grid-row: 2 / 4;
    transform: rotate(1.5deg) translateY(-20px);
    padding: 3rem 2rem;
    z-index: 5;
}

.tangle-block-3 {
    grid-column: 9 / 12;
    grid-row: 1;
    transform: rotate(4deg) translateX(10px);
    padding: 1.5rem;
    text-align: right;
}

.tangle-block-4 {
    grid-column: 1 / 6;
    grid-row: 4;
    transform: rotate(-2deg);
    padding: 2rem;
}

.tangle-block-5 {
    grid-column: 7 / 12;
    grid-row: 4;
    transform: rotate(3deg) translateY(15px);
    padding: 1.5rem;
}

.tangle-block-6 {
    grid-column: 3 / 10;
    grid-row: 5 / 6;
    transform: rotate(-1deg) translateX(20px);
    padding: 3rem 2rem;
}

.tangle-block-7 {
    grid-column: 1 / 4;
    grid-row: 6;
    transform: rotate(5deg);
    padding: 1.5rem;
}

.tangle-block-8 {
    grid-column: 5 / 11;
    grid-row: 7;
    transform: rotate(-2.5deg);
    padding: 2rem;
}

/* Glitch Text Effect */
.glitch-text {
    position: relative;
    display: inline-block;
    color: var(--resolve-white);
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.glitch-text::before {
    color: var(--interference);
    animation: glitch-before 0.3s infinite;
    clip-path: inset(0 0 65% 0);
}

.glitch-text::after {
    color: var(--spine-line);
    animation: glitch-after 0.3s infinite;
    clip-path: inset(60% 0 0 0);
}

.glitch-text:hover::before,
.glitch-text:hover::after {
    animation-play-state: paused;
}

@keyframes glitch-before {
    0% { clip-path: inset(0 0 65% 0); transform: translate(-2px, 0); }
    20% { clip-path: inset(25% 0 40% 0); transform: translate(2px, 0); }
    40% { clip-path: inset(50% 0 15% 0); transform: translate(-1px, 0); }
    60% { clip-path: inset(10% 0 55% 0); transform: translate(3px, 0); }
    80% { clip-path: inset(70% 0 5% 0); transform: translate(-2px, 0); }
    100% { clip-path: inset(0 0 65% 0); transform: translate(0, 0); }
}

@keyframes glitch-after {
    0% { clip-path: inset(60% 0 0 0); transform: translate(2px, 0); }
    20% { clip-path: inset(35% 0 30% 0); transform: translate(-3px, 0); }
    40% { clip-path: inset(5% 0 60% 0); transform: translate(1px, 0); }
    60% { clip-path: inset(45% 0 20% 0); transform: translate(-2px, 0); }
    80% { clip-path: inset(15% 0 50% 0); transform: translate(2px, 0); }
    100% { clip-path: inset(60% 0 0 0); transform: translate(0, 0); }
}

.hero-glitch {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    line-height: 1.1;
}

.fragment-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    line-height: 1.5;
    color: var(--static);
}

.mono-accent {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--interference);
    opacity: 0.7;
}

.tangle-block h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    line-height: 1.2;
}

/* Glitch Strips - screen tearing effect */
.glitch-strip {
    position: absolute;
    height: 4px;
    background: var(--interference);
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    animation: strip-flash 4s infinite;
}

.strip-1 {
    top: 15%;
    left: 10%;
    width: 45%;
    animation-delay: 0s;
}

.strip-2 {
    top: 30%;
    left: 25%;
    width: 60%;
    animation-delay: 0.7s;
}

.strip-3 {
    top: 50%;
    left: 5%;
    width: 35%;
    animation-delay: 1.4s;
}

.strip-4 {
    top: 68%;
    left: 40%;
    width: 50%;
    animation-delay: 2.1s;
}

.strip-5 {
    top: 82%;
    left: 15%;
    width: 70%;
    animation-delay: 2.8s;
}

@keyframes strip-flash {
    0%, 96%, 100% { opacity: 0; }
    97% { opacity: 0.8; transform: translateX(-5px); }
    98% { opacity: 0.4; transform: translateX(3px); }
    99% { opacity: 0.6; transform: translateX(-2px); }
}

/* ==========================================================================
   ACT II: The Unraveling
   ========================================================================== */

.act-2 {
    background-color: var(--chaos-dark);
    min-height: 120vh;
    overflow: hidden;
}

.unravel-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-height: 120vh;
    position: relative;
}

.diagonal-slice {
    padding: clamp(3rem, 6vw, 6rem) clamp(4rem, 10vw, 12rem);
    position: relative;
    transform-origin: center;
    transition: var(--transition-smooth);
}

.diagonal-slice::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

.slice-1 {
    transform: skewY(-4deg);
    padding-top: 8vh;
}

.slice-1::before {
    background: rgba(27, 20, 35, 0.6);
    transform: skewY(4deg);
}

.slice-2 {
    transform: skewY(3deg);
}

.slice-2::before {
    background: rgba(27, 20, 35, 0.4);
    transform: skewY(-3deg);
}

.slice-3 {
    transform: skewY(-2deg);
}

.slice-3::before {
    background: rgba(27, 20, 35, 0.3);
    transform: skewY(2deg);
}

.slice-4 {
    transform: skewY(1deg);
}

.slice-5 {
    transform: skewY(-0.5deg);
}

.unravel-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--resolve-white);
    line-height: 1.15;
}

.unravel-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    color: var(--static);
    line-height: 1.7;
    max-width: 600px;
}

.unravel-text.serif-body {
    font-style: italic;
    font-weight: 300;
    color: var(--resolve-white);
    opacity: 0.8;
    max-width: 520px;
}

/* ==========================================================================
   ACT III: The Alignment
   ========================================================================== */

.act-3 {
    background-color: var(--resolve-white);
    min-height: 200vh;
}

.alignment-content {
    display: flex;
    flex-direction: column;
    min-height: 200vh;
}

.alignment-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(4rem, 10vw, 12rem);
    position: relative;
}

.alignment-panel::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: var(--clarity-blue);
    opacity: 0.2;
}

.alignment-panel:last-child::after {
    display: none;
}

.alignment-statement {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    color: var(--clarity-blue);
    text-align: center;
    line-height: 1.15;
    max-width: 900px;
}

.alignment-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.1rem, 1.5vw, 1.4rem);
    color: var(--clarity-blue);
    text-align: center;
    line-height: 1.8;
    max-width: 640px;
    opacity: 0.8;
}

/* ==========================================================================
   ACT IV: The Clarity
   ========================================================================== */

.act-4 {
    background-color: var(--resolve-white);
    min-height: 180vh;
    overflow: hidden;
}

.clarity-content {
    display: flex;
    flex-direction: column;
    min-height: 180vh;
    position: relative;
}

/* Gradient Orbs */
.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(44, 62, 107, 0.15), rgba(78, 205, 196, 0.08), transparent);
    top: 10%;
    left: -10%;
    animation: orb-drift-1 45s ease-in-out infinite;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(201, 169, 97, 0.12), rgba(44, 62, 107, 0.06), transparent);
    top: 40%;
    right: -5%;
    animation: orb-drift-2 55s ease-in-out infinite;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.1), rgba(201, 169, 97, 0.08), transparent);
    bottom: 15%;
    left: 20%;
    animation: orb-drift-3 38s ease-in-out infinite;
}

.orb-4 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(201, 169, 97, 0.1), rgba(44, 62, 107, 0.05), transparent);
    top: 20%;
    right: -15%;
    animation: orb-drift-1 50s ease-in-out infinite reverse;
}

.orb-5 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.08), transparent);
    bottom: 30%;
    left: 10%;
    animation: orb-drift-3 60s ease-in-out infinite;
}

@keyframes orb-drift-1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(60px, -40px); }
    50% { transform: translate(-30px, 50px); }
    75% { transform: translate(40px, 20px); }
}

@keyframes orb-drift-2 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-50px, 30px); }
    66% { transform: translate(30px, -60px); }
}

@keyframes orb-drift-3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(40px, 30px); }
    50% { transform: translate(-20px, -40px); }
    75% { transform: translate(-50px, 20px); }
}

.clarity-panel {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(4rem, 10vw, 12rem);
    position: relative;
    z-index: 1;
}

.clarity-quote {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 2.5vw, 2.2rem);
    color: var(--clarity-blue);
    text-align: center;
    line-height: 1.7;
    max-width: 700px;
    opacity: 0.9;
}

/* ==========================================================================
   ACT V: The Stillness
   ========================================================================== */

.act-5 {
    background-color: var(--resolve-white);
    min-height: 100vh;
    overflow: hidden;
}

.stillness-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.stillness-word {
    z-index: 2;
    text-align: center;
}

.final-word {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--clarity-blue);
    display: inline-block;
    cursor: default;
}

.pulse-text {
    animation: pulse-breathe 3s ease-in-out infinite;
}

.pulse-text:hover {
    transform: scale(1.05);
    color: var(--accent-gold);
    transition: color 0.5s ease, transform 0.5s ease;
}

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

/* ==========================================================================
   Scroll-triggered animations (applied via JS)
   ========================================================================== */

.act-1 .tangle-block {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.act-1 .tangle-block.visible {
    opacity: 1;
}

.diagonal-slice {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.diagonal-slice.visible {
    opacity: 1;
}

.diagonal-slice.visible.slice-1 {
    transform: skewY(-4deg) translateY(0);
}

.diagonal-slice.visible.slice-2 {
    transform: skewY(3deg) translateY(0);
}

.diagonal-slice.visible.slice-3 {
    transform: skewY(-2deg) translateY(0);
}

.diagonal-slice.visible.slice-4 {
    transform: skewY(1deg) translateY(0);
}

.diagonal-slice.visible.slice-5 {
    transform: skewY(-0.5deg) translateY(0);
}

.alignment-panel {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.8s ease, transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.alignment-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.clarity-panel {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.9s ease, transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.clarity-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.stillness-word {
    opacity: 0;
    transition: opacity 1.5s ease;
}

.stillness-word.visible {
    opacity: 1;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .progress-dots {
        left: 12px;
        gap: 30px;
    }

    .dot {
        width: 12px;
        height: 12px;
    }

    .dot-label {
        display: none;
    }

    .tangle-grid {
        grid-template-columns: repeat(6, 1fr);
        padding: 5vh 3vw;
    }

    .tangle-block-1 {
        grid-column: 1 / 3;
    }

    .tangle-block-2 {
        grid-column: 1 / 6;
    }

    .tangle-block-3 {
        grid-column: 4 / 7;
    }

    .tangle-block-4 {
        grid-column: 1 / 5;
    }

    .tangle-block-5 {
        grid-column: 3 / 7;
    }

    .tangle-block-6 {
        grid-column: 1 / 6;
    }

    .tangle-block-7 {
        grid-column: 1 / 3;
    }

    .tangle-block-8 {
        grid-column: 2 / 7;
    }

    .diagonal-slice {
        padding: clamp(2rem, 4vw, 4rem) clamp(2rem, 6vw, 6rem);
    }

    .alignment-panel {
        padding: clamp(3rem, 6vw, 6rem);
    }

    .clarity-panel {
        padding: clamp(3rem, 6vw, 6rem);
    }

    .gradient-orb {
        filter: blur(60px);
    }

    .orb-1 { width: 300px; height: 300px; }
    .orb-2 { width: 250px; height: 250px; }
    .orb-3 { width: 200px; height: 200px; }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .glitch-text::before,
    .glitch-text::after {
        animation: none;
    }

    .glitch-strip {
        animation: none;
        display: none;
    }

    .pulse-text {
        animation: none;
    }

    .gradient-orb {
        animation: none;
    }

    .spine-line {
        transition: none;
    }

    .diagonal-slice,
    .alignment-panel,
    .clarity-panel,
    .stillness-word,
    .tangle-block {
        opacity: 1;
        transform: none;
        transition: none;
    }

    body {
        transition: none;
    }
}
