/* ==========================================================================
   Kithu Bathi Gee Dahana — public website
   Hand-written CSS on purpose: no build step, so deploys never need node on
   the 911MB shared box, and nothing competes with the live mobile API.
   Colours follow the app (primary #2b65f7).
   ========================================================================== */

:root {
  --blue: #2b65f7;
  --blue-dark: #1b46b3;
  --blue-soft: rgba(43, 101, 247, .10);

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --text: #161d33;
  --text-dim: #5b6480;
  --line: #e3e8f2;
  --chord: #2b65f7;
  --shadow: 0 1px 2px rgba(18, 26, 48, .05), 0 6px 20px rgba(18, 26, 48, .05);
  --radius: 14px;

  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Sinhala",
          "Iskoola Pota", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0e1320;
  --surface: #171e2e;
  --surface-2: #1d253750;
  --text: #e7ecf7;
  --text-dim: #99a3bd;
  --line: #27314a;
  --blue: #5b88ff;
  --blue-soft: rgba(91, 136, 255, .14);
  --chord: #7fa2ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Icons are inline SVG drawn as strokes, except the solid play/pause glyphs. */
svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.as-fab svg path, .btn-media svg path:first-child { fill: currentColor; stroke: none; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.22rem; }

.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-dim); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin: .3em 0; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--blue); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 14px; height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: .95rem; }
.brand-text small { font-size: .72rem; color: var(--text-dim); }

.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: 7px 11px; border-radius: 9px; color: var(--text-dim);
  font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--blue-soft); color: var(--blue); text-decoration: none; }
.nav a.on { background: var(--blue); color: #fff; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: 0 0 auto;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.icon-btn:hover { color: var(--blue); border-color: var(--blue); }
.menu-btn { display: none; }

:root[data-theme="light"] .i-moon, :root:not([data-theme="dark"]) .i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }

@media (max-width: 760px) {
  .menu-btn { display: inline-grid; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px; box-shadow: var(--shadow); display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; }
}

/* ---------- hero + search ---------- */
.hero {
  background: linear-gradient(160deg, var(--blue), var(--blue-dark));
  color: #fff; padding: 34px 0 30px; text-align: center;
}
.hero h1 { color: #fff; margin-bottom: .15em; }
.hero-sub { margin: 0 0 18px; opacity: .9; font-size: .95rem; }

.search-wrap { position: relative; max-width: 560px; margin: 0 auto; }
.search-i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.search {
  width: 100%; height: 50px; padding: 0 42px 0 42px;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 0; border-radius: 25px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .14);
}
.search:focus { outline: 3px solid rgba(255, 255, 255, .55); outline-offset: 2px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-dim); font-size: 1.4rem; cursor: pointer;
}
.search-hint { font-size: .82rem; opacity: .85; margin: 10px 0 0; }
.linky {
  background: none; border: 0; padding: 0; font: inherit;
  color: inherit; text-decoration: underline; cursor: pointer;
}

/* ---------- filters ---------- */
.filters { padding: 18px 16px 6px; display: grid; gap: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 15px; font: inherit; font-size: .88rem; font-weight: 500;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 20px; cursor: pointer;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.selects { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.sel { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--text-dim); }
.sel select {
  font: inherit; font-size: .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-width: 150px;
}
.count { margin: 0; font-size: .85rem; color: var(--text-dim); }
.count strong { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; font: inherit; font-size: .88rem; font-weight: 500;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-ghost { background: transparent; }

/* ---------- song list ---------- */
.song-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 28px; }
.song {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; order: var(--o, 0);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.song:hover { border-color: var(--blue); text-decoration: none; transform: translateY(-1px); }
.song[hidden] { display: none; }
.song-no {
  flex: 0 0 44px; text-align: center; padding-top: 1px;
  font-size: 17px; font-weight: 500; color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.song-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.song-title { font-size: .94rem; font-weight: 600; }
.song-artist { font-size: .8rem; color: var(--text-dim); }
.song-tags { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; padding-top: 2px; }
.song-go { color: var(--text-dim); flex: 0 0 auto; margin-top: 3px; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.badge-key { background: var(--blue-soft); color: var(--blue); }
.badge-beat { background: rgba(255, 152, 0, .13); color: #c76a00; }
:root[data-theme="dark"] .badge-beat { color: #f0a94a; }
.badge-cat { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--line); }
.badge.big { padding: 6px 11px; font-size: .78rem; }

.page-head { padding: 22px 16px 14px; }
.crumbs { font-size: .8rem; color: var(--text-dim); margin-bottom: 8px; }
.crumbs span { margin: 0 4px; opacity: .6; }
.empty { text-align: center; padding: 36px 0; color: var(--text-dim); }

/* ---------- categories ---------- */
.cat-grid {
  display: grid; gap: 10px; padding-bottom: 28px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.cat {
  display: flex; flex-direction: column; gap: 2px; padding: 15px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.cat:hover { border-color: var(--blue); text-decoration: none; }
.cat-name { font-weight: 600; }
.cat-count { font-size: .8rem; color: var(--text-dim); }

/* ---------- patrons ---------- */
.patron-grid {
  display: grid; gap: 12px; padding-bottom: 28px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
.patron {
  display: flex; gap: 13px; padding: 15px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.patron-pic { flex: 0 0 80px; }
.patron-pic img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.patron-initial {
  display: grid; place-items: center; width: 80px; height: 80px;
  border-radius: 50%; background: var(--blue); color: #fff; font-size: 1.9rem;
}
.patron-body { min-width: 0; }
.patron-body h2 { font-size: 1rem; color: var(--blue); margin-bottom: .1em; }
.patron-biz { margin: 0; font-size: .82rem; font-weight: 600; }
.patron-desc { margin: .3em 0; font-size: .85rem; color: var(--text-dim); }
.patron-links { display: flex; gap: 10px; flex-wrap: wrap; font-size: .82rem; }

/* ---------- reader ---------- */
.reader { padding-bottom: 40px; }
.reader-head { padding: 4px 0 14px; }
.reader-no { margin: 0; font-size: .78rem; font-weight: 600; color: var(--blue); letter-spacing: .04em; text-transform: uppercase; }
.reader-artist { margin: .1em 0 0; font-size: .88rem; color: var(--text-dim); }
.reader-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

.keybadge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; font: inherit; font-size: .82rem; font-weight: 600;
  background: var(--blue); color: #fff; border: 0; border-radius: 9px; cursor: pointer;
}
.keybadge:not(.on) { background: #8b93a7; }
.keybadge svg { stroke-width: 2; }

.stepper {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.stepper-l { font-size: .72rem; color: var(--text-dim); padding: 0 6px; }
.stepper button {
  min-width: 30px; height: 28px; padding: 0 7px;
  font: inherit; font-size: .85rem; font-weight: 600;
  background: transparent; color: var(--text);
  border: 0; border-radius: 7px; cursor: pointer;
}
.stepper button:hover { background: var(--blue-soft); color: var(--blue); }
.stepper output {
  min-width: 30px; text-align: center; font-size: .85rem;
  font-weight: 600; font-variant-numeric: tabular-nums; color: var(--blue);
}
.stepper-reset { font-size: .72rem !important; font-weight: 500 !important; color: var(--text-dim) !important; }

.media-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-media { font-size: .83rem; }
.btn-media.alt:hover { border-color: #e08a00; color: #e08a00; }

/* the sheet */
.sheet {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 16px 12px;
}
.sheet-mark {
  position: absolute; inset: 0; pointer-events: none;
  background: url('/img/watermark.png') center 80px / 340px no-repeat;
  opacity: .14;
}
:root[data-theme="dark"] .sheet-mark { opacity: .07; }

.lyrics {
  position: relative;
  font-size: var(--fs, 16px);
  line-height: 1.4;
  letter-spacing: .5px;
}
.lyrics .l { margin-bottom: 10px; }
.lyrics .gap { height: calc(var(--fs, 16px) * 1.6); }

/* one word (or whitespace run) with its chord stacked above it */
.lyrics .u { display: inline-block; vertical-align: top; }
.lyrics .u .c {
  display: block;
  font-size: .85em;
  font-weight: 700;
  line-height: 1.2;
  color: var(--chord);
  white-space: pre;
  min-height: 1.2em;
}
.lyrics .u .w { display: block; white-space: pre; }
.lyrics.no-chords .u .c { color: transparent; }   /* keeps the layout stable */

.sheet-foot {
  margin: 18px 0 0; text-align: center;
  font-size: 9px; font-weight: 700; color: var(--text-dim);
}
.no-lyrics { text-align: center; padding: 30px 0; color: var(--text-dim); }

.prevnext { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.pn {
  display: flex; flex-direction: column; gap: 1px; max-width: 48%; padding: 11px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.pn:hover { border-color: var(--blue); text-decoration: none; }
.pn.right { text-align: right; margin-left: auto; }
.pn-l { font-size: .72rem; color: var(--blue); font-weight: 600; }
.pn-t { font-size: .82rem; color: var(--text-dim); }

/* auto-scroll control */
.autoscroll {
  position: fixed; right: 16px; bottom: 20px; z-index: 30;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.as-pill {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: rgba(14, 19, 32, .82); color: #fff;
  border-radius: 20px; font-size: .76rem; backdrop-filter: blur(4px);
}
.as-pill button {
  width: 22px; height: 22px; font: inherit; font-size: .9rem; line-height: 1;
  background: rgba(255, 255, 255, .16); color: #fff;
  border: 0; border-radius: 50%; cursor: pointer;
}
.as-pill b { font-variant-numeric: tabular-nums; }
.as-fab {
  display: grid; place-items: center; width: 52px; height: 52px;
  background: var(--blue); color: #fff; border: 0; border-radius: 50%;
  box-shadow: 0 6px 18px rgba(43, 101, 247, .4); cursor: pointer;
}
.as-fab:hover { background: var(--blue-dark); }
.as-count { font-size: 1.15rem; font-weight: 700; }

/* ---------- prose ---------- */
.prose { padding-bottom: 36px; }
.prose p { margin: 0 0 1em; }
.prose .lead { font-size: 1.04rem; }
.prose h2 { margin-top: 1.5em; }
.prose blockquote {
  margin: 0 0 1.2em; padding: 14px 16px;
  background: var(--blue-soft); border-left: 3px solid var(--blue);
  border-radius: 0 10px 10px 0; font-style: italic;
}
.prose blockquote cite { display: block; margin-top: .4em; font-size: .85rem; opacity: .8; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 30px 0 20px; margin-top: 10px; }
.foot-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.foot h4 { font-size: .9rem; margin-bottom: .5em; }
.foot a { color: var(--text-dim); font-size: .86rem; }
.foot a:hover { color: var(--blue); }
.stores { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.foot-base {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--text-dim);
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 14px);
  z-index: 60; max-width: calc(100% - 32px);
  padding: 11px 18px; border-radius: 22px;
  background: rgba(14, 19, 32, .92); color: #fff; font-size: .87rem;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #c0392b; }

@media print {
  .topbar, .foot, .autoscroll, .media-row, .prevnext, .crumbs, .reader-tools, .toast { display: none !important; }
  body { background: #fff; }
  .sheet { border: 0; box-shadow: none; }
}
