/* =========================================
   Light Academic Design System
   ABC Musik - German Music Theory Study App
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* -----------------------------------------
   1. Design System Variables
   ----------------------------------------- */
:root {
    --bg-from: #f5f6fa;
    --bg-via: #eef0f5;
    --bg-to: #e8eaf0;
    --glass: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.9);
    --glass-inset: rgba(0, 0, 0, 0.03);
    --accent-blue: #4a6cf7;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-purple: #7c3aed;
    --accent-orange: #f59e0b;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a7a;
    --text-muted: #8e8ea0;
    --radius: 16px;
    --blur: 20px;
}

/* -----------------------------------------
   2. Base Styles
   ----------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-from), var(--bg-via), var(--bg-to));
    background-attachment: fixed;
    color: var(--text-primary);
    margin: 0;
    padding: 30px 15px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 700px;
    margin: 0 auto;
}

.hidden {
    display: none !important;
}

/* -----------------------------------------
   3. Index Page - Header
   ----------------------------------------- */
header {
    text-align: left;
    margin-bottom: 28px;
    padding-bottom: 15px;
}

header h1 {
    font-weight: 700;
    margin: 0;
    font-size: 1.9rem;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

p.subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 0.92rem;
    font-weight: 300;
}

/* -----------------------------------------
   4. Index Page - Search & Filter
   ----------------------------------------- */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
}

.section-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 20px 0 10px 4px;
}

/* -----------------------------------------
   5. Index Page - File List (Lecture Cards)
   ----------------------------------------- */
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.file-card:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.file-num {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 42px;
    line-height: 1.35;
}

.text-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.file-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
}

.file-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 300;
}

.arrow-icon {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 5px;
    transition: all 0.2s ease;
}

.file-card:hover .arrow-icon {
    color: var(--accent-blue);
    transform: translateX(2px);
}

/* -----------------------------------------
   6. Lecture Page - Header
   ----------------------------------------- */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.88rem;
    font-weight: 400;
    padding: 7px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

.german-title {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-top: 10px;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.korean-title {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 0.92rem;
    color: var(--text-muted);
    font-weight: 300;
    margin-top: 2px;
    margin-bottom: 25px;
}

/* -----------------------------------------
   7. Sentence List & Cards
   ----------------------------------------- */
.sentence-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 80px;
}

.sentence-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sentence-card:hover {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* -----------------------------------------
   8. Card Top (Play Button + German Sentence)
   ----------------------------------------- */
.card-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.play-btn {
    background: rgba(255, 255, 255, 0.8);
    color: var(--accent-blue);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.play-btn:hover {
    background: rgba(74, 108, 247, 0.1);
    border-color: var(--accent-blue);
}

.play-btn:active,
.play-btn.playing {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.play-btn i.fa-stop {
    font-size: 0.85em;
}

.german-sentence {
    font-size: 1.12rem;
    margin: 0;
    line-height: 1.6;
    color: var(--text-primary);
    cursor: pointer;
    flex-grow: 1;
    font-family: Georgia, 'Times New Roman', serif;
    transition: color 0.2s ease;
}

.german-sentence:hover {
    color: var(--accent-blue);
}

.toggle-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 8px;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.german-sentence:hover .toggle-icon {
    color: var(--accent-blue);
}

/* -----------------------------------------
   9. Translation Wrapper & Box
   ----------------------------------------- */
.translation-wrapper {
    margin-top: 14px;
    animation: slideDown 0.3s ease-out;
}

.translation-box {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    padding: 14px 16px;
    margin-top: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.retranslate-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-orange);
    margin-bottom: 5px;
    margin-top: 12px;
    display: block;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 10px;
    letter-spacing: 0.03em;
    opacity: 0.85;
}

.trans-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.7;
    margin: 0;
}

.trans-loading {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.88rem;
}

/* -----------------------------------------
   10. Retranslate Button & Area
   ----------------------------------------- */
.retranslate-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    color: var(--accent-orange);
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.retranslate-btn:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-orange);
}

.retranslate-area {
    margin-top: 4px;
}

.retranslate-result {
    margin-top: 8px;
}

.retranslate-text {
    /* inherits .trans-text styles */
}

/* -----------------------------------------
   11. Grammar Box
   ----------------------------------------- */
.grammar-box {
    margin-top: 14px;
    background: rgba(0, 0, 0, 0.02);
    border-left: 3px solid var(--accent-purple);
    border-radius: 4px 12px 12px 4px;
    padding: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.grammar-title {
    font-weight: 600;
    color: var(--accent-purple);
    font-size: 0.82rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 8px;
}

.grammar-content {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-primary);
}

.grammar-highlight {
    background: linear-gradient(120deg, rgba(124, 58, 237, 0.12) 0%, rgba(124, 58, 237, 0.12) 100%);
    background-repeat: no-repeat;
    background-size: 100% 40%;
    background-position: 0 88%;
    font-weight: 600;
    padding: 0 3px;
    color: var(--accent-purple);
}

.structure-tag {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    margin-right: 4px;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* -----------------------------------------
   12. Interactive Words & Popup
   ----------------------------------------- */
.interactive-word {
    cursor: pointer;
    border-bottom: none !important;
    text-decoration: none !important;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 1px 2px;
}

.interactive-word:hover,
.interactive-word:active,
.interactive-word.active {
    color: var(--accent-blue);
    background-color: rgba(74, 108, 247, 0.1);
}

#word-popup {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--glass-border);
    border-radius: 24px 24px 0 0;
    padding: 24px 22px;
    box-sizing: border-box;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

#word-popup.show {
    bottom: 0;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.popup-word {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close {
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--glass-border);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

.popup-meaning {
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
}

.popup-grammar {
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
    padding: 12px;
    border-radius: 12px;
    line-height: 1.5;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.popup-play {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: var(--accent-blue);
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
    margin-left: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.popup-play:hover {
    background: rgba(74, 108, 247, 0.1);
    border-color: var(--accent-blue);
}

.popup-play.playing {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-red);
}

/* -----------------------------------------
   13. Sub-list (Bulleted Content)
   ----------------------------------------- */
.sub-list {
    margin-top: 10px;
    padding-left: 16px;
    border-left: 2px solid rgba(0, 0, 0, 0.08);
    list-style: none;
}

.sub-list li {
    margin-bottom: 10px;
    list-style: none;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-primary);
}

/* -----------------------------------------
   14. Summary Table
   ----------------------------------------- */
.table-container {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: 12px;
}

.summary-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 12px;
    font-size: 0.85rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.summary-table th,
.summary-table td {
    padding: 10px 12px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.summary-table th {
    background: rgba(74, 108, 247, 0.1);
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-table td {
    background: rgba(255, 255, 255, 0.5);
}

.summary-table td:first-child {
    background: rgba(0, 0, 0, 0.03);
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

/* -----------------------------------------
   15. Music Notation Symbols
   ----------------------------------------- */
.func-symbol {
    font-family: "Times New Roman", Georgia, serif;
    font-weight: bold;
    font-style: italic;
    padding: 0 2px;
}

.major-func {
    color: var(--accent-orange);
}

.minor-func {
    color: var(--accent-blue);
}

.parallel-suffix {
    font-style: italic;
    font-size: 0.9em;
    color: var(--accent-orange);
}

/* -----------------------------------------
   16. Bottom Navigation Bar
   ----------------------------------------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 20px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 50;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav .nav-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
}

.bottom-nav .nav-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

body:has(.bottom-nav) .container {
    padding-bottom: 60px;
}

/* Prev/Next lecture nav buttons */
.nav-prev, .nav-next {
    width: auto !important;
    padding: 0 12px !important;
    gap: 4px;
}

.nav-num {
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.7;
}

.nav-btn.disabled {
    opacity: 0.2;
    pointer-events: none;
}

/* Index page - focus highlight */
.file-card-highlight {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 20px rgba(74, 108, 247, 0.2);
    transition: all 0.5s ease;
}

/* -----------------------------------------
   17. Animations
   ----------------------------------------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

/* -----------------------------------------
   18. Legacy Styles (backward compatibility)
   ----------------------------------------- */
.card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--glass-border);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    position: relative;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.category {
    background: rgba(74, 108, 247, 0.1);
    color: var(--accent-blue);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid rgba(74, 108, 247, 0.15);
}

.korean-translation {
    margin-top: 12px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.65;
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: slideDown 0.3s ease-out;
}

.korean-translation p {
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    margin-right: 5px;
    vertical-align: text-top;
}

.badge.red { background-color: var(--accent-red); }
.badge.blue { background-color: var(--accent-blue); }
.badge.green { background-color: var(--accent-green); }
.badge.purple { background-color: var(--accent-purple); }
.badge.gray { background-color: #b0b0b8; }

/* -----------------------------------------
   19. Responsive - Mobile
   ----------------------------------------- */
@media (max-width: 480px) {
    body {
        padding: 20px 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .german-title {
        font-size: 1.3rem;
    }

    .container {
        max-width: 100%;
    }

    .sentence-card {
        padding: 16px;
        border-radius: 14px;
    }

    .card-top {
        gap: 10px;
    }

    .play-btn {
        width: 36px;
        height: 36px;
        font-size: 0.82rem;
    }

    .german-sentence {
        font-size: 1.02rem;
        line-height: 1.55;
    }

    .translation-box {
        padding: 12px;
    }

    .grammar-box {
        padding: 14px;
    }

    .grammar-content {
        font-size: 0.85rem;
    }

    .trans-text {
        font-size: 0.9rem;
    }

    .file-card {
        padding: 14px 16px;
        gap: 10px;
        border-radius: 14px;
    }

    .file-title {
        font-size: 0.95rem;
    }

    .file-subtitle {
        font-size: 0.8rem;
    }

    #word-popup {
        padding: 20px 16px;
        border-radius: 20px 20px 0 0;
    }

    .popup-word {
        font-size: 1.2rem;
    }

    .popup-play {
        width: 34px;
        height: 34px;
    }

    .popup-grammar {
        font-size: 0.85rem;
        padding: 10px;
    }

    .back-btn {
        font-size: 0.82rem;
        padding: 6px 12px;
    }

    .summary-table {
        font-size: 0.78rem;
    }

    .summary-table th,
    .summary-table td {
        padding: 8px;
    }

    .retranslate-btn {
        font-size: 0.78rem;
        padding: 6px 12px;
    }

    .structure-tag {
        font-size: 0.65rem;
    }
}
