/* RudyOnMars — shared styles
   One place to change the look of every page.
   Colour roles: gold = chord tones / UI accent, teal = root note / selected key. */

:root {
  --ink: #0a0a09;
  --panel: #12110f;
  --raise: #1a1815;
  --rule: #2a2620;
  --rule-strong: #3d372c;

  --ivory: #ebe5d7;
  --stone: #a59c8a;   /* secondary text, 7:1 on --ink */
  --dim: #857c6b;     /* tertiary text, 4.8:1 on --ink */

  --gold: #c9a14f;
  --gold-hi: #e0b962;
  --teal: #3bb3a4;    /* root note. Change this one value to recolour every root. */
  --teal-deep: #17665d;

  --display: 'Bebas Neue', 'Arial Narrow', Impact, sans-serif;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Apple Symbols', 'Segoe UI Symbol', 'DejaVu Sans Mono', monospace;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 62ch;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--ivory);
  font: 500 1.25rem/1.5 var(--serif);
  overflow-x: hidden;
}

main { flex: 1 0 auto; }
img, svg { max-width: 100%; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 400; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--gold); color: var(--ink);
  padding: .6rem 1rem; font: 500 .9rem var(--mono);
}
.skip:focus { left: 0; }

/* ---------- Header ---------- */

.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 2rem; padding-block: 1.15rem;
}
.brand {
  font: 400 1.85rem/1 var(--display); letter-spacing: .08em;
  color: var(--gold); text-decoration: none;
}
.brand span { color: var(--ivory); }
.main-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.75rem; }
.main-nav a {
  font: 400 .95rem var(--mono); color: var(--stone); text-decoration: none;
  padding: .4rem 0; border-bottom: 1px solid transparent;
}
.main-nav a:hover { color: var(--ivory); }
.main-nav a[aria-current] { color: var(--ivory); border-bottom-color: var(--gold); }

/* Tool switcher, shown under the header on every tool page */
.toolbar { border-bottom: 1px solid var(--rule); background: var(--panel); }
.toolbar ul {
  display: flex; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter);
  overflow-x: auto; scrollbar-width: thin;
}
.toolbar a {
  display: block; white-space: nowrap; padding: .85rem 1.15rem;
  font: 400 .9rem var(--mono); color: var(--stone); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.toolbar li:first-child a { padding-left: 0; }
.toolbar a:hover { color: var(--ivory); }
.toolbar a[aria-current] { color: var(--ivory); border-bottom-color: var(--gold); }

/* ---------- Headings ---------- */

.page-title, .tool-head h1 {
  font: 400 clamp(3rem, 7.5vw, 5.75rem)/.92 var(--display);
  letter-spacing: .02em;
}
.tool-head { padding-block: clamp(2.25rem, 6vw, 4.25rem) clamp(1.5rem, 3vw, 2.25rem); }
.lede { margin-top: 1.1rem; max-width: var(--measure); color: var(--stone); font-size: 1.35rem; line-height: 1.45; }
.section-title { font: 400 clamp(2rem, 4vw, 2.75rem)/1 var(--display); letter-spacing: .03em; }

.field-label { font: 400 .85rem var(--mono); color: var(--stone); margin-bottom: .6rem; }

/* ---------- Buttons and chips ---------- */

.btn {
  display: inline-block; cursor: pointer; text-decoration: none; text-align: center;
  font: 500 .92rem/1.2 var(--mono);
  padding: .85rem 1.35rem; border-radius: 2px;
  background: var(--gold); color: var(--ink); border: 1px solid var(--gold);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn-quiet { background: transparent; color: var(--ivory); border-color: var(--rule-strong); }
.btn-quiet:hover { background: transparent; border-color: var(--gold); color: var(--gold-hi); }
.btn.is-playing { background: var(--teal); border-color: var(--teal); }

.text-link { color: var(--ivory); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: .28em; text-decoration-thickness: 1px; }
.text-link:hover { color: var(--gold-hi); }

.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font: 400 .9rem/1.1 var(--mono);
  min-width: 3.1rem; min-height: 2.6rem; padding: .5rem .75rem;
  background: transparent; border: 1px solid var(--rule-strong); border-radius: 2px;
  color: var(--ivory); cursor: pointer; text-align: center;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--gold); }
.chip small { display: block; font-size: .68rem; color: var(--stone); margin-top: .15rem; }
/* selected root = teal, selected chord type = gold: the same colours the instruments use */
.chip.is-root[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.chip.is-root[aria-pressed="true"] small { color: var(--ink); }
.chip.is-type[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); }

.seg { display: inline-flex; flex-wrap: wrap; }
.seg-btn {
  font: 400 .88rem/1.1 var(--mono); padding: .7rem 1rem; cursor: pointer;
  background: transparent; border: 1px solid var(--rule-strong); margin-left: -1px; color: var(--stone);
}
.seg-btn:first-child { margin-left: 0; border-radius: 2px 0 0 2px; }
.seg-btn:last-child { border-radius: 0 2px 2px 0; }
.seg-btn:hover { color: var(--ivory); }
.seg-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); position: relative; }

.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }

/* ---------- Chord type lists (piano + guitar tools) ---------- */

.tool-body > * + * { margin-top: clamp(1.75rem, 3.5vw, 2.5rem); }

.type-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem 3rem; }
@media (max-width: 720px) { .type-groups { grid-template-columns: 1fr; } }
.group-name { font: italic 600 1.2rem var(--serif); color: var(--stone); margin-bottom: .5rem; }
.type-list { border-top: 1px solid var(--rule); }
.type-btn {
  display: flex; justify-content: space-between; gap: 1rem; width: 100%;
  text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--rule);
  padding: .72rem .6rem; color: var(--stone); font: 400 .9rem/1.3 var(--mono);
}
.type-btn:hover { color: var(--ivory); }
.type-btn .formula { color: var(--dim); white-space: nowrap; }
.type-btn[aria-pressed="true"] {
  color: var(--gold-hi); background: rgba(201, 161, 79, .1); box-shadow: inset 2px 0 0 var(--gold);
}
.type-btn[aria-pressed="true"] .formula { color: var(--gold); }

/* ---------- Readout ---------- */

.readout {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1.25rem 2rem; padding-block: 1.75rem; border-block: 1px solid var(--rule);
}
.readout-name { font: 400 clamp(2.25rem, 5vw, 3.5rem)/1 var(--display); letter-spacing: .03em; }
.readout-name .r { color: var(--teal); }
.readout-notes {
  margin-top: .7rem; font: 400 clamp(1.3rem, 3vw, 1.9rem)/1.3 var(--mono);
  color: var(--gold-hi); letter-spacing: .04em; word-spacing: .3em;
}
.degrees { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.degree { font: 400 .95rem/1.2 var(--mono); border: 1px solid var(--rule-strong); padding: .4rem .7rem; color: var(--ivory); }
.degree i { display: block; font-style: normal; font-size: .74rem; color: var(--stone); }
.degree.is-root { border-color: var(--teal); }
.degree.is-root i { color: var(--teal); }

/* ---------- Keyboard (shared by the home page and the piano tool) ---------- */

.keys { position: relative; display: flex; height: clamp(130px, 24vw, 210px); user-select: none; }
.wk {
  flex: 1 1 0; position: relative;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: .55rem;
  background: #e9e3d5; border: 1px solid #1b1813; border-top: 0; border-radius: 0 0 4px 4px;
  font: 500 clamp(.65rem, 1.7vw, .9rem) var(--mono); color: #7d7565;
  transition: background .12s;
}
.wk.hit { background: var(--gold); color: var(--ink); }
.wk.root { background: var(--teal); color: var(--ink); }
.bk {
  position: absolute; top: 0; z-index: 2; height: 62%; width: calc(100% / 14 * .6);
  transform: translateX(-50%);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: .4rem;
  background: #0f0e0c; border: 1px solid #2c2820; border-top: 0; border-radius: 0 0 3px 3px;
  font: 500 clamp(.55rem, 1.35vw, .72rem) var(--mono); color: var(--ink);
  transition: background .12s;
}
.bk.hit { background: var(--gold-hi); }
.bk.root { background: var(--teal); }

.legend { display: flex; flex-wrap: wrap; gap: .6rem 1.75rem; font: 400 .85rem var(--mono); color: var(--stone); }
.legend span { display: inline-flex; align-items: center; gap: .55rem; }
.legend i { width: .8rem; height: .8rem; border-radius: 50%; background: var(--gold); flex: none; }
.legend i.root { background: var(--teal); }
.legend i.mute { background: transparent; border: 1px solid var(--stone); border-radius: 0; }

.cross-links { display: flex; flex-wrap: wrap; gap: .5rem 2rem; font: 400 .95rem var(--mono); }

/* ---------- Reference table ---------- */

.table-scroll { overflow-x: auto; }
.ref-table { width: 100%; min-width: 34rem; border-collapse: collapse; font: 400 .95rem/1.4 var(--mono); }
.ref-table caption { text-align: left; padding-bottom: .9rem; }
.ref-table th {
  text-align: left; font-weight: 400; font-size: .82rem; color: var(--stone);
  padding: .6rem .6rem; border-bottom: 1px solid var(--rule-strong);
}
.ref-table td { padding: .7rem .6rem; border-bottom: 1px solid var(--rule); }
.ref-table td.f { color: var(--stone); }
.ref-table tr.is-current td { color: var(--gold-hi); background: rgba(201, 161, 79, .09); }
.ref-table tr.grp td { font: italic 600 1.15rem var(--serif); color: var(--stone); border-bottom: 0; padding-top: 1.6rem; }
.table-note { margin-top: .8rem; font: 400 .82rem/1.5 var(--mono); color: var(--dim); max-width: 60ch; }

/* ---------- More tools + footer ---------- */

.more-tools { margin-top: clamp(3rem, 7vw, 5rem); padding-top: 2.5rem; border-top: 1px solid var(--rule); }
.more-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 3rem; margin-top: 1.5rem; }
@media (max-width: 720px) { .more-list { grid-template-columns: 1fr; } }
.more-list li { border-top: 1px solid var(--rule); padding: 1rem 0 1.15rem; }
.more-list a { font: 600 1.35rem/1.2 var(--serif); text-decoration: none; }
.more-list a:hover { color: var(--gold-hi); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: .25em; }
.more-list p { margin-top: .3rem; font-size: 1.1rem; line-height: 1.4; color: var(--stone); }
.more-cta { margin-top: 2rem; color: var(--stone); font-size: 1.2rem; }

.site-footer { border-top: 1px solid var(--rule); margin-top: clamp(3rem, 7vw, 5rem); }
.site-footer .wrap {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem;
  padding-block: 1.75rem; font: 400 .85rem/1.6 var(--mono); color: var(--stone);
}
.footer-links { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--gold-hi); text-decoration: underline; }

@media (max-width: 560px) {
  .lede { font-size: 1.25rem; }
  .brand { font-size: 1.6rem; }
}
