/* =========================================================================
   Piano Note Trainers — shared design system
   A small suite of keyboard note-naming trainers, styled like stage
   lighting falling across a piano: dark stage, ivory keys, brass trim.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* -- palette -- */
  --stage:        #15151a;
  --stage-raised: #1e1f26;
  --stage-line:   #33343d;
  --ivory:        #f6f2ea;
  --ivory-dim:    #cfc9bd;
  --ink:          #15151a;
  --brass:        #c9a227;
  --brass-bright: #e4c04f;
  --brass-dim:    #8a7128;
  --good:         #3fae5c;
  --bad:          #d1495b;
  --info:         #3b82c4;

  /* -- type -- */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

  /* -- layout -- */
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,0.45);
  --nav-height: 64px;
  --max-width: 1080px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--ivory);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

p { line-height: 1.6; }

a { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================== Top navigation ============================ */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--stage);
  color: var(--ivory);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
}

.site-nav__inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ivory);
  white-space: nowrap;
}

.site-nav__brand-mark {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav__links a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ivory-dim);
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, background 150ms ease;
}

.site-nav__links a:hover {
  color: var(--ivory);
  background: rgba(255,255,255,0.06);
}

.site-nav__links a.is-active {
  color: var(--brass-bright);
  background: rgba(201,162,39,0.12);
}

/* ---- Grouped dropdown menus (Note Names / Scales / Chords) ---- */

.site-nav__group {
  position: relative;
}

.site-nav__group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ivory-dim);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.site-nav__group-toggle:hover {
  color: var(--ivory);
  background: rgba(255,255,255,0.06);
}

.site-nav__group-toggle.is-active {
  color: var(--brass-bright);
  background: rgba(201,162,39,0.12);
}

.site-nav__chevron {
  transition: transform 150ms ease;
}

.site-nav__group.is-open .site-nav__chevron {
  transform: rotate(180deg);
}

.site-nav__dropdown {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 200px;
  background: var(--stage);
  border: 1px solid var(--stage-line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 110;
}

.site-nav__group.is-open .site-nav__dropdown {
  display: block;
}

.site-nav__dropdown a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ivory-dim);
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease;
}

.site-nav__dropdown a:hover {
  color: var(--ivory);
  background: rgba(255,255,255,0.06);
}

.site-nav__dropdown a.is-active {
  color: var(--brass-bright);
  background: rgba(201,162,39,0.12);
}

/* Grouped dropdown (currently just Chords): non-clickable sub-headings
   plus a wider, multi-column layout so 50+ links don't turn into one
   giant single-column scroll. */
.site-nav__dropdown--grouped {
  min-width: 560px;
  columns: 2;
  column-gap: 0.5rem;
  max-height: 80vh;
  overflow-y: auto;
}

.site-nav__dropdown-heading {
  break-inside: avoid;
  break-after: avoid;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
  padding: 0.6rem 0.7rem 0.2rem;
  margin-top: 0.2rem;
  white-space: nowrap;
}

.site-nav__dropdown-heading:first-child {
  margin-top: 0;
}

.site-nav__toggle {
  display: none;
  background: none;
  border: 1px solid var(--stage-line);
  border-radius: 8px;
  color: var(--ivory);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.site-nav__toggle span,
.site-nav__toggle span::before,
.site-nav__toggle span::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ivory);
  position: relative;
  transition: transform 150ms ease, opacity 150ms ease;
}

.site-nav__toggle span::before { position: absolute; top: -6px; }
.site-nav__toggle span::after  { position: absolute; top: 6px; }

@media (max-width: 760px) {
  .site-nav__toggle { display: inline-flex; }

  .site-nav__links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--stage);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 1rem 1rem;
    display: none;
    border-top: 1px solid var(--stage-line);
  }

  .site-nav__links.is-open { display: flex; }

  .site-nav__links > li > a {
    border-radius: 8px;
    padding: 0.75rem;
  }

  /* Group buttons become full-width accordion headers, and their
     dropdowns become an inline expanding panel instead of a floating
     popover. */
  .site-nav__group-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 8px;
  }

  .site-nav__dropdown {
    display: none;
    position: static;
    box-shadow: none;
    border: none;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    margin: 0.15rem 0 0.35rem;
    padding: 0.15rem;
    min-width: 0;
  }

  .site-nav__group.is-open .site-nav__dropdown {
    display: block;
  }

  .site-nav__dropdown a {
    padding: 0.65rem 0.75rem 0.65rem 1.5rem;
  }

  .site-nav__dropdown--grouped {
    min-width: 0;
    columns: 1;
    max-height: none;
    overflow-y: visible;
  }

  .site-nav__dropdown-heading {
    padding-left: 0.75rem;
  }
}

/* ============================ Page shell =============================== */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-dim);
  font-weight: 600;
}

.page-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-top: 0.35rem;
}

.page-header p {
  color: #4b4a45;
  max-width: 60ch;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: #7a776c;
  font-size: 0.85rem;
}

.site-footer a { color: var(--brass-dim); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* =============================== Cards ================================= */

.card {
  background: #fffdf9;
  border: 1px solid #e7e1d3;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

.card + .card { margin-top: 0; }

.stack { display: flex; flex-direction: column; gap: 1.25rem; }

.now-playing {
  text-align: center;
  background: var(--stage);
  color: var(--ivory);
  border: none;
}

.now-playing .eyebrow { color: var(--ivory-dim); }

.now-playing__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 8vw, 4rem);
  color: var(--brass-bright);
  line-height: 1;
  margin: 0.35rem 0;
}

.now-playing__sub {
  font-size: 1.05rem;
  color: var(--ivory-dim);
}

.now-playing__note {
  font-size: 0.85rem;
  color: var(--ivory-dim);
  margin-top: 0.35rem;
}

.progression-blurb {
  font-weight: 700;
  color: var(--info);
  font-size: 1.02rem;
  line-height: 1.6;
  padding: 0 0.1rem;
}

/* ========================== Form controls =============================== */

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 140px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #55534c;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field select,
.field input[type="number"] {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #d8d2c3;
  background: #fff;
  color: var(--ink);
}

.field select:focus,
.field input:focus,
button:focus-visible,
.piano-key:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 1px;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
}

.segmented {
  display: inline-flex;
  border: 1px solid #d8d2c3;
  border-radius: 999px;
  overflow: hidden;
}

.segmented button {
  border: none;
  background: #fff;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #55534c;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--ink);
  color: var(--ivory);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 100ms ease, filter 150ms ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--ink); color: var(--ivory); }
.btn-success { background: var(--good); color: #fff; }
.btn-danger  { background: var(--bad); color: #fff; }
.btn-ghost   { background: #efeadf; color: var(--ink); }
.btn-toggle  { background: #efeadf; color: var(--ink); }
.btn-toggle.is-on { background: var(--info); color: #fff; }

.btn:hover:not(:disabled) { filter: brightness(1.07); }

.letter-btn {
  width: 3.2rem;
  height: 2.6rem;
  border-radius: 8px;
  border: none;
  background: #efeadf;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.letter-btn:hover:not(:disabled) { background: #e2dbc8; }
.letter-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.letter-btn.is-active { background: var(--ink); color: var(--ivory); }

/* ================================ Alerts ================================ */

.alert {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.alert-warning { background: #fbeecb; color: #6b4c05; }
.alert-info    { background: #dcebf8; color: #17456b; }
.alert-success { background: #dff2e3; color: #1c5f31; }
.alert-danger  { background: #fbdfe1; color: #7d1f2a; }

/* =============================== Progress =============================== */

.progress {
  width: 100%;
  max-width: 480px;
  margin: 0.75rem auto 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--brass);
  transition: width 160ms ease;
}

/* ============================= Piano keyboard ============================ */

.piano-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 6px;
}

.piano-inner {
  position: relative;
  width: 100%;
  min-width: 1180px; /* keeps all 8 octaves of keys legible/tappable; scrolls on narrow screens */
  max-width: 1600px;
}

.piano-svg {
  width: 100%;
  height: auto;
  display: block;
}

.piano-key {
  stroke: #262620;
  stroke-width: 1;
  transition: fill 120ms ease;
}

.piano-key-white { fill: #fffdf9; }
.piano-key-black { fill: #1c1c22; }

.piano-key-tonic.piano-key-white { fill: #f1e2b3; }
.piano-key-tonic.piano-key-black { fill: #6b551a; }

.piano-key-active.piano-key-white,
.piano-key-active.piano-key-black {
  fill: var(--good);
}

/* Two-hand highlighting (Power in the Blood Song Trainer and any future
   lesson that plays a right-hand melody and a left-hand chord together):
   melody notes light up brass/gold, chord notes light up blue, so a
   learner can see at a glance which hand plays which key. */
.piano-key-melody.piano-key-white,
.piano-key-melody.piano-key-black {
  fill: var(--brass-bright);
}

.piano-key-chord.piano-key-white,
.piano-key-chord.piano-key-black {
  fill: var(--info);
}

.piano-key-clickable { cursor: pointer; }

.hand-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ivory-dim);
  margin: 0.5rem 0 0;
}

.hand-legend__item { display: inline-flex; align-items: center; gap: 0.4rem; }

.hand-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.hand-legend__swatch--melody { background: var(--brass-bright); }
.hand-legend__swatch--chord { background: var(--info); }

.piano-key-label {
  position: absolute;
  top: 87%;
  transform: translate(0, -50%);
  text-align: center;
  font-family: var(--font-mono);
  font-size: clamp(9px, 2.4vw, 13px);
  font-weight: 600;
  color: #4b4a45;
  pointer-events: none;
  user-select: none;
}

.piano-key-label-black {
  top: 52%;
  color: var(--ivory-dim);
}

.piano-key-label-active { color: #ffffff; }

/* ================================ Tables ================================ */

.data-table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #ece6d8;
  font-family: var(--font-mono);
}

.data-table th {
  font-family: var(--font-body);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a776c;
}

.data-table tr.is-current td { background: #f1e2b3; }

.data-table tr.is-minor-row td { background: #eef3f9; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
}

.pill-major { background: #f1e2b3; color: #6b551a; }
.pill-minor { background: #dcebf8; color: #17456b; }
.pill-dom7 { background: #f6d9c4; color: #7a3a12; }
.pill-dim7 { background: #e5dcf3; color: #402a70; }

/* ================================= Tabs ================================= */

.tabbar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #e7e1d3;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tabbar button {
  border: none;
  background: none;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  color: #8b8878;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabbar button.is-active {
  color: var(--ink);
  border-bottom-color: var(--brass);
}

.tabpanel { display: none; }
.tabpanel.is-active { display: block; }

/* =============================== Homepage =============================== */

.hero {
  background: var(--stage);
  color: var(--ivory);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem 1.5rem;
  margin-bottom: 2rem;
  overflow: hidden;
}

.hero__inner {
  max-width: 640px;
  margin: 0 auto 1.75rem;
  text-align: center;
}

.hero .eyebrow { color: var(--brass-bright); }

.hero h1 {
  color: var(--ivory);
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin-top: 0.4rem;
}

.hero p {
  color: var(--ivory-dim);
  margin: 0.75rem auto 0;
}

.hero-keyboard {
  max-width: 820px;
  margin: 0 auto;
}

.hero-keyboard .piano-key-white { fill: #f6f2ea; }
.hero-keyboard .piano-key-label { color: #4b4a45; }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
}

.lesson-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #fffdf9;
  border: 1px solid #e7e1d3;
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.lesson-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--brass);
}

.lesson-card__tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass-dim);
  font-weight: 600;
}

.lesson-card h2 {
  font-size: 1.25rem;
  margin: 0;
}

.lesson-card p {
  font-size: 0.9rem;
  color: #5b594f;
  margin: 0;
}

.lesson-card__cta {
  margin-top: auto;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}

.about-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e7e1d3;
}

.about-strip .card { flex: 1 1 220px; margin: 0; }

/* score / status rows */

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #55534c;
}

@media (max-width: 640px) {
  .card { padding: 1rem; }
  .controls-row { gap: 0.9rem; }
  .field { min-width: 47%; flex: 1 1 47%; }
}
