/* style.css — Behr
   Theme: Shab-e-mehfil, a candlelit mushaira night (plum, wine, candle-amber, old paper). */

:root {
  /* ===== Theme: Shab-e-mehfil (a candlelit mushaira night) =====
     To change the whole look, edit only this block. */
  --bg: #170f1a;           /* night sky, deep plum */
  --bg-glow: #2c1a2a;      /* candle glow in the corner */
  --panel: #22172a;
  --panel-2: #2e1f36;
  --ink: #f4e8d6;          /* old paper */
  --muted: #b9a8a8;
  --long: #8e3b52;         /* long syllables: wine */
  --short: #3d2638;        /* short syllables: dusk */
  --accent: #e9a979;       /* candlelight: what is sounding now */
  --gold: #d9b26f;
  --danger: #e06a6a;
  --danger-ink: #ff9c9c;

  /* The same colors as R, G, B numbers, for see-through glows: rgba(var(--x-rgb), 0.5) */
  --accent-rgb: 233, 169, 121;
  --gold-rgb: 217, 178, 111;
  --long-rgb: 142, 59, 82;
  --danger-rgb: 224, 106, 106;

  /* Older names that visuals.js still reads */
  --lapis: var(--long);
  --turquoise: var(--accent);

  --unit: clamp(12px, 1.6vw, 24px); /* width of one short syllable */
  --beat-h: 64px;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, var(--bg-glow) 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

.urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  line-height: 2.2; /* Nastaliq needs tall lines */
}

/* ---------- Header ---------- */
.site-header {
  padding: 2.5rem 2rem 1rem;
  text-align: center;
}
.site-header h1 {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.site-header h1 .urdu {
  color: var(--accent);
  font-size: 2rem;
  margin-inline-start: 0.4rem;
}
.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem 3rem;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 1rem; }
}

/* ---------- Meter list ---------- */
.meter-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.meter-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  padding: 0.4rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  text-align: start;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.meter-btn:hover { background: var(--panel-2); }
.meter-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meter-btn.active {
  border-color: var(--accent);
  background: var(--panel-2);
}
.meter-btn-urdu {
  align-self: flex-end;
  line-height: 1.9;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Stage ---------- */
.stage {
  background: var(--panel);
  border-radius: calc(var(--radius) * 1.6);
  padding: 2rem;
  min-height: 420px;
}
.empty-hint { color: var(--muted); }

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.meter-head h2 { margin: 0; font-weight: 500; }
.meter-urdu { margin: 0; font-size: 1.4rem; color: var(--gold); }

/* ---------- Rhythm ---------- */
.rhythm {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1rem 0 1.5rem;
}
.rukn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.beats {
  display: flex;
  gap: 4px;
}
.beat {
  width: calc(var(--w) * var(--unit) + (var(--w) - 1) * 4px);
  height: var(--beat-h);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease-out, background 0.08s, box-shadow 0.08s;
}
.beat.short { background: var(--short); }
.beat.long  { background: var(--long); }

.beat-mark  { font-size: 1.1rem; line-height: 1; }
.beat-digit { font-size: 0.7rem; color: var(--muted); }

.beat.active {
  background: var(--accent);
  color: var(--bg);
  transform: scaleY(1.18);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.6);
}
.beat.active .beat-digit { color: var(--bg); }

.rukn-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
}
.rukn-label .urdu { font-size: 1rem; line-height: 1.9; }
.rukn-roman { color: var(--muted); }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.play-btn {
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.play-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.tempo, .toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.tempo input { accent-color: var(--accent); }
.tempo output { min-width: 2.5ch; color: var(--ink); }
.toggle input { accent-color: var(--accent); }

/* ---------- Example verse ---------- */
.example {
  margin: 0 auto 1.5rem;
  max-width: 640px;
  text-align: center;
}
.example blockquote { margin: 0; }
.example-urdu { margin: 0; font-size: 1.5rem; }
.example-roman { margin: 0.25rem 0 0; color: var(--muted); font-style: italic; }
.example figcaption { margin-top: 0.4rem; color: var(--gold); font-size: 0.9rem; }

/* ---------- Legend ---------- */
.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.5rem; }
.legend-beat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  border-radius: 5px;
  color: var(--ink);
}
.legend-beat.short { width: 18px; background: var(--short); }
.legend-beat.long  { width: 40px; background: var(--long); }

/* ---------- Scanner ---------- */
.scanner {
  max-width: 1200px;
  margin: 0 auto 3rem;
  padding: 2rem;
  background: var(--panel);
  border-radius: calc(var(--radius) * 1.6);
  width: calc(100% - 4rem);
}
@media (max-width: 820px) {
  .scanner { width: calc(100% - 2rem); padding: 1.25rem; }
}
.scanner h2 { margin: 0 0 0.5rem; font-weight: 500; }
.scanner h2 .urdu { color: var(--gold); font-size: 1.2rem; margin-inline-start: 0.4rem; }
.scanner-help { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }
.scanner-help code {
  background: var(--panel-2);
  color: var(--accent);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}
#scan-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--panel-2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  resize: vertical;
}
#scan-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.scanner-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}
.scanner-hint { color: var(--muted); font-size: 0.8rem; }

.ghost-btn {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.ghost-btn:hover { background: rgba(var(--accent-rgb), 0.12); }
.ghost-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Syllable chips */
.scan-syllables {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1.5rem;
}
.scan-gap { width: 14px; }
.syl {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
}
.syl-text { font-size: 0.95rem; }
.syl-mark { color: var(--accent); font-size: 1rem; line-height: 1.2; }
.syl.flex { border-style: dashed; border-color: var(--muted); }
.syl.mismatch { background: rgba(var(--danger-rgb), 0.18); border: 1px solid var(--danger); }
.syl.mismatch .syl-mark { color: var(--danger-ink); }
.syl.skipped { opacity: 0.45; }

/* Results */
.scan-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.scan-result {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  background: var(--panel-2);
  border-radius: var(--radius);
}
.scan-result-name { font-weight: 500; }
.scan-result .urdu { color: var(--muted); line-height: 1.9; }
.scan-result .ghost-btn { margin-inline-start: auto; }
.badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(var(--gold-rgb), 0.18);
  color: var(--gold);
}
.badge.perfect { background: rgba(var(--accent-rgb), 0.18); color: var(--accent); }
.scan-empty { color: var(--muted); }

/* ---------- Visuals ---------- */
.viz {
  display: block;
  width: 100%;
  height: clamp(260px, 38vw, 380px);
  margin: 0 auto 0.5rem;
}

/* ---------- Sample verses + variant badge ---------- */
.scan-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.5rem 0 1.5rem;
}
.sample-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  font-style: italic;
}
.badge.variant { background: rgba(var(--long-rgb), 0.45); color: var(--ink); }

/* ---------- Verse playback: the sounding syllable glows ---------- */
.syl { transition: background 0.08s, transform 0.08s, box-shadow 0.08s; }
.syl.playing {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.6);
}
.syl.playing .syl-text,
.syl.playing .syl-mark { color: var(--bg); }

/* ---------- About ---------- */
.about {
  max-width: 1200px;
  width: calc(100% - 4rem);
  margin: 0 auto 3rem;
  padding: 2rem;
  background: var(--panel);
  border-radius: calc(var(--radius) * 1.6);
}
@media (max-width: 820px) {
  .about { width: calc(100% - 2rem); padding: 1.25rem; }
}
.about h2 { margin: 0 0 0.75rem; font-weight: 500; }
.about h2 .urdu { color: var(--gold); font-size: 1.2rem; margin-inline-start: 0.4rem; }
.about-lead { max-width: 72ch; color: var(--ink); margin: 0 0 1.5rem; }
.about em { color: var(--accent); font-style: italic; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 820px) {
  .about-grid { grid-template-columns: 1fr; }
}
.about-grid article {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.about-grid h3 { margin: 0 0 0.4rem; color: var(--gold); font-weight: 600; }
.about-grid p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.about-sub { margin: 0 0 0.5rem; font-weight: 500; }
.about-list { margin: 0; padding-inline-start: 1.2rem; color: var(--muted); font-size: 0.92rem; }
.about-list li { margin-bottom: 0.3rem; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 1rem 2.5rem;
}
.site-footer a { color: var(--accent); }