/*
 * The Scales and Intervals theory pages.
 *
 * Laid out like the Key signatures page (same headings, boxes and numbered
 * steps) so the Learn section reads as one book, with what these two add:
 * rows of notes with the steps between them, and cards that play.
 */

.theory-page {
    --tp-mark: #d9480f;          /* a note the text points at (raised, altered) */
    --tp-semitone: #c2255c;
    --tp-tone: var(--nb-primary);
    --tp-wide: #e8590c;
    --tp-surface: rgba(255, 255, 255, .72);
    --tp-surface-soft: rgba(255, 255, 255, .55);
}

/* A global rule centres text and makes .container a centring flex column;
   these pages are read left to right and fill the column. */
.theory-page.container { display: block !important; }
.theory-page .section-heading,
.theory-page .theory-box,
.theory-page .method-step,
.theory-page .scale-card,
.theory-page .iv-card,
.theory-page p { text-align: left; }

.theory-page .section-heading {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .55;
    margin-bottom: .75rem;
}

/* ── Boxes ── */
.theory-box {
    padding: .9rem 1rem;
    border-radius: .75rem;
    background: var(--tp-surface);
    border: 1px solid var(--nb-border-faint);
}
.theory-box p { font-size: .9rem; }
.theory-box-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.theory-badge {
    flex: 0 0 2rem;
    height: 2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: var(--nb-primary);
    color: #fff;
}
.theory-example {
    font-size: .82rem;
    opacity: .75;
    border-left: 3px solid var(--nb-border-faint);
    padding-left: .6rem;
}

/* ── The starting note ── */
.scales-tonic-bar {
    padding: .75rem 1rem;
    border-radius: .75rem;
    background: var(--tp-surface-soft);
    text-align: left;
}
.scales-tonics { display: flex; flex-wrap: wrap; gap: .35rem; }
.scales-tonics .btn { min-width: 3.2rem; }

/* ── Steps and notes ── */
.scale-step {
    display: inline-grid;
    place-items: center;
    min-width: 1.7rem;
    height: 1.4rem;
    padding: 0 .3rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    background: var(--tp-tone);
}
.scale-step-1 { background: var(--tp-semitone); }
.scale-step-3 { background: var(--tp-wide); }

.scale-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem 1.1rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: .85rem;
}
.scale-legend li { display: flex; align-items: center; gap: .35rem; float: none; }
.scale-legend-mark { padding: .1rem .45rem; font-weight: 700; }

/* ── A scale ── */
.scale-card {
    padding: 1rem 1.1rem;
    border-radius: .9rem;
    background: var(--tp-surface);
    border: 1px solid var(--nb-border-faint);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.scale-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .4rem; }
.scale-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.scale-body { font-size: .92rem; line-height: 1.55; }
.scale-direction {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .55;
    margin-top: .4rem;
}

.scale-staff, .iv-staff { overflow: hidden; }
.scale-staff svg, .iv-staff svg { display: block; width: 100%; height: auto; }
/* The note being played, on the staff and in its row. */
.scale-staff .is-playing path, .iv-staff .is-playing path { fill: var(--nb-primary); stroke: var(--nb-primary); }

.scale-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    list-style: none;
    padding: 0;
    margin: .25rem 0 .75rem;
}
.scale-row li { float: none; }
.scale-note {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 2.6rem;
    padding: .2rem .35rem;
    border-radius: .5rem;
    background: var(--tp-surface-soft);
    border: 1px solid var(--nb-border-faint);
    line-height: 1.15;
}
.scale-note-solfa { font-weight: 700; font-size: .85rem; }
.scale-note-letter { font-size: .68rem; opacity: .55; }
.scale-note-letter:empty { display: none; }
.scale-note.is-marked { color: var(--tp-mark); border-color: var(--tp-mark); }
.scale-note.is-playing { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); }

.scale-listen {
    font-size: .85rem;
    opacity: .8;
    border-left: 3px solid var(--nb-primary);
    padding-left: .6rem;
}

.scale-play.is-playing, .mode-play.is-playing,
.iv-play-melodic.is-playing, .iv-play-harmonic.is-playing { opacity: .7; }

/* ── The modes ── */
.modes-table { background: var(--tp-surface); border-radius: .75rem; overflow: hidden; font-size: .88rem; }
.modes-table th, .modes-table td { background: transparent; text-align: left; }
.mode-name { display: block; font-weight: 700; }
.mode-character { display: block; font-weight: 400; font-size: .78rem; opacity: .7; max-width: 22rem; }
.mode-degree { font-weight: 700; color: var(--nb-primary); }
.mode-steps { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; white-space: nowrap; }
.mode-notes { white-space: nowrap; }

/* ── Intervals ── */
.iv-ladder {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: .25rem;
}
.iv-ladder li {
    flex: 1 1 0;
    float: none;
    text-align: center;
    font-size: .78rem;
    padding: .3rem .2rem;
    border-radius: .4rem;
    background: var(--tp-surface-soft);
    border: 1px solid var(--nb-border-faint);
}
.iv-ladder li.is-main { background: var(--nb-primary); color: #fff; font-weight: 700; border-color: var(--nb-primary); }

.iv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: .75rem;
}
.iv-card {
    display: flex;
    flex-direction: column;
    padding: .8rem .9rem;
    border-radius: .9rem;
    background: var(--tp-surface);
    border: 1px solid var(--nb-border-faint);
}
.iv-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.iv-name { font-size: 1rem; font-weight: 700; margin: 0; }
.iv-name::first-letter { text-transform: uppercase; }
.iv-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .78rem;
    font-weight: 700;
    color: var(--nb-primary);
}
.iv-staff { max-width: 170px; margin: .2rem 0; }
.iv-facts { display: flex; flex-wrap: wrap; gap: .2rem .7rem; font-size: .8rem; }
.iv-notes { font-weight: 700; }
.iv-semitones, .iv-tones { opacity: .7; }
.iv-character { font-size: .82rem; opacity: .8; margin: .4rem 0 .6rem; flex: 1; }
.iv-buttons { display: flex; flex-wrap: wrap; gap: .35rem; }

.iv-inversions { list-style: none; padding: 0; margin: 0; }
.iv-inversions li {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    float: none;
    padding: .45rem .75rem;
    margin-bottom: .3rem;
    border-radius: .5rem;
    background: var(--tp-surface-soft);
    font-size: .88rem;
    text-align: left;
}
.iv-pair { flex: 0 0 5.5rem; white-space: nowrap; }

/* ── The numbered steps, as on the Key signatures page ── */
.theory-page .method-list { list-style: none; padding: 0; margin: 0; }
.theory-page .method-step {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    float: none;
    width: 100%;
    padding: .7rem .9rem;
    border-radius: .6rem;
    background: var(--tp-surface-soft);
    margin-bottom: .4rem;
}
.theory-page .method-number {
    flex: 0 0 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .85rem;
    background: var(--nb-primary);
    color: #fff;
}
.theory-page .method-body { display: flex; flex-direction: column; }
.theory-page .method-title { font-weight: 600; }
.theory-page .method-desc { font-size: .85rem; opacity: .7; line-height: 1.45; }

@media (max-width: 575.98px) {
    .scale-card { padding: .8rem; }
    .scale-note { min-width: 2.2rem; }
    .iv-inversions li { flex-direction: column; gap: .15rem; }
}

@media (prefers-reduced-motion: no-preference) {
    .scale-note, .scale-staff path, .iv-staff path { transition: background-color .12s ease, fill .12s ease; }
}

/* ── Road-map signs ── */
/* Noto Music last, so letters keep the body font and only the musical symbols
   a system lacks (𝄋, 𝄌, 𝄆 on Apple devices) are drawn with it. */
.theory-page { font-family: var(--bs-body-font-family), 'Noto Music'; }

.rm-signs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: .6rem;
}
.rm-sign {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    padding: .7rem .85rem;
    border-radius: .75rem;
    background: var(--tp-surface);
    border: 1px solid var(--nb-border-faint);
    text-align: left;
}
.rm-glyph {
    flex: 0 0 4.2rem;
    min-height: 2.6rem;
    display: grid;
    place-items: center;
    border-radius: .55rem;
    background: var(--tp-surface-soft);
    border: 1px solid var(--nb-border-faint);
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-weight: 700;
    font-size: .95rem;
    color: var(--nb-primary);
    text-align: center;
    line-height: 1.1;
    padding: .2rem;
}
.rm-glyph-music {
    font-family: 'Noto Music', 'Segoe UI Symbol', 'Apple Symbols', serif;
    font-style: normal;
    font-weight: 400;
    font-size: 1.9rem;
    font-variant-emoji: text;
}

.rm-staff { overflow: hidden; }
.rm-staff svg { display: block; width: 100%; height: auto; }
.rm-bar { fill: transparent; stroke: none; transition: fill .15s ease; }
.rm-bar.is-playing { fill: rgba(26, 110, 138, .16); }  /* --nb-primary, faint */

.rm-path-wrap { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; }
.rm-path-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .55;
}
.rm-path { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.rm-step {
    float: none;
    min-width: 1.8rem;
    height: 1.8rem;
    display: grid;
    place-items: center;
    border-radius: .45rem;
    font-weight: 700;
    font-size: .85rem;
    background: var(--tp-surface-soft);
    border: 1px solid var(--nb-border-faint);
}
.rm-step.is-playing { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); }
.iv-inversions .theory-badge { flex: 0 0 1.6rem; height: 1.6rem; font-size: .8rem; }
