/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-color: #22d3ee;
    --success-color: #10b981;
    --white-key: #ffffff;
    --black-key: #1e293b;
    --active-key: #6366f1;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* App container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Main content */
main {
    flex: 1;
}

/* Controls section */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select {
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--surface-light);
    border-radius: 8px;
    background: var(--surface-light);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 45px;
}

select:hover {
    border-color: var(--primary-color);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Playback controls */
.playback-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    background: var(--surface-color);
    padding: 20px 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--secondary-color);
}

.tempo-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: auto;
    min-width: 200px;
}

.tempo-control label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

#tempo-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-light);
    appearance: none;
    cursor: pointer;
}

#tempo-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

#tempo-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

#tempo-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

/* Visualization section */
.visualization {
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.visualization h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.scale-info {
    text-align: center;
    margin-bottom: 30px;
}

.scale-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 10px;
}

.scale-notes {
    font-size: 1.25rem;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.scale-intervals {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

/* Piano visualization */
.piano-container {
    overflow-x: auto;
    padding: 20px 0;
    margin-bottom: 25px;
}

.piano {
    display: flex;
    justify-content: center;
    position: relative;
    height: 180px;
    min-width: fit-content;
    margin: 0 auto;
}

.key {
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.white-key {
    width: 50px;
    height: 180px;
    background: var(--white-key);
    border: 1px solid #d1d5db;
    border-radius: 0 0 6px 6px;
    margin-right: 2px;
    color: #374151;
    z-index: 1;
}

.white-key:hover {
    background: #f3f4f6;
}

.white-key.active {
    background: var(--active-key);
    color: white;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.white-key.in-scale {
    background: linear-gradient(to bottom, #ddd6fe, var(--white-key));
}

.white-key.in-scale.active {
    background: var(--active-key);
}

.black-key {
    width: 34px;
    height: 110px;
    background: var(--black-key);
    border-radius: 0 0 4px 4px;
    position: absolute;
    z-index: 2;
    color: white;
    font-size: 0.65rem;
}

.black-key:hover {
    background: #374151;
}

.black-key.active {
    background: var(--active-key);
    box-shadow: inset 0 -3px 8px rgba(0, 0, 0, 0.3);
}

.black-key.in-scale {
    background: linear-gradient(to bottom, var(--primary-color), var(--black-key));
}

.black-key.in-scale.active {
    background: var(--active-key);
}

/* Scale degrees */
.notation-container {
    margin-top: 20px;
}

.notation-container h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.scale-degrees {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.degree-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-light);
    padding: 15px 20px;
    border-radius: 8px;
    min-width: 60px;
}

.degree-number {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.degree-note {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Scale details */
.scale-details {
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.scale-details h2 {
    font-size: 1.25rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.scale-description {
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.7;
}

.formula-display h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--accent-color);
    background: var(--surface-light);
    padding: 12px 20px;
    border-radius: 8px;
    display: inline-block;
}

/* Footer */
footer {
    text-align: center;
    padding: 25px;
    margin-top: auto;
    border-top: 1px solid var(--surface-light);
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

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

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .controls {
        grid-template-columns: 1fr 1fr;
        padding: 20px;
        gap: 15px;
    }

    .playback-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .tempo-control {
        margin-left: 0;
        margin-top: 10px;
    }

    .btn {
        justify-content: center;
    }

    .white-key {
        width: 40px;
        height: 150px;
    }

    .black-key {
        width: 28px;
        height: 90px;
    }

    .scale-name {
        font-size: 1.5rem;
    }

    .scale-notes {
        font-size: 1rem;
    }

    .degree-item {
        padding: 10px 15px;
        min-width: 50px;
    }

    .degree-note {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .controls {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .white-key {
        width: 32px;
        height: 130px;
        font-size: 0.65rem;
    }

    .black-key {
        width: 22px;
        height: 75px;
        font-size: 0.55rem;
    }

    .piano {
        height: 130px;
    }

    .scale-degrees {
        gap: 8px;
    }

    .degree-item {
        padding: 8px 12px;
        min-width: 45px;
    }
}

/* Animation for playing notes */
@keyframes keyPress {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(3px);
    }
    100% {
        transform: translateY(0);
    }
}

.key.playing {
    animation: keyPress 0.2s ease;
}

/* Loading state */
.loading {
    opacity: 0.5;
    pointer-events: none;
}
