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

:root {
    --deep-umber: #2A1810;
    --warm-parchment: #F5EDE6;
    --terracotta: #D4856A;
    --burnt-clay: #8B5E4B;
    --copper-mist: #C4846C;
    --oscilloscope: #4CAF7D;
    --glitch-blue: #5B8CA8;
    --espresso: #3D2B1F;
    --cream: #E8DDD4;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--warm-parchment);
    color: var(--espresso);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* === TYPOGRAPHY === */
.display-text {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: clamp(3.5rem, 9vw, 8rem);
    letter-spacing: -0.02em;
    text-shadow: 2px 0 var(--terracotta), -2px 0 var(--burnt-clay);
    line-height: 1.1;
    will-change: transform, opacity;
}

.body-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.85;
    max-width: 38ch;
}

.mono-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--copper-mist);
    opacity: 0.7;
}

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

/* === BACKGROUND LAYERS === */
#bg-staff-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#bg-staff-lines::before,
#bg-staff-lines::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
    background: var(--copper-mist);
    opacity: 0.08;
}

#bg-staff-lines::before { top: calc(100vh / 7); }
#bg-staff-lines::after { top: calc(200vh / 7); }

.staff-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
    background: var(--copper-mist);
    opacity: 0.08;
    will-change: transform;
}

#bg-pulse-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.glitch-block {
    position: absolute;
    opacity: 0;
    will-change: transform, opacity;
}

/* === VU METER === */
#vu-meter {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column-reverse;
    gap: 4px;
}

.vu-segment {
    width: 6px;
    height: 16px;
    background: var(--copper-mist);
    opacity: 0.2;
    border-radius: 1px;
    transition: opacity 0.3s, background 0.3s;
}

.vu-segment.active {
    background: var(--terracotta);
    opacity: 0.9;
}

.vu-segment.bright {
    background: var(--terracotta);
    opacity: 1;
    filter: brightness(1.2);
}

/* === MOVEMENTS === */
.movement {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8vh 6vw;
}

.dark-bg {
    background: var(--deep-umber);
    color: var(--cream);
}

.dark-bg .display-text {
    color: var(--cream);
}

.dark-bg .body-text {
    color: var(--cream);
}

.light-bg {
    background: var(--warm-parchment);
    color: var(--espresso);
}

.light-bg .display-text {
    color: var(--espresso);
}

/* === MA REST SPACES === */
.ma-rest {
    position: relative;
    z-index: 1;
    background: var(--warm-parchment);
}

.quarter-rest { height: 8vh; }
.half-rest { height: 16vh; }
.whole-rest { height: 32vh; }

/* === TUNING SECTION === */
#tuning {
    background: var(--warm-parchment);
    min-height: 100vh;
}

.tuning-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#treble-clef {
    opacity: 0;
    will-change: transform, opacity;
}

.clef-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

#site-title {
    font-size: clamp(3rem, 8vw, 7rem);
    text-align: center;
    min-height: 1.2em;
    color: var(--espresso);
}

#site-subtitle {
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* === MOVEMENT CONTENT === */
.movement-label {
    margin-bottom: 1rem;
}

.movement-title {
    margin-bottom: 3rem;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.movement-desc {
    margin-top: 3rem;
    text-align: center;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1s ease 0.3s, transform 1s ease 0.3s;
}

.movement-desc.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === WAVEFORM CANVAS === */
#waveform-canvas,
#harmony-canvas,
#synthesis-canvas {
    width: 100%;
    max-width: 900px;
    height: 300px;
    display: block;
}

/* === RHYTHM GRID === */
#rhythm-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 700px;
    padding: 2rem 0;
}

.rhythm-dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--copper-mist);
    opacity: 0.12;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
    will-change: transform, opacity;
}

.rhythm-dot.pulse {
    opacity: 0.8;
    background: var(--terracotta);
    transform: scale(1.4);
}

.rhythm-dot.glitch {
    opacity: 0.5;
    background: var(--glitch-blue);
    transform: scale(1.1) translateX(3px);
}

/* === SILENCE MOVEMENT === */
.silence-movement {
    min-height: 80vh;
    background: var(--warm-parchment);
}

.silence-text {
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 2s ease;
}

.silence-text.visible {
    opacity: 0.7;
}

/* === NOTATION FRAGMENTS === */
.notation-fragment {
    position: absolute;
    opacity: 0.3;
    will-change: transform;
    animation: drift 12s ease-in-out infinite alternate;
}

.frag-1 {
    top: 20%;
    left: 15%;
    transform: rotate(3deg);
    animation-delay: -3s;
}

.frag-2 {
    bottom: 25%;
    right: 20%;
    transform: rotate(-2deg);
    animation-delay: -7s;
}

@keyframes drift {
    0% { transform: translate(0, 0) rotate(3deg); }
    100% { transform: translate(15px, -10px) rotate(-2deg); }
}

/* === FINALE === */
#finale {
    height: 50vh;
    background: var(--deep-umber);
    position: relative;
    z-index: 1;
}

/* === SPECTRAL BARS (decorative) === */
.spectral-bar {
    position: absolute;
    width: 4px;
    background: var(--terracotta);
    opacity: 0.08;
    border-radius: 1px;
}
