/* ============================================================
   TENSIMUSIC MUSIC LESSON — Design System
   Theme: Deep Navy × Gold
   ============================================================ */

:root {
  --navy-900: #060d1a;
  --navy-800: #0a1628;
  --navy-700: #111e35;
  --navy-600: #1a2e4a;
  --navy-500: #243d60;
  --navy-400: #2e4d78;

  --gold-500: #c9920a;
  --gold-400: #d4a017;
  --gold-300: #e8b832;
  --gold-200: #f5d060;
  --gold-100: #fde99a;

  --white:   #ffffff;
  --gray-50: #f8f9fb;
  --gray-100: #eef0f4;
  --gray-200: #d8dce6;
  --gray-400: #8892a4;
  --gray-600: #4a5568;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 24px rgba(212,160,23,0.25);

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--navy-800);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
canvas { display: block; }

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6,13,26,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212,160,23,0.18);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.logo-icon {
  font-size: 36px;
  color: var(--gold-300);
  line-height: 1;
}
.logo-text {
  font-family: var(--font-serif);
  font-size: 25.5px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.08em;
}
.logo-sub {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--gold-400);
  text-transform: uppercase;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-weight: 500;
  color: var(--gray-200);
  transition: var(--transition);
  white-space: nowrap;
}
.nav-link:hover {
  background: rgba(212,160,23,0.12);
  color: var(--gold-300);
}
.nav-link.active {
  background: var(--gold-400);
  color: var(--navy-900);
  font-weight: 600;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.lang-switcher {
  display: flex;
  gap: 4px;
  background: var(--navy-700);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.lang-btn {
  background: none;
  border: none;
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-400);
  transition: var(--transition);
}
.lang-btn.active, .lang-btn:hover {
  background: var(--gold-400);
  color: var(--navy-900);
}
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--gray-200);
  border-radius: 2px;
  transition: var(--transition);
}

/* ── App Main ── */
.app-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Hero ── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  min-height: 380px;
  padding: 48px 0 64px;
}
.hero-badge {
  display: inline-block;
  background: rgba(212,160,23,0.15);
  border: 1px solid rgba(212,160,23,0.35);
  color: var(--gold-300);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 99px;
  margin-bottom: 20px;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(36px, 4.5vw, 58px);
  font-weight: 700;
  line-height: 1.12;
  margin-bottom: 20px;
}
.gold-text { color: var(--gold-300); }
.hero-desc {
  font-size: 16px;
  color: var(--gray-200);
  max-width: 440px;
  margin-bottom: 32px;
  line-height: 1.7;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-700);
  border: 1px solid rgba(212,160,23,0.15);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
#heroStaff { max-width: 100%; height: auto; }

/* ── Features Grid ── */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding-top: 16px;
}
.feature-card {
  background: var(--navy-700);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  transition: var(--transition);
}
.feature-card:hover {
  border-color: rgba(212,160,23,0.4);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}
.feature-icon {
  font-size: 48px;
  margin-bottom: 14px;
  color: var(--gold-300);
}
.feature-card h3 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}
.feature-card p {
  font-size: 20px;
  color: var(--gray-400);
  line-height: 1.6;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 32px;
}
.page-header h2 {
  font-family: var(--font-serif);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gold-200);
}
.page-header p {
  color: var(--gray-400);
  font-size: 15px;
}

/* ── Panel ── */
.panel {
  background: var(--navy-700);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ── Tool Layout ── */
.tool-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
.tool-controls { display: flex; flex-direction: column; gap: 20px; }
.tool-display { display: flex; flex-direction: column; gap: 20px; }

/* ── Control Group ── */
.control-group label {
  display: block;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-400);
  margin-bottom: 10px;
}

/* ── Note Selector ── */
.note-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.note-btn {
  background: var(--navy-600);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: 19.5px;
  font-weight: 600;
  padding: 6px 0;
  width: 42px;
  text-align: center;
  transition: var(--transition);
}
.note-btn:hover { border-color: var(--gold-400); color: var(--gold-300); }
.note-btn.active {
  background: var(--gold-400);
  border-color: var(--gold-400);
  color: var(--navy-900);
}
.note-btn.sharp { font-size: 16.5px; }

/* ── Interval Selector ── */
.interval-selector, .chord-type-selector, .scale-type-selector {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.interval-btn, .chord-type-btn, .scale-type-btn {
  background: var(--navy-600);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--gray-200);
  font-size: 19.5px;
  padding: 8px 12px;
  text-align: left;
  transition: var(--transition);
}
.interval-btn:hover, .chord-type-btn:hover, .scale-type-btn:hover {
  border-color: var(--gold-400);
  color: var(--gold-300);
}
.interval-btn.active, .chord-type-btn.active, .scale-type-btn.active {
  background: rgba(212,160,23,0.15);
  border-color: var(--gold-400);
  color: var(--gold-200);
}

/* ── Toggle Group ── */
.toggle-group {
  display: flex;
  background: var(--navy-600);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.toggle-btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--gray-400);
  font-size: 19.5px;
  font-weight: 500;
  padding: 6px 8px;
  transition: var(--transition);
}
.toggle-btn.active {
  background: var(--gold-400);
  color: var(--navy-900);
  font-weight: 700;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
  transition: var(--transition);
  cursor: pointer;
}
.btn-primary {
  background: var(--gold-400);
  color: var(--navy-900);
}
.btn-primary:hover {
  background: var(--gold-200);
  box-shadow: var(--shadow-gold);
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gold-400);
  color: var(--gold-300);
}
.btn-outline:hover {
  background: rgba(212,160,23,0.12);
}
.btn-ghost {
  background: rgba(255,255,255,0.07);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-full { width: 100%; }
.btn-lg { font-size: 16px; padding: 14px 32px; }

/* ── Info Box ── */
.info-box {
  background: var(--navy-900);
  border: 1px solid rgba(212,160,23,0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  color: var(--gray-200);
  min-height: 60px;
  line-height: 1.6;
}
.info-box strong { color: var(--gold-300); }
.info-box em { color: var(--gray-400); font-style: normal; font-size: 12px; }

/* ── Notation Panel ── */
.notation-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  overflow: hidden;
}
.notation-panel canvas { max-width: 100%; }

/* ── Piano ── */
.piano-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 10px 8px;
  background: #111827;
  border-radius: var(--radius-lg);
}
.piano {
  display: flex;
  position: relative;   /* black keys are absolute inside here */
  height: 140px;
  user-select: none;
  flex-shrink: 0;       /* don't collapse inside overflow container */
}
.piano-key {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
/* White keys: 34px wide (border-box), 1px right-border as divider */
.piano-key.white {
  width: 34px;
  height: 140px;
  background: #f4f4f4;
  border-right: 1px solid #bbb;
  border-bottom: 2px solid #999;
  border-radius: 0 0 4px 4px;
  z-index: 1;
  transition: background 0.07s ease;
}
.piano-key.white:hover { background: #ddeeff; }
.piano-key.white.highlight { background: rgba(212,160,23,0.6) !important; }
.piano-key.white.pressed  { background: #c9920a !important; }

/* Black keys: 22px wide, centered between the flanking white keys */
.piano-key.black {
  width: 22px;
  height: 86px;
  background: #1c1c1e;
  position: absolute;
  top: 0;
  z-index: 2;
  border-radius: 0 0 4px 4px;
  border-bottom: 2px solid #444;
  transition: background 0.07s ease;
}
.piano-key.black:hover { background: #2e2e30; }
.piano-key.black.highlight { background: var(--gold-500) !important; }
.piano-key.black.pressed  { background: var(--gold-400) !important; }

/* C-octave label: bottom-left corner of the white key */
.piano-label {
  position: absolute;
  bottom: 5px;
  left: 3px;
  font-size: 10px;
  font-weight: 700;
  color: #888;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
}
.piano-label-c { color: #555; }

/* ── Circle of Fifths ── */
.circle-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
}
.circle-canvas-wrap {
  display: flex;
  justify-content: center;
}
#circleCanvas { max-width: 100%; cursor: pointer; }
.circle-info h3 {
  font-family: var(--font-serif);
  font-size: 28px;
  margin-bottom: 16px;
}
.circle-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 14px;
}
.circle-detail-row:last-child { border-bottom: none; }
.circle-detail-label { color: var(--gray-400); font-weight: 500; }
.circle-detail-val { color: var(--white); font-weight: 600; }


/* ── Footer ── */
.site-footer {
  background: var(--navy-900);
  border-top: 1px solid rgba(212,160,23,0.12);
  padding: 24px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.footer-logo {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--gold-300);
  font-weight: 700;
}
.site-footer p {
  font-size: 12.5px;
  color: var(--gray-400);
}
.footer-note { font-size: 11.5px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding: 32px 0 48px; }
  .hero-visual { display: none; }
  .tool-layout { grid-template-columns: 1fr; }
  .circle-layout { grid-template-columns: 1fr; }
  .main-nav { display: none; }
  .main-nav.open { display: flex; flex-direction: column; position: fixed; inset: 64px 0 0 0; background: var(--navy-900); padding: 24px; z-index: 99; }
  .menu-toggle { display: flex; }
}
@media (max-width: 560px) {
  .app-main { padding: 20px 16px 48px; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .hero-actions { flex-direction: column; }
  .btn { width: 100%; }
}

/* ══════════════════════════════════════════════════════════
   LESSONS
   ══════════════════════════════════════════════════════════ */

/* Nav lessons badge */
.nav-divider {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}

/* Lessons page layout */
.lessons-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Sidebar ── */
.lessons-sidebar {
  position: sticky;
  top: 88px;
  padding: 0;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-icon { font-size: 24px; }
.sidebar-header h3 {
  font-size: 19.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.lesson-list {
  list-style: none;
  padding: 8px 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Part section header in sidebar */
.lesson-part-header {
  padding: 14px 20px 5px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-500);
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 4px;
}
.lesson-part-header:first-child {
  border-top: none;
  margin-top: 0;
}
.lesson-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.lesson-list-item:hover {
  background: rgba(255,255,255,0.04);
  border-left-color: rgba(212,160,23,0.4);
}
.lesson-list-item.active {
  background: rgba(212,160,23,0.1);
  border-left-color: var(--gold-400);
}
.lesson-num {
  flex-shrink: 0;
  width: 33px;
  height: 33px;
  background: var(--navy-600);
  border-radius: 50%;
  font-size: 16.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  margin-top: 1px;
}
.lesson-list-item.active .lesson-num {
  background: var(--gold-400);
  color: var(--navy-900);
}
.lesson-list-title {
  font-size: 19.5px;
  line-height: 1.45;
  color: var(--gray-200);
}
.lesson-list-item.active .lesson-list-title {
  color: var(--gold-200);
  font-weight: 600;
}

/* ── Lesson Content Area ── */
.lesson-content-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.lesson-header {
  padding-bottom: 24px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(212,160,23,0.15);
}
.lesson-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.lesson-number-badge {
  margin-bottom: 0 !important;
}
.lesson-part-badge {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--gray-400);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 99px;
}
.lesson-number-badge {
  display: inline-block !important;
  background: rgba(212,160,23,0.15);
  border: 1px solid rgba(212,160,23,0.3);
  color: var(--gold-300);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 14px;
}
.lesson-main-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 700;
  color: var(--gold-200);
  margin-bottom: 6px;
  line-height: 1.2;
}
.lesson-subtitle-text {
  font-size: 21.75px;
  color: var(--gray-400);
}

/* ── Lesson Body ── */
.lesson-body {
  padding: 28px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Bullet groups — styled like a callout box */
.lesson-bullets {
  background: rgba(10,22,40,0.6);
  border-left: 3px solid var(--gold-400);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 18px 22px 18px 26px;
  margin: 16px 0;
}
.lesson-bullets ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.lesson-bullets li {
  font-size: 22.5px;
  color: var(--gray-100);
  line-height: 1.65;
  padding-left: 18px;
  position: relative;
}
.lesson-bullets li::before {
  content: '·';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--gold-300);
  font-size: 30px;
  line-height: 1.3;
  font-weight: 900;
}
.lesson-bullets li strong { color: var(--white); }
.lesson-bullets li em { color: var(--gray-400); font-style: normal; }

/* Text paragraphs */
.lesson-text {
  font-size: 22.5px;
  color: var(--gray-100);
  line-height: 1.75;
  padding: 14px 4px;
  margin: 4px 0;
}
.lesson-text strong { color: var(--white); }
.lesson-text em { color: var(--gray-400); font-style: normal; }

/* Staff wraps */
.lesson-staff-wrap {
  background: var(--navy-700);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  margin: 20px 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
}
.lesson-staff-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Separator */
.lesson-separator {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 24px 0 8px;
}

/* Nav bar at bottom */
.lesson-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 28px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Home card pointing to lessons */
.feature-card[data-route="lessons"] {
  border-color: rgba(212,160,23,0.25);
  background: linear-gradient(135deg, var(--navy-700) 0%, rgba(26,46,74,0.8) 100%);
}

/* ── Responsive Lessons ── */
@media (max-width: 900px) {
  .lessons-layout { grid-template-columns: 1fr; }
  .lessons-sidebar { position: static; }
  .lesson-list { max-height: 260px; overflow-y: auto; }
  .lesson-part-header { padding: 10px 16px 4px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--navy-800); }
::-webkit-scrollbar-thumb { background: var(--navy-500); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-500); }
