/* ==================================================================
   Pitch Pipe Online — Styles
   Theme: Minimalist dark with primary accent #6366F1 (Indigo)
   ================================================================== */

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

:root {
    --primary: #6366F1;
    --primary-rgb: 99, 102, 241;
    --primary-light: #818CF8;
    --primary-dark: #4F46E5;
    --bg: #0F0F14;
    --bg-card: rgba(22, 22, 30, 0.85);
    --bg-elevated: rgba(30, 30, 42, 0.6);
    --text: #E4E4E7;
    --text-muted: #A1A1AA;
    --text-dim: #71717A;
    --border: rgba(99, 102, 241, 0.12);
    --border-hover: rgba(99, 102, 241, 0.3);
    --white-key: #F4F4F5;
    --white-key-active: #E4E4E7;
    --black-key: #27272A;
    --black-key-active: #3F3F46;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 640px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
    text-align: center;
    padding: 1rem 0;
}

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

.logo-icon {
    font-size: 1.75rem;
    animation: bounce 2.5s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ── Glass Card ──────────────────────────────────────────────── */
.controls-panel,
.now-playing,
.reference-section {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* ── Controls ────────────────────────────────────────────────── */
.control-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.control-group {
    flex: 1;
    min-width: 100px;
}

.control-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.control-select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23A1A1AA' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 1.75rem;
}

.control-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Toggle Button ───────────────────────────────────────────── */
.sustain-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-btn {
    width: 44px;
    height: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    padding: 0;
}

.toggle-knob {
    display: block;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition), background var(--transition);
}

.toggle-btn[aria-pressed="true"] {
    background: rgba(var(--primary-rgb), 0.25);
    border-color: var(--primary);
}

.toggle-btn[aria-pressed="true"] .toggle-knob {
    transform: translateX(20px);
    background: var(--primary);
}

.toggle-text {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Now Playing ─────────────────────────────────────────────── */
.now-playing {
    text-align: center;
    padding: 1.5rem;
}

.note-display {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary-light);
    transition: color var(--transition);
    line-height: 1.1;
}

.note-display.active {
    color: var(--primary);
    text-shadow: 0 0 30px rgba(var(--primary-rgb), 0.4);
}

.freq-display {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

.visualizer {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

#wave-canvas {
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

/* ── Keyboard ────────────────────────────────────────────────── */
.keyboard-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.keyboard {
    display: flex;
    position: relative;
    height: 180px;
    min-width: fit-content;
    margin: 0 auto;
    user-select: none;
}

.key {
    position: relative;
    cursor: pointer;
    border: none;
    transition: background var(--transition), box-shadow var(--transition), transform 0.1s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.75rem;
    font-family: var(--font);
    font-weight: 600;
}

.key:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.key-white {
    width: 48px;
    height: 180px;
    background: var(--white-key);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 -2px 0 rgba(0, 0, 0, 0.08);
    z-index: 1;
    color: var(--text-dim);
    font-size: 0.7rem;
    margin-right: 2px;
}

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

.key-white.active {
    background: #D4D4D8;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transform: translateY(2px);
}

.key-black {
    width: 32px;
    height: 115px;
    background: var(--black-key);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
    z-index: 2;
    position: absolute;
    color: var(--text-dim);
    font-size: 0.6rem;
    align-items: flex-end;
    padding-bottom: 0.5rem;
}

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

.key-black.active {
    background: #52525B;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    transform: translateY(2px);
    height: 113px;
}

/* ── Reference Table ─────────────────────────────────────────── */
.reference-section {
    padding: 0;
}

.ref-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
}

.ref-toggle-btn:hover {
    color: var(--text);
}

.chevron {
    transition: transform var(--transition);
}

.ref-toggle-btn[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.ref-table {
    padding: 0 1.25rem 1rem;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ref-table table {
    width: 100%;
    border-collapse: collapse;
}

.ref-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    text-align: left;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.ref-table td {
    font-size: 0.8rem;
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    color: var(--text-muted);
}

.ref-table td:first-child {
    font-weight: 600;
    color: var(--primary-light);
}

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
    color: var(--text-dim);
    font-size: 0.7rem;
    margin-top: auto;
}

/* ── Utility ─────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .control-row {
        flex-direction: column;
    }

    .control-group {
        min-width: 100%;
    }

    .keyboard {
        height: 150px;
    }

    .key-white {
        width: 38px;
        height: 150px;
        font-size: 0.6rem;
    }

    .key-black {
        width: 26px;
        height: 95px;
        font-size: 0.55rem;
    }

    .note-display {
        font-size: 2.5rem;
    }
}