/* Cadence — Breathing Rhythm Styles */
/* An Exquisite Corpse of Collaborative CSS */

:root {
    --bg-deep: #0a0a0f;
    --bg-surface: #12121a;
    --text-primary: #e8e8ec;
    --text-muted: #6b6b7b;
    --accent-inhale: #4a9eff;
    --accent-hold: #a855f7;
    --accent-exhale: #22c55e;
    --accent-rest: #f59e0b;
    --glow-intensity: 0.6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

/* Boids Canvas - Full screen background */
.boids-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Resonance visualization canvas */
.resonance-canvas {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 800px;
    height: 200px;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

/* Cymatics pattern canvas - sacred geometry from sound */
.cymatics-canvas {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    z-index: 2;
    pointer-events: none;
    opacity: 0.8;
    mix-blend-mode: screen;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    text-align: center;
    position: relative;
    z-index: 10;
}

/* Navigation */
.tool-nav {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    color: var(--accent-inhale);
    background: rgba(74, 158, 255, 0.1);
    border-color: rgba(74, 158, 255, 0.3);
}

/* Header */
header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 200;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.2em;
}

/* The Breathing Circle Container */
.breath-circle-container {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 2rem;
}

/* Ripple Canvas Overlay */
.ripple-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* The Breathing Circle */
.breath-circle {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle, var(--bg-surface) 0%, var(--bg-deep) 70%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.1s ease-out, box-shadow 0.3s ease;
}

.breath-circle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(74, 158, 255, 0.3) 90deg,
        transparent 180deg
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    animation: rotate 8s linear infinite paused;
}

.breath-circle.active::before {
    opacity: 1;
    animation-play-state: running;
}

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

.inner-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.phase-text {
    font-size: 1.4rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.timer-text {
    font-size: 3rem;
    font-weight: 100;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

/* Phase Colors */
.breath-circle.inhale {
    box-shadow:
        0 0 60px rgba(74, 158, 255, var(--glow-intensity)),
        0 0 120px rgba(74, 158, 255, calc(var(--glow-intensity) * 0.5)),
        inset 0 0 60px rgba(74, 158, 255, 0.1);
}
.breath-circle.inhale .phase-text { color: var(--accent-inhale); }

.breath-circle.hold {
    box-shadow:
        0 0 60px rgba(168, 85, 247, var(--glow-intensity)),
        0 0 120px rgba(168, 85, 247, calc(var(--glow-intensity) * 0.5)),
        inset 0 0 60px rgba(168, 85, 247, 0.1);
}
.breath-circle.hold .phase-text { color: var(--accent-hold); }

.breath-circle.exhale {
    box-shadow:
        0 0 60px rgba(34, 197, 94, var(--glow-intensity)),
        0 0 120px rgba(34, 197, 94, calc(var(--glow-intensity) * 0.5)),
        inset 0 0 60px rgba(34, 197, 94, 0.1);
}
.breath-circle.exhale .phase-text { color: var(--accent-exhale); }

.breath-circle.rest {
    box-shadow:
        0 0 60px rgba(245, 158, 11, var(--glow-intensity)),
        0 0 120px rgba(245, 158, 11, calc(var(--glow-intensity) * 0.5)),
        inset 0 0 60px rgba(245, 158, 11, 0.1);
}
.breath-circle.rest .phase-text { color: var(--accent-rest); }

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.875rem 2.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-inhale), var(--accent-hold));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(74, 158, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

/* Audio Controls */
.audio-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.btn-audio,
.btn-soundscape,
.btn-breath-drone {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-audio svg,
.btn-soundscape svg,
.btn-breath-drone svg {
    width: 22px;
    height: 22px;
}

.btn-audio:hover,
.btn-soundscape:hover,
.btn-breath-drone:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-audio.active {
    background: var(--accent-inhale);
    border-color: var(--accent-inhale);
    color: white;
}

.btn-audio.active .sound-waves {
    animation: soundPulse 1s ease-in-out infinite;
}

.btn-soundscape.active {
    background: var(--accent-exhale);
    border-color: var(--accent-exhale);
    color: white;
}

.btn-breath-drone.active {
    background: var(--accent-hold);
    border-color: var(--accent-hold);
    color: white;
    animation: omPulse 3s ease-in-out infinite;
}

@keyframes omPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(168, 85, 247, 0.5); }
    50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.8); }
}

@keyframes soundPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Soundscape Section */
.soundscape-section {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    max-height: 400px;
    overflow: hidden;
}

.soundscape-section.collapsed {
    max-height: 0;
    padding: 0;
    margin-bottom: 0;
    opacity: 0;
    pointer-events: none;
}

.soundscape-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.soundscape-header h3 {
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.master-slider {
    width: 100px;
}

.sound-layers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.sound-layer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.sound-toggle {
    padding: 0.4rem 0.8rem;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--bg-deep);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.sound-toggle:hover {
    border-color: var(--accent-exhale);
    color: var(--text-primary);
}

.sound-toggle.active {
    background: var(--accent-exhale);
    border-color: var(--accent-exhale);
    color: white;
}

.sound-slider {
    width: 100%;
    height: 4px;
}

/* Range Input Styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-inhale);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-inhale);
    border: none;
    cursor: pointer;
}

/* Pattern Selector */
.pattern-selector {
    margin-bottom: 2rem;
}

.pattern-selector h2 {
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.patterns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.pattern-btn {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
}

.pattern-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.pattern-btn.active {
    border-color: var(--accent-inhale);
    background: rgba(74, 158, 255, 0.1);
}

.pattern-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.pattern-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Cycle Counter */
.cycle-counter {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

#cycleCount {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Footer */
footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

footer p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.05em;
}

footer .credits {
    margin-top: 0.5rem;
    font-style: normal;
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Ambient Background Pulse */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 150vmax;
    height: 150vmax;
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle,
        rgba(74, 158, 255, 0.03) 0%,
        transparent 50%
    );
    pointer-events: none;
    z-index: -1;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 1.5rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .breath-circle-container,
    .breath-circle {
        width: 220px;
        height: 220px;
    }

    .inner-circle {
        width: 160px;
        height: 160px;
    }

    .phase-text {
        font-size: 1.1rem;
    }

    .timer-text {
        font-size: 2.2rem;
    }

    .patterns {
        grid-template-columns: 1fr;
    }

    .sound-layers {
        grid-template-columns: repeat(2, 1fr);
    }

    .tool-nav {
        gap: 0.75rem;
    }

    .nav-link {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .cymatics-canvas {
        width: 320px;
        height: 320px;
    }
}
