/*
 * Raaga Explorer (/raaga/) and the 72 melakartas (/raaga/melakarta/). Loaded after site.css; uses its tokens only.
 * Mobile first: settings, list (compact chips) and detail in one column; from 1100 px the list becomes a sticky
 * sidebar beside the detail. No animation: the playing note is shown by a colour change only (calm by design).
 */

/* ------------------------------------------------------------------ top of page */
.rx-limit { margin: 0 0 var(--s-4); color: var(--muted); }
.rx-limit strong { color: var(--text); }

/* ------------------------------------------------------------------ settings panel */
.rx-settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-4) var(--s-6); margin-bottom: var(--s-5); }
.rx-sa-field { min-width: 12rem; }
.rx-sa-field select { min-height: 44px; }
.rx-speed-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.rx-label { font-weight: 650; padding: 0; margin-bottom: 6px; }
.rx-speed, .rx-trad { margin: 0; }
.rx-drone-field { display: flex; flex-direction: column; gap: 2px; }
.rx-drone-field .switch { min-height: 44px; }
.rx-legend { flex: 1 1 100%; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); }
.rx-legend-h { font-weight: 650; color: var(--text); }
.rx-legend-more { margin-left: 4px; }
.rx-audio-msg { flex: 1 1 100%; margin: 0; }

/* ------------------------------------------------------------------ confidence labels */
.rx-conf {
  display: inline-block; font-size: .8125rem; font-weight: 700; line-height: 1.35; padding: 1px 9px; border-radius: var(--r-pill);
  border: 1.5px solid currentColor; background: var(--surface); white-space: nowrap; vertical-align: 2px; letter-spacing: 0;
}
.rx-conf.is-agreed { color: var(--teal); }
.rx-conf.is-single { color: var(--gold); }
.rx-conf.is-contested { color: var(--rose); }
.rx-conf.is-none { color: var(--muted); border-style: dashed; }
h2 .rx-conf, h3 .rx-conf { font-family: var(--font-body); }

/* English glosses after Indian terms: hidden when the footer's Indian terms switch is on (site.js sets data-terms). */
.rx-gloss { color: var(--muted); font-weight: 400; }
:root[data-terms="indian"] .rx-gloss { display: none; }

/* ------------------------------------------------------------------ layout: list + detail */
.rx { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .rx { grid-template-columns: minmax(19rem, 25rem) minmax(0, 1fr); gap: var(--s-6); }
}
.rx-browse-h { margin: 0 0 var(--s-3); font-size: var(--step-1); }
.rx-filters { display: grid; gap: var(--s-3); }
.rx-search input { width: 100%; min-height: 44px; }
.rx-trad-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.rx-trad { display: flex; width: 100%; }
.rx-trad .seg { flex: 1 1 0; }
.rx-trad .seg span { width: 100%; padding-left: 8px; padding-right: 8px; }
.rx-filter-row { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) and (max-width: 1099px) { .rx-filter-row { grid-template-columns: 1fr 1fr; } }
.rx-filter-row select { width: 100%; min-height: 44px; }
.rx-filter-note { margin: 0; }
.rx-count { margin: var(--s-3) 0 var(--s-2); font-weight: 650; }

/* The list: compact chips on narrow screens, rows with a second line in the sidebar */
.rx-group { margin-top: var(--s-4); }
.rx-group:first-child { margin-top: var(--s-2); }
.rx-group-h { margin: 0 0 var(--s-2); font-size: var(--step--1); font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rx-group-n { font-weight: 600; }
.rx-held-note { margin: 0 0 var(--s-2); }
.rx-items { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rx-li { display: flex; min-width: 0; }
.rx-item {
  display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 6px 14px; border-radius: var(--r-md);
  border: 2px solid var(--line-strong); background: var(--surface); color: var(--text); line-height: 1.25; text-decoration: none; min-width: 0;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
a.rx-item:hover { background: var(--surface-2); text-decoration: none; }
a.rx-item[aria-current="page"] { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); }
a.rx-item[aria-current="page"] .rx-item-sub { color: var(--indigo-ink); }
.rx-item-name { font-weight: 700; overflow-wrap: anywhere; }
.rx-item-sub { display: none; font-size: .8125rem; color: var(--muted); font-weight: 500; overflow-wrap: anywhere; }
.rx-li.is-held .rx-item { border-style: dashed; color: var(--muted); }
.rx-li.is-held .rx-item-name { font-weight: 600; }
@media (min-width: 1100px) {
  .rx-items { flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .rx-li { display: block; }
  .rx-item { border-width: 1px; border-color: var(--line); border-radius: var(--r-sm); padding: 6px 12px; }
  .rx-item-sub { display: block; }
  a.rx-item[aria-current="page"] { border-color: var(--indigo); }
}
.rx-empty { margin-top: var(--s-3); }
.rx-empty p { margin-top: 0; }

/* ------------------------------------------------------------------ detail card */
.rx-detail { min-width: 0; }
.rx-intro h2 { margin-top: 0; }
.rx-card { min-width: 0; }
.rx-kicker { margin: 0 0 var(--s-1); color: var(--muted); }
.rx-trad-tag { display: inline-block; font-size: .8125rem; font-weight: 700; padding: 0 8px; border-radius: var(--r-pill); border: 1.5px solid var(--line-strong); color: var(--text); background: var(--surface); }
.rx-title { margin: 0; font-size: var(--step-3); overflow-wrap: anywhere; }
.rx-title:focus { outline: none; }
.rx-title:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.rx-aka { margin: var(--s-1) 0 0; }
.rx-warn, .rx-caveat { max-width: 52em; }
.rx-card .rx-warn { margin-top: var(--s-4); }
.rx-card .rx-caveat { margin-top: calc(-1 * var(--s-2)); border-left-color: var(--gold); }

.rx-play { margin: var(--s-4) 0 var(--s-2); }
.rx-play-btns { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); }
.rx-play-btns button { min-height: 48px; }
.rx-play-note { margin: var(--s-2) 0 0; max-width: 52em; }
.rx-play-msg { margin: var(--s-2) 0 0; max-width: 52em; }

.rx-seq-block, .rx-sec { margin-top: var(--s-5); }
.rx-seq-block h3, .rx-sec h3 { margin: 0 0 var(--s-2); font-size: var(--step-1); }
.rx-claim { margin: 0 0 var(--s-2); }
.rx-code { font-family: var(--font-mono); font-size: .9375rem; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; color: var(--text); }
.rx-by { display: block; color: var(--muted); margin-top: 2px; }
.rx-by a, .rx-src { font-weight: 600; }
.rx-remark { color: var(--muted); }
.rx-detail-text { display: block; color: var(--muted); margin-top: 2px; max-width: 52em; }
.rx-none-text { font-style: italic; color: var(--muted); }

/* Versions of a contested aroh/avroh */
.rx-versions { border: 0; padding: 0; margin: 0 0 var(--s-3); min-width: 0; display: grid; gap: 6px; }
.rx-versions legend { padding: 0; margin-bottom: 6px; font-weight: 650; }
.rx-ver { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: start; padding: 8px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
.rx-ver input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--indigo); }
.rx-ver:has(input:checked) { border: 2px solid var(--indigo); padding: 7px 11px; }
.rx-ver.is-off { cursor: default; background: var(--surface-2); }
.rx-ver-body { min-width: 0; }

/* A sequence of swara cells */
.rx-seq { list-style: none; padding: 0; margin: var(--s-2) 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rx-n {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 3.4rem; padding: 6px 8px 5px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); line-height: 1.15; text-align: center;
}
.rx-n.is-oct { border-style: dashed; }
.rx-n-sw { font-weight: 750; font-size: 1.1875rem; }
.rx-n-q { font-size: .75rem; color: var(--muted); font-weight: 600; min-height: 1em; }
.rx-n-w { font-size: .875rem; font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text); margin-top: 2px; }
.rx-n.is-now { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); }
.rx-n.is-now .rx-n-q, .rx-n.is-now .rx-n-w { color: var(--indigo-ink); }
.rx-seq-none { margin: var(--s-2) 0 0; }

/* Swaras table */
.rx-table-wrap { overflow-x: auto; max-width: 40rem; }
.rx-sw-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.rx-sw-table th, .rx-sw-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rx-sw-table thead th { font-size: var(--step--1); color: var(--muted); font-weight: 650; border-bottom: 2px solid var(--line-strong); }
.rx-sw-table tbody th { font-weight: 650; }
.rx-tok { font-family: var(--font-mono); font-size: .8125rem; color: var(--muted); font-weight: 400; }
.rx-num, .rx-west { font-family: var(--font-num); }
.rx-outside { max-width: 52em; }

/* Facts */
.rx-facts { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px var(--s-5); }
.rx-facts dt { font-weight: 700; margin-top: var(--s-3); }
.rx-facts dt .rx-gloss { display: block; font-size: var(--step--1); line-height: 1.4; }
:root[data-terms="indian"] .rx-facts dt .rx-gloss { display: none; }
.rx-facts dd { margin: 0; min-width: 0; }
@media (min-width: 760px) {
  .rx-facts { grid-template-columns: minmax(10rem, 15rem) minmax(0, 1fr); }
  .rx-facts dt, .rx-facts dd { padding: var(--s-2) 0; border-top: 1px solid var(--line); margin-top: 0; }
}
.rx-val { font-weight: 650; }
.rx-claims { margin: 4px 0 0; padding-left: 1.25rem; }
.rx-claims li { margin-bottom: 6px; }
.rx-claims .rx-by { display: inline; }

.rx-same { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.rx-same li { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.rx-same-warn { max-width: 52em; }
.rx-notes { margin-top: var(--s-5); border-top: 1px solid var(--line); }
.rx-notes summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 650; }
.rx-notes p { max-width: 52em; color: var(--muted); }
.rx-sources { padding-left: 1.25rem; margin: 0 0 var(--s-2); }
.rx-sources li { margin-bottom: 4px; overflow-wrap: anywhere; }
.rx-held-card p, .rx-unknown p { max-width: 46em; }

/* Lower sections */
.rx-how li { margin-bottom: var(--s-2); }
.rx-gaps-h { margin-top: var(--s-6); font-size: var(--step-1); }
.rx-gaps li { margin-bottom: 4px; }
.rx-src-line { color: var(--muted); }

/* ------------------------------------------------------------------ melakarta table */
.mk-explain h2 { font-size: var(--step-1); }
.mk-filters { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); max-width: 60rem; }
@media (min-width: 760px) { .mk-filters { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.3fr); align-items: end; } }
.mk-filters input, .mk-filters select { width: 100%; min-height: 44px; }
.mk-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.mk-table th, .mk-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mk-table thead th { font-size: var(--step--1); color: var(--muted); font-weight: 650; border-bottom: 2px solid var(--line-strong); }
.mk-table tr[hidden] { display: none; }
.mk-no { font-weight: 750; font-family: var(--font-num); }
.mk-name { min-width: 11rem; max-width: 24rem; }
.mk-chakra { white-space: nowrap; }
.mk-name-main { display: block; font-weight: 700; }
.mk-alt, .mk-links { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.mk-links a { font-weight: 600; }
.mk-sw, .mk-semi { font-family: var(--font-mono); font-size: .9375rem; white-space: nowrap; }
.mk-west { font-family: var(--font-num); white-space: nowrap; }
.mk-play { min-height: 44px; min-width: 5.5rem; padding: 6px 14px; }
.mk-table tbody tr.is-playing { background: var(--indigo-soft); }
.mk-table tbody tr:target { outline: 3px solid var(--saffron-edge); outline-offset: -3px; }
@media (max-width: 899px) {
  /* Each row becomes a small card; the header stays for screen readers only. */
  .mk-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .mk-table, .mk-table tbody { display: block; }
  .mk-table tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .mk-table tbody tr[hidden] { display: none; }
  .mk-table tbody th, .mk-table tbody td { border: 0; padding: 0; }
  .mk-no { grid-row: 1; grid-column: 1; font-size: 1.125rem; }
  .mk-name { grid-row: 1; grid-column: 2; min-width: 0; }
  .mk-btn-cell { grid-row: 1; grid-column: 3; }
  .mk-chakra, .mk-sw, .mk-semi, .mk-west { grid-column: 2 / 4; white-space: normal; }
  .mk-chakra::before, .mk-sw::before, .mk-semi::before, .mk-west::before { content: attr(data-label) ": "; color: var(--muted); font-family: var(--font-body); font-size: .8125rem; font-weight: 600; }
}

@media (forced-colors: active) {
  .rx-n.is-now { outline: 3px solid Highlight; }
  .rx-conf { border-color: CanvasText; }
}
