/* music.css — the public Music Theory library (/musictheory).

   Paper and ink. Reading surface is manuscript ivory; chrome (header band, footer) is ebony; the
   single accent is a concert-hall crimson. Cormorant Garamond carries titles and grade numerals,
   Literata carries the long-form body. The only ornament is the five-line staff, and the only
   numbered device is the grade ladder — because the grades really are a sequence. No motion. */

:root {
  --ebony: #141216;
  --ebony-2: #211e24;
  --ivory: #f4efe4;
  --ivory-2: #ebe4d5;
  --ink: #1e1b17;
  --ink-2: #6a625a;
  --rule: #c9c1b1;
  --crimson: #9e2a3a;
  --crimson-2: #7d1f2d;
  --gold: #b08a3e;
  --serif-display: 'Cormorant Garamond', 'Georgia', serif;
  --serif-text: 'Literata', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --measure: 68ch;
  --wrap: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.mt {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--serif-text);
  font-size: 17px;
  line-height: 1.65;
  font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 600px) { body.mt { font-size: 16px; } }

/* Links inside prose are crimson and underlined; navigation, the staff, the outline and every
   list row set their own look, so the prose rule is scoped to the prose containers only. */
.mt-body a, .mt-intro a, .mt-section-lede a, .mt-empty p a, .mt-foot a, .mt-guide-download {
  color: var(--crimson); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em;
}
.mt-body a:hover, .mt-intro a:hover, .mt-section-lede a:hover, .mt-empty p a:hover, .mt-foot a:hover, .mt-guide-download:hover { color: var(--crimson-2); }
.mt :focus-visible { outline: 2px solid var(--crimson); outline-offset: 3px; border-radius: 2px; }
.mt img { max-width: 100%; height: auto; }

.mt-wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: clamp(18px, 4vw, 40px); }

/* ---------- header band ---------- */
.mt-band { background: var(--ebony); color: var(--ivory); }
.mt-band-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; }
.mt-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ivory); text-decoration: none; font-family: var(--serif-display); font-size: 1.45rem; font-weight: 600; letter-spacing: 0.01em; }
.mt-brand:hover { color: var(--ivory); }
.mt-clef { width: 18px; height: 30px; fill: var(--gold); flex: none; }
.mt-nav { display: flex; gap: 22px; }
.mt-nav a { color: var(--ivory); text-decoration: none; font-size: 0.95rem; opacity: 0.85; }
.mt-nav a:hover { opacity: 1; text-decoration: underline; color: var(--ivory); }

/* ---------- hero with the grade staff ---------- */
.mt-hero { background: var(--ebony-2); color: var(--ivory); padding: clamp(36px, 6vw, 72px) 0 clamp(30px, 5vw, 56px); }
.mt-title { font-family: var(--serif-display); font-weight: 600; font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: 1.02; margin: 0 0 14px; letter-spacing: -0.01em; }
.mt-tagline { font-size: clamp(1.05rem, 1.6vw, 1.25rem); max-width: 60ch; margin: 0; color: #d8d1c3; }
.mt-intro { max-width: var(--measure); margin-top: 26px; color: #d8d1c3; }
.mt-intro p { margin: 0 0 1em; }

.mt-staff { margin-top: clamp(30px, 5vw, 54px); }
.mt-staff-caption { display: block; font-family: var(--serif-display); font-style: italic; font-size: 1.15rem; color: #d8d1c3; margin-bottom: 18px; }
/* Five lines drawn with a repeating gradient; each note rises one half-step per grade. */
.mt-staff-lines {
  --line-gap: 14px;
  position: relative; list-style: none; margin: 0; padding: 0;
  height: calc(var(--line-gap) * 4 + 2px + 52px);
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-items: end;
  background-image: repeating-linear-gradient(to bottom, rgba(244, 239, 228, 0.55) 0 1px, transparent 1px var(--line-gap));
  background-size: 100% calc(var(--line-gap) * 4 + 1px);
  background-repeat: no-repeat;
  background-position: 0 0;
}
.mt-note { position: relative; height: 100%; }
.mt-note a {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--ivory); text-decoration: none;
}
.mt-note-head {
  display: block; width: 18px; height: 13px; border-radius: 50%; background: var(--ivory);
  transform: rotate(-20deg);
  /* grade 1 sits on the bottom line, grade 8 above the top: one half-space per step */
  margin-bottom: calc(var(--step, 0) * (var(--line-gap) / 2) + 52px - 13px + 2px);
}
.mt-note-head::after { content: ""; position: absolute; right: 1px; bottom: 5px; width: 1.5px; height: 36px; background: var(--ivory); transform: rotate(20deg); transform-origin: bottom right; }
.mt-note-label { position: absolute; bottom: 0; font-family: var(--serif-display); font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.mt-note a:hover .mt-note-head, .mt-note a:hover .mt-note-head::after { background: var(--gold); }
.mt-note a:hover .mt-note-label { color: var(--gold); }
@media (max-width: 600px) {
  .mt-staff-lines { --line-gap: 11px; }
  .mt-note-label { font-size: 1rem; }
  .mt-note-word { display: none; }              /* eight "Grade N" labels collide at phone width: numerals only */
  .mt-note-head { width: 14px; height: 10px; margin-bottom: calc(var(--step, 0) * (var(--line-gap) / 2) + 52px - 10px + 2px); }
  .mt-note-head::after { height: 28px; }
}

/* ---------- landing sections ---------- */
.mt-main { padding-block: clamp(28px, 4vw, 48px) 64px; }   /* padding-block only: the sides come from .mt-wrap */
.mt-section + .mt-section { margin-top: clamp(40px, 6vw, 72px); }
.mt-section-title { font-family: var(--serif-display); font-weight: 600; font-size: clamp(2rem, 3.4vw, 2.6rem); line-height: 1.1; margin: 0 0 8px; }
.mt-section-lede { color: var(--ink-2); max-width: var(--measure); margin: 0 0 18px; }
.mt-category { margin-top: 26px; }
.mt-category-title {
  font-family: var(--serif-display); font-style: italic; font-weight: 500; font-size: 1.5rem; color: var(--ink);
  margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}

.mt-guides, .mt-downloads { list-style: none; margin: 0; padding: 0; }
.mt-guide { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.mt-guide:last-child { border-bottom: 0; }
.mt-guide-link { display: flex; gap: 16px; align-items: baseline; color: var(--ink); text-decoration: none; min-width: 0; }
.mt-guide-link:hover .mt-guide-title { color: var(--crimson); text-decoration: underline; text-underline-offset: 0.16em; }
.mt-grade { font-family: var(--serif-display); font-weight: 600; font-size: 2rem; line-height: 1; color: var(--gold); flex: none; width: 1.3em; text-align: right; font-variant-numeric: lining-nums; }
.mt-guide-text { display: block; min-width: 0; }
.mt-guide-title { display: block; font-family: var(--serif-display); font-weight: 600; font-size: 1.35rem; line-height: 1.2; }
.mt-guide-summary { display: block; color: var(--ink-2); font-size: 0.96rem; margin-top: 4px; max-width: var(--measure); }
.mt-guide-download { font-size: 0.92rem; white-space: nowrap; }
.mt-guides-compact .mt-guide { padding: 8px 0; }
@media (max-width: 720px) {
  .mt-guide { grid-template-columns: 1fr; }
  .mt-guide-download { white-space: normal; }
}

.mt-download { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.mt-download:last-child { border-bottom: 0; }
.mt-download a { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; text-decoration: none; color: var(--ink); }
.mt-download a:hover .mt-download-title { color: var(--crimson); text-decoration: underline; text-underline-offset: 0.16em; }
.mt-download-title { font-weight: 500; }
.mt-download-meta { color: var(--ink-2); font-size: 0.92rem; white-space: nowrap; }
@media (max-width: 600px) { .mt-download a { flex-direction: column; gap: 2px; } .mt-download-meta { white-space: normal; } }

.mt-empty { max-width: var(--measure); padding: 24px 0; }
.mt-empty h1, .mt-empty h2 { font-family: var(--serif-display); font-weight: 600; font-size: 2rem; margin: 0 0 8px; }
.mt-empty p { color: var(--ink-2); }

.mt-button {
  display: inline-block; background: var(--crimson); color: var(--ivory); text-decoration: none;
  padding: 10px 18px; border-radius: 3px; font-weight: 500; font-size: 0.98rem;
}
.mt-button:hover { background: var(--crimson-2); color: var(--ivory); }

/* ---------- guide page ---------- */
.mt-guide-head { background: var(--ivory-2); border-bottom: 1px solid var(--rule); padding: clamp(24px, 4vw, 44px) 0 clamp(22px, 3vw, 34px); }
.mt-crumbs { font-size: 0.92rem; color: var(--ink-2); display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mt-crumbs a { color: var(--ink-2); }
.mt-crumbs a:hover { color: var(--crimson); }
.mt-guide-h1 { font-family: var(--serif-display); font-weight: 600; font-size: clamp(2.2rem, 4.6vw, 3.4rem); line-height: 1.05; margin: 0; max-width: 30ch; letter-spacing: -0.01em; }
.mt-guide-lede { max-width: var(--measure); color: var(--ink-2); font-size: 1.05rem; margin: 14px 0 0; }
.mt-guide-actions { margin: 20px 0 0; }

.mt-reader { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; padding-block: clamp(24px, 3vw, 40px) 64px; }
@media (min-width: 960px) {
  .mt-reader { grid-template-columns: 260px minmax(0, 1fr); gap: clamp(32px, 4vw, 64px); align-items: start; }
  .mt-toc { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
}
.mt-toc { border-left: 2px solid var(--rule); padding-left: 16px; font-size: 0.92rem; }
.mt-toc summary { font-family: var(--serif-display); font-style: italic; font-size: 1.15rem; cursor: pointer; list-style: none; margin-bottom: 8px; }
.mt-toc summary::-webkit-details-marker { display: none; }
.mt-toc summary::before { content: "▸ "; color: var(--ink-2); font-style: normal; font-size: 0.8em; }
.mt-toc[open] summary::before { content: "▾ "; }
.mt-toc-list { list-style: none; margin: 0; padding: 0; }
.mt-toc-list li { margin: 0 0 7px; line-height: 1.35; }
.mt-toc-list a { color: var(--ink); text-decoration: none; }
.mt-toc-list a:hover { color: var(--crimson); text-decoration: underline; }
.mt-toc-h3 { padding-left: 16px; color: var(--ink-2); }
.mt-toc-h3 a { color: var(--ink-2); }
@media (max-width: 959px) { .mt-toc nav { max-height: 40vh; overflow: auto; } }

.mt-body { max-width: var(--measure); min-width: 0; }
.mt-body > :first-child { margin-top: 0; }
.mt-body h2, .mt-body h3, .mt-body h4 { font-family: var(--serif-display); font-weight: 600; line-height: 1.15; color: var(--ink); scroll-margin-top: 20px; }
.mt-body h2 { font-size: 2rem; margin: 2.2em 0 0.6em; padding-top: 0.6em; border-top: 1px solid var(--rule); }
.mt-body hr + h2 { border-top: 0; padding-top: 0; margin-top: 1.2em; }   /* the guides rule their own sections; never two rules */
.mt-body h3 { font-size: 1.5rem; margin: 1.8em 0 0.5em; }
.mt-body h4 { font-size: 1.2rem; margin: 1.5em 0 0.4em; }
.mt-body p, .mt-body ul, .mt-body ol { margin: 0 0 1.1em; }
.mt-body li { margin-bottom: 0.35em; }
.mt-body li > p { margin-bottom: 0.5em; }
.mt-body hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.mt-body blockquote { margin: 1.4em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--gold); color: var(--ink-2); font-style: italic; }
.mt-body blockquote p:last-child { margin-bottom: 0; }
.mt-body code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.88em; background: var(--ivory-2); padding: 0.1em 0.35em; border-radius: 3px; }
.mt-body pre { background: var(--ivory-2); padding: 14px 16px; border-radius: 4px; overflow: auto; line-height: 1.5; }
.mt-body pre code { background: none; padding: 0; font-size: 0.86em; }
.mt-body table { border-collapse: collapse; width: 100%; margin: 1.4em 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.mt-body th, .mt-body td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.mt-body th { font-weight: 600; border-bottom: 2px solid var(--ink); }
.mt-body img { display: block; margin: 1.4em auto; background: #fff; padding: 6px; border: 1px solid var(--rule); border-radius: 3px; }
.mt-body a { word-break: break-word; }
.mt-body strong { font-weight: 600; }
.mt-body .footnotes { font-size: 0.92rem; color: var(--ink-2); border-top: 1px solid var(--rule); margin-top: 2em; padding-top: 1em; }

.mt-siblings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 3em; padding-top: 1.4em; border-top: 1px solid var(--rule); }
.mt-sibling { display: block; text-decoration: none; color: var(--ink); }
.mt-sibling-next { text-align: right; grid-column: 2; }
.mt-sibling-prev { grid-column: 1; }
.mt-sibling-label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 2px; }
.mt-sibling-title { display: block; font-family: var(--serif-display); font-weight: 600; font-size: 1.25rem; line-height: 1.2; }
.mt-sibling:hover .mt-sibling-title { color: var(--crimson); text-decoration: underline; text-underline-offset: 0.14em; }
@media (max-width: 600px) { .mt-siblings { grid-template-columns: 1fr; } .mt-sibling-next { grid-column: 1; text-align: left; } }

/* ---------- footer ---------- */
.mt-foot { background: var(--ebony); color: #b7b0a3; padding: 26px 0 34px; font-size: 0.9rem; }
.mt-foot p { margin: 0; max-width: var(--measure); }

@media print {
  .mt-band, .mt-foot, .mt-toc, .mt-siblings, .mt-guide-actions { display: none; }
  body.mt { background: #fff; color: #000; font-size: 11pt; }
  .mt-guide-head { background: none; border: 0; }
  .mt-body img { border: 0; padding: 0; }
}
