/* ============================================
   12-TONE MATRIX GENERATOR
   Modern, educational design
   ============================================ */

.twelve-tone-app {
    max-width: 1000px;
    margin: 0 auto;
}

/* ============================================
   INTRO SECTION
   ============================================ */
.intro-section {
    margin-bottom: 24px;
}

.intro-card {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.intro-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 12px;
}

.intro-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-light);
    margin: 0 0 20px;
}

.intro-text strong {
    color: var(--primary);
    font-weight: 700;
}

.intro-text em {
    font-style: italic;
    color: var(--text);
}

/* Key Concepts Grid */
.key-concepts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.concept {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 12px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.concept-label {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 6px;
}

.concept-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.concept-desc {
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================
   CONTROLS SECTION
   ============================================ */
.controls-section {
    margin-bottom: 24px;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20, 184, 166, 0.4);
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

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

.toggle-group {
    display: inline-flex;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}

.toggle-btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

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

/* ============================================
   PRIME ROW DISPLAY
   ============================================ */
.row-display-section {
    margin-bottom: 24px;
}

.row-display-card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.row-display-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.1) 0%, rgba(20, 184, 166, 0.03) 100%);
    border-bottom: 1px solid var(--border);
}

.row-display-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
}

.row-display-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(20, 184, 166, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prime-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    flex-wrap: wrap;
}

.prime-note {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    transition: all 0.2s;
}

.prime-note:first-child {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.prime-note .note-index {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 2px;
}

.prime-note:first-child .note-index {
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   MATRIX SECTION
   ============================================ */
.matrix-section {
    margin-bottom: 32px;
}

.matrix-header {
    text-align: center;
    margin-bottom: 16px;
}

.matrix-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 4px;
}

.matrix-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}

.matrix-container {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 16px;
    overflow-x: auto;
}

.matrix-wrapper {
    display: flex;
    justify-content: center;
    min-width: fit-content;
}

/* Matrix Table */
.matrix-table {
    border-collapse: separate;
    border-spacing: 2px;
    font-family: 'JetBrains Mono', monospace;
}

.matrix-table th,
.matrix-table td {
    width: 42px;
    height: 42px;
    text-align: center;
    vertical-align: middle;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.15s;
}

/* Header cells (P, I, R, RI labels) */
.matrix-table th {
    background: transparent;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
    cursor: default;
}

.matrix-table th.label-cell {
    cursor: pointer;
}

.matrix-table th.label-cell:hover {
    color: var(--primary);
}

/* Corner cells */
.matrix-table th.corner {
    background: transparent;
}

/* P row labels (left) */
.matrix-table th.p-label {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.matrix-table th.p-label:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

/* I column labels (top) */
.matrix-table th.i-label {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.matrix-table th.i-label:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

/* R row labels (right) */
.matrix-table th.r-label {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.matrix-table th.r-label:hover {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

/* RI column labels (bottom) */
.matrix-table th.ri-label {
    color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
}

.matrix-table th.ri-label:hover {
    background: rgba(168, 85, 247, 0.15);
    color: #9333ea;
}

/* Matrix data cells */
.matrix-table td {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

/* Highlighted states */
.matrix-table td.highlight-prime {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #dc2626;
    font-weight: 700;
}

.matrix-table td.highlight-inversion {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #2563eb;
    font-weight: 700;
}

.matrix-table td.highlight-retrograde {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #16a34a;
    font-weight: 700;
}

.matrix-table td.highlight-ri {
    background: rgba(168, 85, 247, 0.15);
    border-color: #a855f7;
    color: #9333ea;
    font-weight: 700;
}

/* First cell (P0 start) - always highlighted */
.matrix-table td.origin-cell {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 800;
}

/* Row Info Panel */
.row-info-panel {
    margin-top: 16px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.row-info-header {
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.row-info-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.row-info-label.prime { color: #ef4444; }
.row-info-label.inversion { color: #3b82f6; }
.row-info-label.retrograde { color: #22c55e; }
.row-info-label.ri { color: #a855f7; }

.row-info-notes {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    flex-wrap: wrap;
}

.row-info-note {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.row-info-note.prime {
    border-color: #ef4444;
    color: #ef4444;
}

.row-info-note.inversion {
    border-color: #3b82f6;
    color: #3b82f6;
}

.row-info-note.retrograde {
    border-color: #22c55e;
    color: #22c55e;
}

.row-info-note.ri {
    border-color: #a855f7;
    color: #a855f7;
}

/* ============================================
   LEARN SECTION
   ============================================ */
.learn-section {
    margin-bottom: 32px;
}

.learn-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    margin: 0 0 20px;
}

.learn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.learn-card {
    background: var(--card);
    border-radius: 14px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.learn-card h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.learn-card p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-light);
    margin: 0;
}

.learn-card p strong {
    color: var(--text);
}

.learn-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 900;
    margin-bottom: 12px;
}

.learn-card-icon.prime {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.learn-card-icon.inversion {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.learn-card-icon.retrograde {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.learn-card-icon.ri {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

/* Composers Section */
.composers-section {
    background: var(--card);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--border);
}

.composers-section h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 16px;
    text-align: center;
}

.composers-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.composer {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    min-width: 160px;
}

.composer-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.composer-work {
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================
   TIPS SECTION
   ============================================ */
.tips-section {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(20, 184, 166, 0.02) 100%);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 32px;
}

.tips-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 16px;
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tips-list li {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-light);
    padding-left: 24px;
    position: relative;
}

.tips-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}

.tips-list li strong {
    color: var(--primary);
    font-weight: 700;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease-out;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

body.dark-mode .toast {
    background: var(--card);
    border: 1px solid var(--border);
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */
body.dark-mode .matrix-table th.p-label {
    background: rgba(239, 68, 68, 0.15);
}

body.dark-mode .matrix-table th.i-label {
    background: rgba(59, 130, 246, 0.15);
}

body.dark-mode .matrix-table th.r-label {
    background: rgba(34, 197, 94, 0.15);
}

body.dark-mode .matrix-table th.ri-label {
    background: rgba(168, 85, 247, 0.15);
}

body.dark-mode .matrix-table td.highlight-prime {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

body.dark-mode .matrix-table td.highlight-inversion {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

body.dark-mode .matrix-table td.highlight-retrograde {
    background: rgba(34, 197, 94, 0.25);
    color: #86efac;
}

body.dark-mode .matrix-table td.highlight-ri {
    background: rgba(168, 85, 247, 0.25);
    color: #d8b4fe;
}

body.dark-mode .learn-card-icon.prime {
    background: rgba(239, 68, 68, 0.2);
}

body.dark-mode .learn-card-icon.inversion {
    background: rgba(59, 130, 246, 0.2);
}

body.dark-mode .learn-card-icon.retrograde {
    background: rgba(34, 197, 94, 0.2);
}

body.dark-mode .learn-card-icon.ri {
    background: rgba(168, 85, 247, 0.2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .key-concepts {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .controls-row {
        flex-direction: column;
        gap: 10px;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .matrix-table th,
    .matrix-table td {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    .prime-note {
        width: 42px;
        height: 42px;
        font-size: 15px;
    }

    .row-info-note {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .composer {
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .key-concepts {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .concept {
        padding: 12px 8px;
    }

    .concept-label {
        font-size: 20px;
    }

    .concept-name {
        font-size: 11px;
    }

    .concept-desc {
        font-size: 10px;
    }

    .intro-card {
        padding: 16px;
    }

    .intro-title {
        font-size: 18px;
    }

    .intro-text {
        font-size: 14px;
    }

    .matrix-container {
        padding: 10px;
    }

    .matrix-table th,
    .matrix-table td {
        width: 28px;
        height: 28px;
        font-size: 10px;
        border-radius: 4px;
    }

    .prime-row {
        padding: 12px;
        gap: 4px;
    }

    .prime-note {
        width: 36px;
        height: 36px;
        font-size: 13px;
        border-radius: 6px;
    }

    .prime-note .note-index {
        font-size: 8px;
    }

    .row-info-notes {
        gap: 4px;
        padding: 12px;
    }

    .row-info-note {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .learn-card {
        padding: 16px;
    }

    .learn-card-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .composers-list {
        flex-direction: column;
        align-items: stretch;
    }

    .composer {
        min-width: 0;
    }
}
