/* Music Page Styles */

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

html {
    height: 100%;
    height: 100dvh;
    overflow: hidden !important;
    overflow: clip !important;
}

body {
    height: 100%;
    height: 100dvh;
    overflow: hidden !important;
    overflow: clip !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: fixed;
    inset: 0;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    overflow: clip !important;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header h1 {
    color: white;
    font-size: 1.3rem;
    flex: 1;
    text-align: center;
    margin-right: 60px;
}

/* Main Area */
.main-area {
    background: white;
    border-radius: 20px;
    padding: 10px 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Song Navigation */
.song-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.nav-song-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.nav-song-btn:hover {
    transform: scale(1.1);
}

.song-info {
    text-align: center;
}

.song-info h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 5px;
}

.song-counter {
    color: #888;
    font-size: 0.9rem;
}

/* Staff Container */
.staff-container {
    background: #fffef8;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 10px;
    overflow: hidden !important;
    overflow: clip !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    flex-shrink: 0;
}

.scroll-hint {
    text-align: center;
    color: #999;
    font-size: 0.8rem;
    padding-top: 5px;
    user-select: none;
}

.staff-scroll {
    overflow-x: auto;
    overflow-y: clip;
    padding: 50px 0 20px 0;
    scroll-behavior: smooth;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.staff-scroll:active {
    cursor: grabbing;
}

/* Visible scrollbar */
.staff-scroll::-webkit-scrollbar {
    height: 14px;
}

.staff-scroll::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 7px;
    margin: 0 10px;
}

.staff-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 7px;
    border: 2px solid #e0e0e0;
}

.staff-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.staff {
    position: relative;
    height: 160px;
    min-width: max-content;
    display: flex;
}

/* Treble Clef */
.clef {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 5rem;
    line-height: 1;
    color: #333;
    z-index: 2;
}

/* Staff Lines */
.staff-lines {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    bottom: 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.staff-line {
    height: 2px;
    background: #333;
    width: 100%;
}

/* Notes Area */
.notes-area {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 30px;
    padding: 0 30px;
    height: 100%;
    margin-left: 90px;
}

/* Note Wrapper - spacing based on note duration */
.note-wrapper {
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease;
    height: 36px;
}

.whole-note-wrapper { width: 66px; }
.half-note-wrapper { width: 54px; }
.quarter-note-wrapper { width: 42px; }
.eighth-note-wrapper { width: 36px; }

.note-wrapper:hover {
    transform: scale(1.1);
}

/* Note Head Base */
.note-head {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    border-radius: 50%;
    transition: all 0.2s;
}

/* Whole Note - hollow oval, no stem */
.whole-note {
    width: 40px;
    height: 26px;
    border: 4px solid #333;
    background: transparent;
    border-radius: 50%;
}

/* Half Note - hollow oval */
.half-note {
    width: 34px;
    height: 24px;
    border: 4px solid #333;
    background: transparent;
}

/* Quarter Note - filled oval */
.quarter-note {
    width: 32px;
    height: 23px;
    border: 4px solid #333;
    background: #333;
}

/* Eighth Note - filled oval */
.eighth-note {
    width: 30px;
    height: 22px;
    border: 4px solid #333;
    background: #333;
}

/* Note Stem */
.note-stem {
    position: absolute;
    width: 4px;
    height: 44px;
    background: #333;
    transition: all 0.2s;
}

.stem-up {
    left: 28px;
    bottom: 50%;
}

.stem-down {
    left: 0;
    top: 50%;
}

/* Eighth Note Flag */
.note-flag {
    position: absolute;
    width: 14px;
    height: 22px;
    background: #333;
    border-radius: 0 0 12px 0;
}

.flag-up {
    left: 28px;
    bottom: calc(50% + 24px);
    border-radius: 0 12px 12px 0;
}

.flag-down {
    left: 0;
    top: calc(50% + 24px);
    border-radius: 0 0 12px 12px;
}

/* Ledger Lines */
.ledger-line {
    position: absolute;
    width: 42px;
    height: 3px;
    background: #333;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
}

/* Bar Lines */
.bar-line {
    width: 3px;
    height: 112px;
    background: #333;
    flex-shrink: 0;
    align-self: center;
    margin: 0 15px;
}

/* Note Label */
.note-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: 700;
    color: #667eea;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.note-wrapper:hover .note-label {
    opacity: 1;
}

/* Playing/Current States */
.note-wrapper.played .note-head {
    border-color: #667eea;
}

.note-wrapper.played .quarter-note,
.note-wrapper.played .eighth-note {
    background: #667eea;
}

.note-wrapper.played .note-stem {
    background: #667eea;
}

.note-wrapper.played .note-flag {
    background: #667eea;
}

.note-wrapper.played .ledger-line {
    background: #667eea;
}

.note-wrapper.current .note-head,
.note-wrapper.playing .note-head {
    border-color: #e74c3c;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6);
}

.note-wrapper.current .quarter-note,
.note-wrapper.current .eighth-note,
.note-wrapper.playing .quarter-note,
.note-wrapper.playing .eighth-note {
    background: #e74c3c;
}

.note-wrapper.current .note-stem,
.note-wrapper.playing .note-stem {
    background: #e74c3c;
}

.note-wrapper.current .note-flag,
.note-wrapper.playing .note-flag {
    background: #e74c3c;
}

.note-wrapper.current .ledger-line,
.note-wrapper.playing .ledger-line {
    background: #e74c3c;
}

.note-wrapper.current .note-label,
.note-wrapper.playing .note-label {
    opacity: 1;
    color: #e74c3c;
}

.note-wrapper.playing .note-head {
    animation: notePulse 0.3s ease;
}

@keyframes notePulse {
    0%, 100% { transform: translateY(-50%) rotate(-15deg) scale(1); }
    50% { transform: translateY(-50%) rotate(-15deg) scale(1.3); }
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.first-note-btn {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
}

.next-note-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    font-size: 1.1rem;
    padding: 16px 32px;
}

.reset-btn {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.4);
}

.secondary-controls {
    margin-top: 5px;
    opacity: 0.8;
}

.secondary-controls .control-btn {
    padding: 10px 18px;
    font-size: 0.9rem;
}

.play-all-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.pause-btn {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.stop-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.prev-note-btn {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
}

/* Octave Controls */
.octave-controls {
    align-items: center;
    gap: 15px;
}

.octave-btn {
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(26, 188, 156, 0.4);
    padding: 8px 14px;
    font-size: 0.85rem;
}

.octave-indicator {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    min-width: 80px;
    text-align: center;
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Note Legend */
.note-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 10px;
    flex-shrink: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #555;
}

.legend-note {
    position: relative;
    width: 35px;
    height: 25px;
}

/* Legend Note Examples */
.whole-example::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    width: 24px;
    height: 16px;
    border: 3px solid #333;
    border-radius: 50%;
}

.half-example::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    width: 18px;
    height: 14px;
    border: 3px solid #333;
    border-radius: 50%;
}

.half-example::after {
    content: '';
    position: absolute;
    left: 23px;
    bottom: 50%;
    width: 3px;
    height: 25px;
    background: #333;
}

.quarter-example::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    width: 16px;
    height: 12px;
    background: #333;
    border-radius: 50%;
}

.quarter-example::after {
    content: '';
    position: absolute;
    left: 21px;
    bottom: 50%;
    width: 3px;
    height: 25px;
    background: #333;
}

.eighth-example::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    width: 14px;
    height: 11px;
    background: #333;
    border-radius: 50%;
}

.eighth-example::after {
    content: '';
    position: absolute;
    left: 19px;
    bottom: 50%;
    width: 3px;
    height: 25px;
    background: #333;
}

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

    .header h1 {
        font-size: 1.2rem;
        margin-right: 0;
    }

    .main-area {
        padding: 15px;
    }

    .song-info h2 {
        font-size: 1.4rem;
    }

    .controls {
        flex-direction: row;
    }

    .control-btn {
        padding: 12px 18px;
        font-size: 0.9rem;
    }

    .note-legend {
        gap: 15px;
    }

    .legend-item {
        font-size: 0.8rem;
    }
}

/* Reveal Button */
.reveal-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.reveal-btn.revealed {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

/* Song Reveal */
.song-reveal {
    text-align: center;
    padding: 12px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    flex-shrink: 0;
}

.song-reveal.hidden {
    display: none;
}

.song-name {
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }

    .main-area {
        background: #1e1e2e;
    }

    .song-info h2 {
        color: #e0e0e0;
    }

    .song-counter {
        color: #888;
    }

    .staff-container {
        background: #2a2a35;
    }

    .clef, .staff-line, .note-stem, .note-flag, .ledger-line, .bar-line {
        color: #ddd;
        background: #ddd;
    }

    .staff-line {
        background: #888;
    }

    .bar-line {
        background: #888;
    }

    .note-head {
        border-color: #ddd;
    }

    .quarter-note, .eighth-note {
        background: #ddd;
    }

    .note-legend {
        background: #2d2d3d;
    }

    .legend-item {
        color: #aaa;
    }

    .whole-example::before,
    .half-example::before {
        border-color: #ddd;
    }

    .half-example::after,
    .quarter-example::before,
    .quarter-example::after,
    .eighth-example::before,
    .eighth-example::after {
        background: #ddd;
    }
}
