/* nBookMedia Music Room.
   Colour comes only from the two token blocks below (R13):
   Kolam Morning (light, rice-flour white, kaavi red, turmeric) and
   Temple Lamp (dark, lamp-black, brass, ember). The player bar is the only
   part styled on existing pages; everything else is scoped to .mr-page. */

:root {
  --mr-bg: #faf6ee;
  --mr-surface: #ffffff;
  --mr-surface-2: #f2ebde;
  --mr-ink: #2b2118;
  --mr-muted: #645646;
  --mr-line: #ddd1bd;
  --mr-accent: #9c3a26;
  --mr-accent-ink: #ffffff;
  --mr-gold: #8a5d00;
  --mr-focus: #1f5fae;
  --mr-shadow: rgba(43, 33, 24, 0.14);
  --mr-kolam: #c9b89c;
  --eq-low: #3f6b4a;
  --eq-mid: #b97c0c;
  --eq-high: #9c3a26;
}

[data-theme="dark"] {
  --mr-bg: #15110c;
  --mr-surface: #1f1912;
  --mr-surface-2: #2a2219;
  --mr-ink: #f3e9d8;
  --mr-muted: #c2b298;
  --mr-line: #43372a;
  --mr-accent: #e8875f;
  --mr-accent-ink: #15110c;
  --mr-gold: #e7b552;
  --mr-focus: #8fbcff;
  --mr-shadow: rgba(0, 0, 0, 0.5);
  --mr-kolam: #5b4b37;
  --eq-low: #79b087;
  --eq-mid: #e7b552;
  --eq-high: #ef7d55;
}

/* ---------- Music pages ---------- */

.mr-page {
  margin: 0;
  background: var(--mr-bg);
  color: var(--mr-ink);
  font: 400 1rem/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mr-page *, .mr-page *::before, .mr-page *::after, #mr-player, #mr-player * { box-sizing: border-box; }
.mr-page img { max-width: 100%; height: auto; display: block; }
.mr-page a { color: var(--mr-accent); }
.mr-page h1, .mr-page h2, .mr-page h3 { font-family: Fraunces, Georgia, serif; line-height: 1.15; margin: 0 0 0.5em; }
.mr-page h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.mr-page h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.mr-page [lang="ta"] { font-family: "Noto Serif Tamil", "Noto Sans Tamil", serif; }
/* Long Tamil words and display titles must wrap at 320 px with 200 % text. */
.mr-page { overflow-wrap: break-word; }
.mr-page h1, .mr-page h2, .mr-page [lang="ta"], .mr-lyric, .mr-row__title, .mr-hero__story { overflow-wrap: anywhere; }

.mr-skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--mr-surface); color: var(--mr-ink); padding: 0.6rem 1rem; border-radius: 6px;
}
.mr-skip:focus { top: 1rem; }

.mr-page :focus-visible, #mr-player :focus-visible {
  outline: 3px solid var(--mr-focus);
  outline-offset: 2px;
}

.mr-header { border-bottom: 1px solid var(--mr-line); background: var(--mr-bg); }
.mr-topnav {
  max-width: 1200px; margin: 0 auto; padding: 0.9rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem;
}
.mr-topnav__mark { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 1.25rem; color: var(--mr-ink) !important; text-decoration: none; }
.mr-topnav__list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; margin: 0; padding: 0; }
.mr-topnav__list a { color: var(--mr-ink); text-decoration: none; padding: 0.3rem 0; display: inline-block; }
.mr-topnav__list a:hover { color: var(--mr-accent); }
.mr-topnav__list a[aria-current="page"] { color: var(--mr-accent); border-bottom: 2px solid currentColor; }

.mr-main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.mr-eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; color: var(--mr-muted); margin: 0 0 0.4rem; }
.mr-muted { color: var(--mr-muted); font-size: 0.9rem; }
.mr-lede { color: var(--mr-muted); max-width: 60ch; }

.mr-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 44px; padding: 0.55rem 1.1rem;
  border: 1px solid var(--mr-line); border-radius: 999px;
  background: var(--mr-surface); color: var(--mr-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.mr-btn:hover { border-color: var(--mr-accent); }
.mr-btn svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.mr-btn--primary { background: var(--mr-accent); border-color: var(--mr-accent); color: var(--mr-accent-ink); }
.mr-btn--icon { padding: 0; width: 44px; justify-content: center; flex: none; }
.mr-btn--icon span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mr-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* Hero */
.mr-hero__card {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2rem; align-items: center;
  background: var(--mr-surface); border: 1px solid var(--mr-line); border-radius: 18px; padding: 1.25rem;
  box-shadow: 0 10px 30px var(--mr-shadow);
}
.mr-hero__cover { border-radius: 12px; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.mr-hero__ta { font-size: 1.35rem; color: var(--mr-gold); margin: 0 0 0.75rem; }
.mr-hero__story { color: var(--mr-muted); margin: 0; }

/* Kolam field */
.mr-browse { margin-top: 3rem; }
.mr-field {
  position: relative; width: min(100%, 760px); aspect-ratio: 1 / 1; margin: 1.5rem auto 2.5rem;
}
.mr-field__kolam { position: absolute; inset: 0; width: 100%; height: 100%; }
.mr-field__pulli circle { fill: var(--mr-kolam); }
.mr-field__line { fill: none; stroke: var(--mr-kolam); stroke-width: 0.45; stroke-linejoin: round; stroke-dasharray: 1.6 1.2; }
.mr-field__nodes { list-style: none; margin: 0; padding: 0; }
.mr-node { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 21%; }
.mr-node__link {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem; text-decoration: none;
  color: var(--mr-ink); text-align: center;
}
.mr-node__link img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px;
  border: 2px solid var(--mr-line); box-shadow: 0 4px 12px var(--mr-shadow); transition: transform 0.2s ease, border-color 0.2s ease;
}
.mr-node__link:hover img, .mr-node__link:focus-visible img { transform: scale(1.06); border-color: var(--mr-accent); }
.mr-node__title { font-size: clamp(0.66rem, 1.6vw, 0.9rem); font-weight: 600; line-height: 1.2; overflow-wrap: break-word; }
.mr-node.is-playing .mr-node__link img { border-color: var(--mr-accent); }

/* List */
.mr-list__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.mr-list__bar select {
  min-height: 44px; padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--mr-line);
  background: var(--mr-surface); color: var(--mr-ink); font: inherit;
  min-width: 0; max-width: 100%;
}
.mr-list__rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--mr-line); }
.mr-list__rows li {
  display: flex; align-items: center; gap: 0.9rem; padding: 0.65rem 0.25rem; border-bottom: 1px solid var(--mr-line);
}
.mr-list__rows img { width: 80px; flex: none; border-radius: 6px; aspect-ratio: 16 / 9; object-fit: cover; }
.mr-row__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mr-row__title { font-weight: 600; color: var(--mr-ink) !important; text-decoration: none; }
.mr-row__title:hover { text-decoration: underline; }
.mr-row__ta { color: var(--mr-gold); font-size: 0.95rem; }
.mr-row__meta { color: var(--mr-muted); font-size: 0.85rem; }

/* Song page */
.mr-song__head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: center; }
.mr-song__cover { border-radius: 14px; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; box-shadow: 0 10px 30px var(--mr-shadow); }
.mr-song__ta { font-size: 1.4rem; color: var(--mr-gold); margin: 0; }
.mr-dedication {
  margin: 0.8rem 0 0; padding: 0.5rem 0.9rem; border-left: 3px solid var(--mr-accent);
  background: var(--mr-surface-2); border-radius: 0 8px 8px 0; font-style: italic;
}
.mr-section { margin-top: 2.5rem; max-width: 760px; }
.mr-stanza { margin-bottom: 1.25rem; }
.mr-stanza__name { font-family: system-ui, sans-serif !important; font-size: 0.8rem !important; text-transform: uppercase; letter-spacing: 0.1em; color: var(--mr-muted); margin-bottom: 0.3rem !important; }
.mr-lyric { font-size: 1.12rem; line-height: 1.9; margin: 0; }
.mr-lyric--rom { font-family: system-ui, sans-serif; font-size: 1.02rem; }
.mr-lyrics__rom { margin-top: 1rem; border: 1px solid var(--mr-line); border-radius: 10px; padding: 0.4rem 1rem; background: var(--mr-surface); }
.mr-lyrics__rom summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.mr-chapters { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
.mr-chapter {
  display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; width: 100%; min-width: 0; text-align: left; min-height: 44px; align-items: center;
  border: 1px solid var(--mr-line); border-radius: 8px; padding: 0.4rem 0.8rem;
  background: var(--mr-surface); color: var(--mr-ink); font: inherit; cursor: pointer;
}
.mr-chapter:hover { border-color: var(--mr-accent); }
.mr-chapter__name { min-width: 0; overflow-wrap: break-word; }
.mr-chapter__at { font-variant-numeric: tabular-nums; color: var(--mr-accent); font-weight: 600; min-width: 3.2em; }
.mr-video { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--mr-surface-2); }
.mr-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mr-rights__list { margin: 0; display: grid; gap: 0; border: 1px solid var(--mr-line); border-radius: 12px; overflow: hidden; background: var(--mr-surface); }
.mr-rights__row { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 1rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--mr-line); }
.mr-rights__row:last-child { border-bottom: 0; }
.mr-rights__row dt { font-weight: 600; color: var(--mr-muted); }
.mr-rights__row dd { margin: 0; overflow-wrap: anywhere; }
.mr-hash { font-size: 0.82rem; word-break: break-all; }
.mr-next a { font-weight: 600; }

.mr-footer { border-top: 1px solid var(--mr-line); color: var(--mr-muted); font-size: 0.9rem; padding: 1.5rem 1rem 2rem; text-align: center; }
.mr-footer p { margin: 0.3rem auto; max-width: 70ch; }

/* ---------- Player bar (all pages) ---------- */

body.mr-has-player { padding-bottom: var(--mr-player-h, 84px); }

#mr-player {
  --mr-player-h: 84px;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000;
  background: var(--mr-surface); color: var(--mr-ink);
  border-top: 1px solid var(--mr-line); box-shadow: 0 -6px 24px var(--mr-shadow);
  font: 400 0.95rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
#mr-player[hidden] { display: none; }
.mr-pl {
  max-width: 1400px; margin: 0 auto; padding: 0.55rem 1rem;
  display: grid; align-items: center; gap: 0.5rem 1rem;
  grid-template-columns: auto minmax(8rem, 15rem) auto minmax(10rem, 1fr) auto auto auto;
  grid-template-areas: "cover meta play seek eq dials actions";
}
#mr-player .mr-pl__cover { grid-area: cover; width: 64px; height: 36px; object-fit: cover; border-radius: 4px; display: block; }
.mr-pl__meta { grid-area: meta; min-width: 0; display: flex; flex-direction: column; }
.mr-pl__title { color: var(--mr-ink); font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-pl__title:hover { text-decoration: underline; }
.mr-pl__sub.is-error { color: var(--mr-accent); white-space: normal; }
.mr-pl__sub { color: var(--mr-muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-pl__btn {
  min-width: 44px; min-height: 44px; border-radius: 999px; border: 1px solid var(--mr-line);
  background: var(--mr-surface); color: var(--mr-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 0.6rem; font: inherit;
}
.mr-pl__btn svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
.mr-pl__btn:hover { border-color: var(--mr-accent); }
.mr-pl__play { grid-area: play; background: var(--mr-accent); border-color: var(--mr-accent); color: var(--mr-accent-ink); width: 48px; height: 48px; }
.mr-pl__seek { grid-area: seek; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.mr-pl__seek input { flex: 1; min-width: 0; accent-color: var(--mr-accent); height: 44px; }
.mr-pl__time { font-variant-numeric: tabular-nums; color: var(--mr-muted); font-size: 0.82rem; min-width: 2.8em; text-align: center; }
.mr-pl__eq { grid-area: eq; width: 168px; height: 36px; display: block; }
.mr-pl__dials { grid-area: dials; display: flex; gap: 0.4rem; }
.mr-pl__actions { grid-area: actions; display: flex; gap: 0.4rem; position: relative; }
.mr-pl__status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mr-pl__menu {
  position: absolute; right: 0; bottom: calc(100% + 0.6rem); min-width: 15rem; margin: 0; padding: 0.4rem;
  list-style: none; background: var(--mr-surface); border: 1px solid var(--mr-line); border-radius: 10px;
  box-shadow: 0 10px 30px var(--mr-shadow);
}
.mr-pl__menu[hidden] { display: none; }
.mr-pl__copy {
  position: absolute; right: 0; bottom: calc(100% + 0.6rem); width: min(22rem, calc(100vw - 2rem)); padding: 0.6rem;
  display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 0.5rem; align-items: center;
  background: var(--mr-surface); border: 1px solid var(--mr-line); border-radius: 10px;
  box-shadow: 0 10px 30px var(--mr-shadow);
}
.mr-pl__copy[hidden] { display: none; }
.mr-pl__copy-msg { grid-column: 1 / -1; margin: 0; font-weight: 600; color: var(--mr-ink); }
.mr-pl__copy-url {
  min-width: 0; min-height: 44px; padding: 0 0.6rem; font: inherit; color: var(--mr-ink);
  background: var(--mr-surface-2); border: 1px solid var(--mr-line); border-radius: 6px;
}
.mr-pl__copy-close {
  min-height: 44px; padding: 0 0.8rem; font: inherit; color: var(--mr-ink); cursor: pointer;
  background: transparent; border: 1px solid var(--mr-line); border-radius: 6px;
}
.mr-pl__menu button {
  width: 100%; text-align: left; min-height: 44px; padding: 0.4rem 0.7rem; border: 0; border-radius: 6px;
  background: transparent; color: var(--mr-ink); font: inherit; cursor: pointer;
}
.mr-pl__menu button:hover, .mr-pl__menu button:focus-visible { background: var(--mr-surface-2); }

/* Rotary dials (R22) */
.mr-dial {
  width: 44px; height: 44px; border-radius: 50%; position: relative; cursor: ns-resize; touch-action: none;
  background: var(--mr-surface-2); border: 1px solid var(--mr-line); flex: none;
}
.mr-dial[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.mr-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mr-dial__track { fill: none; stroke: var(--mr-line); stroke-width: 3; }
.mr-dial__arc { fill: none; stroke: var(--mr-accent); stroke-width: 3; stroke-linecap: round; }
.mr-dial__tick { stroke: var(--mr-ink); stroke-width: 2.5; stroke-linecap: round; }
.mr-dial__label {
  position: absolute; left: 50%; bottom: -0.15rem; transform: translate(-50%, 100%);
  font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mr-muted); pointer-events: none;
}
.mr-pl__dials { padding-bottom: 0.7rem; }

@media (max-width: 900px) {
  #mr-player { --mr-player-h: 132px; }
  body.mr-has-player { padding-bottom: 132px; }
  .mr-pl {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "cover meta actions play"
      "seek seek seek seek"
      "eq eq dials dials";
    gap: 0.3rem 0.6rem; padding: 0.45rem 0.75rem;
  }
  .mr-pl__eq { width: 100%; max-width: 160px; height: 28px; }
  .mr-pl__dials { justify-content: flex-end; }
  .mr-hero__card, .mr-song__head { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .mr-rights__row { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
}

@media (max-width: 480px) {
  /* Taller field spreads the rows; narrower nodes keep edge labels inside. */
  .mr-field { aspect-ratio: 3 / 4; }
  .mr-node { width: 20%; }
  .mr-node__title { font-size: 0.62rem; }
  #mr-player .mr-pl__cover { display: none; }
  .mr-pl { grid-template-areas: "meta meta actions play" "seek seek seek seek" "eq eq dials dials"; }
}

@media (prefers-reduced-motion: reduce) {
  .mr-node__link img { transition: none; }
  .mr-node__link:hover img, .mr-node__link:focus-visible img { transform: none; }
}
