/* Baby Sleep Sounds - Dreamscape Styles */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #252542;
    --bg-card-hover: #2d2d4a;
    --accent-primary: #7c3aed;
    --accent-secondary: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #606080;
    --success: #10b981;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Subtle animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    animation: gradientShift 20s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.moon {
    font-size: 2.5rem;
    animation: moonGlow 4s ease-in-out infinite;
}

@keyframes moonGlow {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 200, 0.5));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 255, 200, 0.8));
        transform: scale(1.05);
    }
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Quick Start / Safety Note */
.quick-start {
    text-align: center;
    margin: -1.5rem 0 2rem;
    padding: 0.75rem 1rem;
    background: rgba(124, 58, 237, 0.1);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.quick-start .safety-note {
    color: var(--accent-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.quick-start .usage-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Now Playing Section */
.now-playing {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.visualizer {
    height: 120px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

#visualizerCanvas {
    width: 100%;
    height: 100%;
}

.current-sound {
    text-align: center;
}

#currentSoundName {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.now-playing.playing #currentSoundName {
    color: var(--accent-secondary);
}

/* Current Sound Display (below visualizer, above controls) */
.now-playing .current-sound {
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    min-height: 1.5em;
}

.now-playing.playing .current-sound {
    color: var(--accent-secondary);
}

/* Now Playing Bar (controls inside visualizer component) */
.now-playing-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
}

/* Pause Button with Progress Ring */
.pause-btn-container {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.pause-progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
}

.pause-progress-bg {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 2;
}

.pause-progress-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 125.6; /* 2 * PI * 20 */
    stroke-dashoffset: 125.6; /* Start empty */
    transition: stroke-dashoffset 0.1s linear;
}

.pause-btn-container.transitioning .pause-progress-fill {
    stroke: var(--accent-secondary);
}

.pause-btn-container.paused .pause-progress-fill {
    stroke: var(--success);
}

.now-playing-bar .pause-btn {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: transparent;
    color: var(--accent-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.now-playing-bar .pause-btn:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.2);
    color: var(--text-primary);
}

.now-playing-bar .pause-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.now-playing-bar .pause-btn.paused {
    color: var(--success);
}

.now-playing-bar .pause-btn.paused:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.2);
}

.now-playing-bar .volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.now-playing-bar .timer-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.now-playing-bar .timer-control label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.now-playing-bar .screensaver-control {
    display: flex;
    align-items: center;
    gap: 0;
}

.now-playing-bar .screensaver-control select {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
    border-right: none;
}

.screensaver-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.6rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.screensaver-btn:hover {
    background: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Sound Selection Zone */
.sound-selection {
    margin-bottom: 2rem;
}

.sound-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
}

.sound-selection-header h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.sound-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.action-btn .btn-icon {
    font-size: 1rem;
}

/* Button Progress Bar (for Random button) */
.action-btn {
    position: relative;
    overflow: hidden;
}

.action-btn .btn-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0%;
    background: var(--accent-secondary);
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    transition: width 0.1s linear;
}

.action-btn.loading .btn-progress {
    background: var(--accent-primary);
}

.action-btn.active .btn-progress {
    width: 100%;
    background: var(--accent-secondary);
}

.action-btn.fading-out .btn-progress {
    background: var(--text-muted);
}

/* Presets Tray (inside now-playing component) */
.presets-tray {
    display: none; /* Hidden when empty */
    padding: 0.5rem 1.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    text-align: center;
}

.presets-tray.has-presets {
    display: block;
}

.presets-tray .presets-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}

.presets-tray .presets-list {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0;
}

.presets-tray .presets-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
    padding: 0;
}

/* Screensaver Overlay */
.screensaver-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: none;
}

.screensaver-overlay.active {
    display: block;
    cursor: none;
}

/* Hide scrollbar and cursor when screensaver is active */
body.screensaver-active {
    overflow: hidden;
    cursor: none;
}

#screensaverCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.screensaver-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 1;
    transition: opacity 3s ease;
}

.screensaver-overlay.hide-hint .screensaver-hint {
    opacity: 0;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.volume-icon {
    font-size: 1.25rem;
    opacity: 0.7;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 10px var(--accent-glow);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-glow);
}

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

.timer-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timer-control label {
    color: var(--text-secondary);
    font-weight: 500;
}

select {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

select:hover, select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.timer-display {
    color: var(--accent-secondary);
    font-weight: 600;
    min-width: 60px;
}

/* Fade-out Control */
.fadeout-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-primary);
    border-radius: 11px;
    transition: var(--transition);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-label input:checked + .toggle-switch::after {
    left: 20px;
    background: var(--text-primary);
}

.toggle-label input:focus + .toggle-switch {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

.fadeout-control select {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
}

.fadeout-control select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fadeout-control.disabled {
    opacity: 0.5;
}

.fadeout-control.disabled .toggle-label {
    cursor: not-allowed;
}

/* Preset Items (used in presets-tray) */

.preset-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(124, 58, 237, 0.2);
    transition: border-color 0.3s ease, background 0.3s ease;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.preset-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
}

/* Preset Progress Bar */
.preset-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0%;
    background: var(--accent-primary);
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    transition: width 0.1s linear;
}

.preset-item.active {
    border-color: var(--accent-primary);
}

.preset-item.active .preset-progress {
    width: 100%;
    background: var(--accent-secondary);
}

.preset-item.loading .preset-progress {
    background: var(--accent-primary);
}

.preset-item.fading-out .preset-progress {
    background: var(--text-muted);
}

.preset-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preset-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.preset-details {
    display: none; /* Hidden in compact mode */
}

.preset-actions {
    display: flex;
    gap: 0.25rem;
}

.preset-load-btn,
.preset-delete-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.preset-load-btn {
    background: var(--accent-primary);
    color: var(--text-primary);
    font-weight: 600;
}

.preset-load-btn:hover {
    background: var(--accent-secondary);
}

.preset-delete-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.25rem 0.4rem;
}

.preset-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Sound Grid */
.sound-grid {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    margin-bottom: 3rem;
}

.sound-category h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.category-info {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.sound-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.sound-card {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
    color: inherit;
}

.sound-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
}

.sound-card.active {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
}

.sound-card.fading-out {
    opacity: 0.6;
    transition: opacity 10s ease-out;
    pointer-events: none;
}

.sound-card.active .card-icon {
    color: var(--accent-secondary);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.card-icon {
    font-size: 1.75rem;
    min-width: 40px;
    text-align: center;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.card-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Per-sound volume slider */
.sound-volume-slider {
    width: 100%;
    margin-top: 0.75rem;
    height: 6px;
    background: var(--bg-primary);
}

.sound-volume-slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
}

.sound-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
}

/* Research Section */
.research-section {
    margin-bottom: 3rem;
}

.research-section h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.research-intro {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.research-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-primary);
}

.research-card h3 {
    color: var(--accent-secondary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.research-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.research-card p:last-of-type {
    margin-bottom: 1.25rem;
}

.research-card strong {
    color: var(--text-primary);
}

.sources {
    padding-top: 1rem;
    border-top: 1px solid rgba(124, 58, 237, 0.2);
}

.sources h4 {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.sources ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sources li {
    margin-bottom: 0.4rem;
}

.sources a {
    color: var(--accent-secondary);
    font-size: 0.8rem;
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.4;
    display: inline-block;
}

.sources a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.research-disclaimer {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.research-disclaimer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.research-disclaimer strong {
    color: var(--accent-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(124, 58, 237, 0.2);
}

footer p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

footer a:hover {
    color: var(--accent-secondary);
}

.github-line {
    margin-top: 0.25rem;
}

.github-link {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.github-link svg {
    vertical-align: middle;
}

.disclaimer {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.dedication {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 1rem;
    letter-spacing: 0.02em;
}

/* Stars animation for background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .logo {
        gap: 0.5rem;
    }

    .moon {
        font-size: 2rem;
    }

    .now-playing-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
        padding: 0.6rem 0.75rem;
    }

    .now-playing-bar .timer-control label {
        display: none;
    }

    .now-playing-bar input[type="range"] {
        width: 80px;
    }

    .sound-selection-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .presets-tray .presets-list {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .sound-cards {
        grid-template-columns: 1fr;
    }

    .now-playing {
        padding: 1.25rem;
    }

    .visualizer {
        height: 80px;
    }

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

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .sound-card {
        padding: 1rem;
    }

    .card-icon {
        font-size: 1.5rem;
        min-width: 32px;
    }

    .research-section h2 {
        font-size: 1.25rem;
    }

    .research-card {
        padding: 1.25rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus styles for keyboard navigation */
.sound-card:focus,
select:focus,
input[type="range"]:focus,
.pause-btn:focus,
.screensaver-btn:focus,
.action-btn:focus,
.preset-load-btn:focus,
.preset-delete-btn:focus {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg-card: #1a1a30;
        --text-secondary: #c0c0e0;
    }

    .sound-card {
        border: 1px solid var(--text-muted);
    }
}
