/* =============================================
   musical.quest — Crystalline Ocean Styles
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    /* Ocean-Deep Palette */
    --abyss-navy: #0A1628;
    --twilight-teal: #0D2B3E;
    --current-cyan: #1A6B7A;
    --surface-aqua: #4ECDC4;
    --coral-pink: #FF6B8A;
    --prism-gold: #FFD93D;
    --pearl-white: #F0F5F7;
    --foam-silver: #B8C9D4;

    /* Dynamic background (updated via JS) */
    --bg-top: #0A1628;
    --bg-bottom: #0D2B3E;

    /* Typography */
    --font-display: 'EB Garamond', Georgia, serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --size-display: clamp(2.5rem, 7vw, 5rem);
    --size-body: clamp(0.95rem, 1.3vw, 1.15rem);
}

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

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

body {
    font-family: var(--font-body);
    font-size: var(--size-body);
    font-weight: 400;
    color: var(--pearl-white);
    background: var(--abyss-navy);
    overflow-x: hidden;
    line-height: 1.7;
}

/* --- Sections Base --- */
.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-content {
    position: relative;
    z-index: 3;
    text-align: center;
    padding: 2rem;
    max-width: 900px;
}

/* --- Typography --- */
.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 400;
    font-style: italic;
    color: var(--pearl-white);
    letter-spacing: 0.02em;
    line-height: 1.1;
    text-shadow: 0 0 60px rgba(78, 205, 196, 0.3), 0 0 120px rgba(78, 205, 196, 0.1);
}

.hero-title em {
    font-style: italic;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--foam-silver);
    margin-top: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

.section-title {
    font-family: var(--font-display);
    font-size: var(--size-display);
    font-weight: 400;
    font-style: italic;
    color: var(--pearl-white);
    margin-bottom: 2rem;
    text-shadow: 0 0 40px rgba(78, 205, 196, 0.2);
}

.section-title em {
    font-style: italic;
}

/* --- Revealable Elements (Progressive Disclosure) --- */
.revealable {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    will-change: opacity, transform;
}

.revealable.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Crystal Formations --- */
.crystal {
    position: absolute;
    background: rgba(78, 205, 196, 0.08);
    border: 1px solid rgba(78, 205, 196, 0.25);
    will-change: transform;
    transition: border-color 2s ease;
}

.crystal[data-color="aqua"] {
    background: rgba(78, 205, 196, 0.08);
    border-color: rgba(78, 205, 196, 0.3);
}

.crystal[data-color="pink"] {
    background: rgba(255, 107, 138, 0.08);
    border-color: rgba(255, 107, 138, 0.3);
}

.crystal[data-color="gold"] {
    background: rgba(255, 217, 61, 0.08);
    border-color: rgba(255, 217, 61, 0.3);
}

.crystal[data-color="teal"] {
    background: rgba(26, 107, 122, 0.1);
    border-color: rgba(26, 107, 122, 0.35);
}

.crystal::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 50%, rgba(255,255,255,0.03) 100%);
    pointer-events: none;
}

/* Crystal Sizes */
.crystal-lg {
    width: 180px;
    height: 180px;
}

.crystal-md {
    width: 120px;
    height: 120px;
}

.crystal-sm {
    width: 70px;
    height: 70px;
}

.crystal-xs {
    width: 40px;
    height: 40px;
}

/* Background crystals (depth layering) */
.crystal-bg-lg {
    width: 300px;
    height: 300px;
    filter: blur(3px);
    opacity: 0.3;
}

.crystal-bg-md {
    width: 200px;
    height: 200px;
    filter: blur(2px);
    opacity: 0.4;
}

/* Crystal Clusters */
.crystal-cluster {
    position: absolute;
    z-index: 1;
}

/* --- Refraction Lines --- */
.refraction-lines {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.refraction-lines svg {
    width: 100%;
    height: 100%;
}

.refraction-line {
    stroke: rgba(78, 205, 196, 0.12);
    stroke-width: 0.5;
}

/* --- Musical Notation Overlay --- */
.music-notation-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.music-notation-overlay svg {
    position: absolute;
    color: var(--foam-silver);
    opacity: 0.08;
}

.notation-treble {
    width: 60px;
    height: 60px;
    left: var(--note-x);
    top: var(--note-y);
}

.notation-note {
    width: 30px;
    height: 30px;
    left: var(--note-x);
    top: var(--note-y);
}

.notation-staff {
    width: 120px;
    height: 30px;
    left: var(--note-x);
    top: var(--note-y);
    transform: translateX(-50%);
}

/* =============================================
   SECTION 1: OVERTURE
   ============================================= */
.section-overture {
    min-height: 100vh;
    background: linear-gradient(180deg, #0A1628 0%, #0D2B3E 100%);
}

.cluster-overture {
    width: 500px;
    height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.cluster-overture .crystal:nth-child(1) {
    top: 30%;
    left: 25%;
    transform: rotate(45deg);
    animation: crystal-drift 20s ease-in-out infinite;
}

.cluster-overture .crystal:nth-child(2) {
    top: 15%;
    left: 55%;
    transform: rotate(30deg);
    animation: crystal-drift 25s ease-in-out infinite reverse;
}

.cluster-overture .crystal:nth-child(3) {
    top: 55%;
    left: 45%;
    transform: rotate(60deg);
    animation: crystal-drift 18s ease-in-out infinite;
}

.cluster-overture .crystal:nth-child(4) {
    top: 40%;
    left: 70%;
    transform: rotate(15deg);
    animation: crystal-drift 22s ease-in-out infinite reverse;
}

.cluster-overture .crystal:nth-child(5) {
    top: 65%;
    left: 20%;
    transform: rotate(75deg);
    animation: crystal-drift 28s ease-in-out infinite;
}

.section-overture .section-content {
    z-index: 5;
}

.refraction-overture {
    opacity: 0.5;
}

/* =============================================
   SECTION 2: MELODY
   ============================================= */
.section-melody {
    min-height: 120vh;
    background: linear-gradient(180deg, #0D2B3E 0%, #1A6B7A 50%, #0D2B3E 100%);
}

.melody-line {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.melody-path {
    stroke: var(--surface-aqua);
    stroke-width: 1.5;
    stroke-opacity: 0.3;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease-out;
}

.melody-path.drawn {
    stroke-dashoffset: 0;
}

.melody-heading {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.melody-nodes {
    position: absolute;
    inset: 0;
    z-index: 2;
}

.melody-node {
    position: absolute;
    left: var(--node-x);
    top: var(--node-y);
    max-width: 280px;
    text-align: center;
}

.melody-node .crystal {
    position: relative;
    display: inline-block;
    margin-bottom: 0.8rem;
}

.melody-node p {
    font-family: var(--font-body);
    font-size: var(--size-body);
    color: var(--foam-silver);
    line-height: 1.6;
}

.cluster-melody-bg {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.cluster-melody-bg .crystal:nth-child(1) {
    top: 10%;
    left: 70%;
    transform: rotate(20deg);
}

.cluster-melody-bg .crystal:nth-child(2) {
    top: 60%;
    left: 10%;
    transform: rotate(50deg);
}

/* =============================================
   SECTION 3: HARMONY
   ============================================= */
.section-harmony {
    min-height: 100vh;
    background: linear-gradient(180deg, #0D2B3E 0%, #0A1628 100%);
}

.section-harmony .section-content {
    margin-bottom: 2rem;
}

.harmony-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    max-width: 800px;
    width: 90%;
    position: relative;
    z-index: 3;
}

.harmony-card {
    padding: 2.5rem 2rem;
    position: relative;
    backdrop-filter: blur(2px);
    transition: transform 0.5s ease;
}

.harmony-card .crystal {
    position: relative;
    display: inline-block;
    margin-bottom: 0.8rem;
}

.harmony-card p {
    font-family: var(--font-body);
    font-size: var(--size-body);
    color: var(--pearl-white);
    line-height: 1.7;
}

.card-deep {
    background: rgba(10, 22, 40, 0.8);
    border: 1px solid rgba(78, 205, 196, 0.15);
    transform: translate(10px, 10px);
}

.card-mid {
    background: rgba(13, 43, 62, 0.8);
    border: 1px solid rgba(78, 205, 196, 0.2);
    transform: translate(-10px, 5px);
}

.card-light {
    background: rgba(26, 107, 122, 0.4);
    border: 1px solid rgba(78, 205, 196, 0.25);
    transform: translate(5px, -10px);
}

.card-surface {
    background: rgba(78, 205, 196, 0.15);
    border: 1px solid rgba(78, 205, 196, 0.3);
    transform: translate(-5px, -5px);
}

.crystal-bridge {
    position: absolute;
    bottom: 15%;
    right: 10%;
    z-index: 2;
}

.crystal-bridge .crystal {
    position: relative;
    display: inline-block;
}

.crystal-bridge .crystal:nth-child(1) {
    transform: rotate(30deg);
}

.crystal-bridge .crystal:nth-child(2) {
    transform: rotate(60deg);
    margin-left: -20px;
}

/* =============================================
   SECTION 4: RHYTHM
   ============================================= */
.section-rhythm {
    min-height: 100vh;
    background: linear-gradient(180deg, #0A1628 0%, #0D2B3E 50%, #0A1628 100%);
    padding: 4rem 0;
}

.rhythm-beats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 700px;
    width: 90%;
    z-index: 3;
    position: relative;
}

.rhythm-beat {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    padding: 1rem 1.5rem;
}

.rhythm-beat .crystal {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.rhythm-beat p {
    font-family: var(--font-body);
    font-size: var(--size-body);
    color: var(--foam-silver);
    line-height: 1.6;
}

.beat-down {
    padding: 1.8rem 2rem;
}

.beat-down p {
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--pearl-white);
}

.beat-up {
    padding: 0.8rem 1.5rem;
    padding-left: 4rem;
}

.beat-up p {
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: var(--foam-silver);
}

/* Pulse animation for rhythm crystals */
.pulse-crystal {
    animation: crystal-pulse 500ms ease-in-out infinite;
}

@keyframes crystal-pulse {
    0%, 100% { transform: scale(1) rotate(var(--r, 45deg)); }
    50% { transform: scale(1.08) rotate(var(--r, 45deg)); }
}

/* =============================================
   SECTION 5: CRESCENDO
   ============================================= */
.section-crescendo {
    min-height: 130vh;
    background: linear-gradient(180deg, #0D2B3E 0%, #1A6B7A 40%, #0D2B3E 100%);
    padding: 4rem 0;
}

.crescendo-elements {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    max-width: 900px;
    width: 90%;
    z-index: 3;
    position: relative;
}

.crescendo-element {
    text-align: center;
    position: relative;
}

.crescendo-element .crystal {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.cresc-text {
    font-family: var(--font-body);
    line-height: 1.7;
    color: var(--foam-silver);
}

/* Progressive scaling and saturation */
.cresc-1 {
    transform-origin: center;
}

.cresc-1 .cresc-text {
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    opacity: 0.6;
}

.cresc-2 .cresc-text {
    font-size: clamp(0.9rem, 1.2vw, 1.05rem);
    opacity: 0.7;
}

.cresc-3 .cresc-text {
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    opacity: 0.8;
    color: var(--pearl-white);
}

.cresc-4 .cresc-text {
    font-size: clamp(1.1rem, 1.6vw, 1.3rem);
    opacity: 0.9;
    color: var(--pearl-white);
}

.cresc-5 {
    padding: 2rem;
}

.cresc-peak {
    font-size: clamp(1.2rem, 2vw, 1.6rem) !important;
    font-weight: 500;
    color: var(--pearl-white) !important;
    opacity: 1 !important;
    text-shadow: 0 0 30px rgba(78, 205, 196, 0.4), 0 0 60px rgba(255, 107, 138, 0.2);
    max-width: 700px;
    line-height: 1.8;
}

.cluster-crescendo-peak {
    position: relative;
    width: 300px;
    height: 200px;
    margin: 0 auto 2rem;
}

.cluster-crescendo-peak .crystal {
    position: absolute;
}

.cluster-crescendo-peak .crystal:nth-child(1) {
    top: 20%;
    left: 30%;
    transform: rotate(45deg);
}

.cluster-crescendo-peak .crystal:nth-child(2) {
    top: 10%;
    left: 55%;
    transform: rotate(25deg);
}

.cluster-crescendo-peak .crystal:nth-child(3) {
    top: 40%;
    left: 65%;
    transform: rotate(60deg);
}

.cluster-crescendo-peak .crystal:nth-child(4) {
    top: 50%;
    left: 20%;
    transform: rotate(15deg);
}

.cluster-crescendo-peak .crystal:nth-child(5) {
    top: 60%;
    left: 45%;
    transform: rotate(75deg);
}

.cluster-crescendo-peak .crystal:nth-child(6) {
    top: 30%;
    left: 10%;
    transform: rotate(40deg);
}

.cluster-crescendo-peak .crystal:nth-child(7) {
    top: 70%;
    left: 70%;
    transform: rotate(55deg);
}

/* Growing crystal animation for crescendo */
.crescendo-element .crystal {
    transition: width 3s ease-out, height 3s ease-out;
}

.crescendo-element.revealed .crystal {
    animation: crystal-grow 3s ease-out forwards;
}

@keyframes crystal-grow {
    from {
        transform: scale(0.6) rotate(var(--r, 45deg));
        opacity: 0.3;
    }
    to {
        transform: scale(1) rotate(var(--r, 45deg));
        opacity: 1;
    }
}

/* =============================================
   SECTION 6: CODA
   ============================================= */
.section-coda {
    min-height: 80vh;
    background: linear-gradient(180deg, #0D2B3E 0%, #0A1628 100%);
    padding: 4rem 0;
}

.coda-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    max-width: 600px;
    width: 90%;
    z-index: 3;
    position: relative;
}

.coda-element p {
    font-family: var(--font-body);
    font-size: var(--size-body);
    color: var(--foam-silver);
    text-align: center;
    line-height: 1.8;
    opacity: 0.7;
}

.coda-final p {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    color: var(--pearl-white);
    opacity: 0.5;
}

.coda-crystal {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
}

.coda-last-crystal {
    position: relative;
    animation: coda-spin 15s linear infinite;
    opacity: 0.5;
}

@keyframes coda-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =============================================
   SECTION 7: SILENCE
   ============================================= */
.section-silence {
    min-height: 60vh;
    background: linear-gradient(180deg, #0A1628 0%, #060E1A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.silence-line {
    width: 200px;
    height: 1px;
    background: var(--foam-silver);
    opacity: 0;
    animation: silence-breath 6s ease-in-out infinite;
}

@keyframes silence-breath {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.3; }
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes crystal-drift {
    0%, 100% {
        transform: rotate(var(--r, 45deg)) translate(0, 0);
    }
    25% {
        transform: rotate(var(--r, 45deg)) translate(10px, -15px);
    }
    50% {
        transform: rotate(var(--r, 45deg)) translate(-5px, 10px);
    }
    75% {
        transform: rotate(var(--r, 45deg)) translate(15px, 5px);
    }
}

/* =============================================
   SECTION TRANSITIONS
   ============================================= */
.section::after {
    content: '';
    position: absolute;
    bottom: -2rem;
    left: 0;
    right: 0;
    height: 4rem;
    z-index: 10;
    pointer-events: none;
}

.section-overture::after {
    background: linear-gradient(180deg, transparent, #0D2B3E);
}

.section-melody::after {
    background: linear-gradient(180deg, transparent, #0D2B3E);
}

.section-harmony::after {
    background: linear-gradient(180deg, transparent, #0A1628);
}

.section-rhythm::after {
    background: linear-gradient(180deg, transparent, #0D2B3E);
}

.section-crescendo::after {
    background: linear-gradient(180deg, transparent, #0D2B3E);
}

.section-coda::after {
    background: linear-gradient(180deg, transparent, #0A1628);
}

/* =============================================
   HOVER & INTERACTION STATES
   ============================================= */
.crystal.prismatic-shift {
    border-color: var(--surface-aqua);
    animation: prismatic 2s ease-in-out infinite;
}

@keyframes prismatic {
    0%, 100% { border-color: rgba(78, 205, 196, 0.4); }
    33% { border-color: rgba(255, 107, 138, 0.4); }
    66% { border-color: rgba(255, 217, 61, 0.4); }
}

/* Crystal hover tooltip */
.crystal-cluster .crystal:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--pearl-white);
    white-space: nowrap;
    opacity: 0.8;
    pointer-events: none;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .harmony-cards {
        grid-template-columns: 1fr;
    }

    .card-deep,
    .card-mid,
    .card-light,
    .card-surface {
        transform: none;
    }

    .melody-node {
        max-width: 200px;
    }

    .beat-up {
        padding-left: 2rem;
    }

    .cluster-overture {
        width: 300px;
        height: 300px;
    }

    .crystal-lg {
        width: 100px;
        height: 100px;
    }

    .crystal-md {
        width: 70px;
        height: 70px;
    }

    .cluster-crescendo-peak {
        width: 200px;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .melody-node {
        max-width: 160px;
        font-size: 0.85rem;
    }

    .harmony-card {
        padding: 1.5rem 1rem;
    }

    .rhythm-beat {
        gap: 1rem;
    }
}
