/* Score Kati — app-wide theme: tokens, app bar, page bar and the shared components every page uses
   (cards, section titles, pills, tags, segmented controls, scorecard tables, ball chips, match rows).
   Load first; page stylesheets (styles.css for NPL, nepal.css, home.css, match.css, profiles.css) build on it.

   Palette comes from the Nepal flag: flag-blue chrome, crimson, snow-white surfaces, sun gold for highlights.
   Type: Anek (variable width) for scores and headings, condensed like a ground scoreboard; Mukta for reading.
   Both cover Latin and Devanagari, so Nepali glosses sit on the same baseline as English. */
:root {
  /* Surfaces and ink: warm lokta-paper surfaces, navy ink. */
  --bg: #f6f2ea;
  --paper: #fffdf8;
  --paper-2: #efe9de;
  --ink: #0e1a33;
  --ink-2: #3a4760;
  --muted: #5f6a80;
  --line: #e2dbcd;
  --line-2: #eee8dc;
  /* Brand: flag crimson, flag blue, sun gold. */
  --brand: #c8102e;
  --brand-2: #1f4fbf;
  --gold: #e3a62b;
  --bar: #0a2459;
  --bar-ink: #ffffff;
  --bar-dim: rgba(255, 255, 255, .72);
  --win: #1d7a45;
  --loss: #b4441b;
  /* Two-series charts (innings 1 / innings 2); validated for CVD on --paper. */
  --s1: #c8102e;
  --s2: #1f4fbf;

  --display: "Anek Latin", "Anek Devanagari", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Mukta", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --deva: "Mukta", "Noto Sans Devanagari", "Kohinoor Devanagari", sans-serif;
  /* Older name for the display face; page stylesheets still use it. */
  --round: var(--display);
  /* Scoreboard width for big numbers and headings. */
  --narrow: 82%;

  /* Radius by size: tags < controls < cards < heroes. */
  --r-xs: 4px;
  --r-sm: 10px;
  --radius: 14px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(14, 26, 51, .06), 0 4px 16px rgba(14, 26, 51, .06);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand-2) 45%, transparent);
  --wrap: 1100px;
  --tabbar-h: 62px;

  color-scheme: light;
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}
/* Dark theme (data-theme set by theme-init.js from the toggle or the system setting) */
:root[data-theme="dark"] {
    color-scheme: dark;
    /* Charcoal surfaces; navy stays on the app bar and the team heroes only. */
    --bg: #0d1015;
    --paper: #161a21;
    --paper-2: #1f242d;
    --ink: #eef2f8;
    --ink-2: #c3ccdb;
    --muted: #8d99ae;
    --line: #2b313b;
    --line-2: #21262e;
    --brand: #f2556a;
    --brand-2: #82a8f6;
    --gold: #f0b94a;
    --bar: #050d1e;
    --win: #4cc283;
    --loss: #f08a5d;
    --s1: #ec4a5f;
    --s2: #5b8ff0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-stretch: 92%; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
.np { font-family: var(--deva); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App bar (lib/appbar.js) ---------- */
.appbar { background: var(--bar); color: var(--bar-ink); }
.appbar-in {
  max-width: var(--wrap); margin: 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.applogo { display: inline-flex; align-items: center; gap: 10px; color: var(--bar-ink); text-decoration: none; flex: none; }
.applogo img { width: 36px; height: 36px; display: block; }
.applogo-name { font-family: var(--display); font-stretch: 85%; font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; line-height: 1; white-space: nowrap; }
/* Live flip: "Kati?" and "कति?" take turns every 3s, like a scoreboard ticking over. */
.applogo-flip { display: inline-grid; vertical-align: baseline; color: var(--gold); }
.applogo-flip > span { grid-area: 1 / 1; animation: applogo-flip 6s infinite; }
.applogo-flip > span + span { animation-delay: -3s; font-family: var(--deva); letter-spacing: 0; }
@keyframes applogo-flip {
  0%, 42% { opacity: 1; transform: none; }
  50%, 92% { opacity: 0; transform: translateY(-.35em); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .applogo-flip > span { animation: none; }
  .applogo-flip > span + span { display: none; }
}

.appnav { margin-left: auto; display: flex; gap: 2px; }
.appnav a {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--bar-dim); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 7px 12px; border-radius: var(--r-sm); white-space: nowrap;
}
/* Desktop: text-only links; icons are for the phone tab bar. The current page is white and bold with a dot under it. */
.appnav svg { display: none; width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.appnav a:hover { color: var(--bar-ink); }
.appnav a { position: relative; }
.appnav a[aria-current="page"] { color: var(--bar-ink); font-weight: 800; }
.appnav a[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--brand); }

/* Light / dark toggle: sun shows in dark theme (tap for light), moon in light. */
.themebtn {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin-left: 4px; padding: 0;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 50%; background: none; color: var(--bar-ink); cursor: pointer;
}
.themebtn:hover { background: rgba(255, 255, 255, .08); }
.themebtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tb-sun { display: none; }
:root[data-theme="dark"] .tb-sun { display: inline; }
:root[data-theme="dark"] .tb-moon { display: none; }

/* Dhaka-cloth band under the bar: crimson and snow triangles, the app's signature edge. */
.dhaka {
  height: 6px;
  background:
    linear-gradient(135deg, var(--brand) 25%, transparent 25%) 0 0 / 12px 6px,
    linear-gradient(225deg, #fff 25%, transparent 25%) 6px 0 / 12px 6px,
    var(--bar);
}
/* Dark theme (data-theme set by theme-init.js from the toggle or the system setting) */
:root[data-theme="dark"] .dhaka { background:
    linear-gradient(135deg, var(--brand) 25%, transparent 25%) 0 0 / 12px 6px,
    linear-gradient(225deg, rgba(255, 255, 255, .8) 25%, transparent 25%) 6px 0 / 12px 6px,
    var(--bar); }

/* Phones: the nav becomes a bottom tab bar, as in the native apps. */
@media (max-width: 720px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .appbar-in { padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .applogo img { width: 32px; height: 32px; }
  .themebtn { margin-left: auto; width: 34px; height: 34px; }
  .appnav {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; margin: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--paper) 92%, transparent); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  .appnav a {
    flex-direction: column; justify-content: center; gap: 3px; padding: 0; border-radius: 0;
    color: var(--muted); font-size: .72rem; font-weight: 600;
  }
  .appnav svg { display: block; width: 22px; height: 22px; }
  .appnav a:hover { background: none; color: var(--ink); }
  .appnav a[aria-current="page"] { background: none; box-shadow: none; color: var(--brand); }
  .appnav a[aria-current="page"] svg { stroke-width: 2.2; }
  .appnav a[aria-current="page"]::after { display: none; }
}

/* ---------- Page bar: page title + page-level controls under the app bar ---------- */
.pagebar { background: var(--paper); border-bottom: 1px solid var(--line); }
.pagebar-in {
  max-width: var(--wrap); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
}
.pagebar-t { font-family: var(--display); line-height: 1.15; font-size: 1.3rem; font-weight: 800; font-stretch: 85%; }
.pagebar-t .np { font-size: .9rem; color: var(--muted); margin-left: 6px; font-stretch: 100%; }
.pagebar .seg { margin-left: auto; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 16px; }
.wrap--narrow { max-width: 760px; }
.appfoot { max-width: var(--wrap); margin: 0 auto; padding: 0 16px 32px; font-size: .82rem; color: var(--muted); }
.appfoot--narrow { max-width: 760px; }

/* ---------- Components ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
/* Section titles: sentence case in the display face; Nepali gloss after it, quieter. */
.card h2, .sec-h {
  font-family: var(--display); font-stretch: 92%; font-size: 1.15rem; font-weight: 700; letter-spacing: -.005em;
  color: var(--ink); margin-bottom: 12px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
}
.card h2 .np, .sec-h .np { font-size: .9rem; font-weight: 500; color: var(--muted); font-family: var(--deva); font-stretch: 100%; }
.card h2 .muted, .sec-h .muted { font-family: var(--body); font-stretch: 100%; font-size: .85rem; font-weight: 500; }
.card h2 .more-link, .sec-h .more-link { margin-left: auto; font-family: var(--body); font-stretch: 100%; font-weight: 600; font-size: .88rem; color: var(--brand-2); text-decoration: none; }
.card h2 .more-link:hover, .sec-h .more-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: .95rem; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 1px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.pill--live { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, transparent); background: color-mix(in srgb, var(--brand) 7%, transparent); }
.pill--live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pill--live::before { animation: none; } }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 0 6px; border-radius: var(--r-xs); border: 1px solid var(--line); color: var(--ink-2); vertical-align: 1px; text-decoration: none; }
.tag--w { color: var(--win); border-color: color-mix(in srgb, var(--win) 40%, transparent); }
.tag--l { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 40%, transparent); }
.tag--live { color: #fff; background: var(--brand); border-color: var(--brand); }

.seg { display: inline-flex; padding: 3px; background: var(--paper-2); border-radius: var(--r-sm); }
.seg button, .seg a { border: 0; background: none; padding: 5px 14px; border-radius: 7px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--ink-2); text-decoration: none; }
.seg button[aria-pressed="true"], .seg a[aria-current] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 26, 51, .14); }
.more, .btn-ghost { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r-sm); padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); display: inline-block; }
.more:hover, .btn-ghost:hover { border-color: var(--ink-2); }
.more { margin-top: 10px; width: 100%; }

.flag { width: 12px; height: 15px; flex: none; }
/* Other countries' flags (lib/flags.js): 3:2 with a hairline so white flags still show on cards. */
.flag--rect { width: 18px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(14, 26, 51, .14); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; flex: none; }
.dot--emb { width: 18px; height: 18px; border-radius: 50%; vertical-align: -4px; }
.dot--emb .emb { display: block; width: 100%; height: 100%; }

/* Team emblems (lib/emblems.js): three tones set per badge through --e-a / --e-c / --e-d. */
.emb .a { fill: var(--e-a); }
.emb .c { fill: var(--e-c); }
.emb .d { fill: var(--e-d); }
.emb .s-a { fill: none; stroke: var(--e-a); }
.emb .s-c { fill: none; stroke: var(--e-c); }
.emb .s-d { fill: none; stroke: var(--e-d); }
.emb .c.s-d { fill: var(--e-c); }
/* Emblem crests are round badges; sizes follow the text crests they replace. */
.crest.crest--emb { width: 30px; height: 30px; border-radius: 50%; background: none; box-shadow: none; }
.crest.crest--emb .emb { display: block; width: 100%; height: 100%; }
.crest.crest--emb.crest--sb { width: 36px; height: 36px; }
.crest.crest--emb.crest--sm { width: 24px; height: 24px; }
.crest.crest--emb.crest--xs { width: 20px; height: 20px; }
.crest.crest--emb.crest--lg { width: 56px; height: 56px; }
@media (max-width: 600px) { .crest.crest--emb.crest--sb { width: 28px; height: 28px; } }

/* Scorecard tables */
.tscroll { overflow-x: auto; }
table.sc { width: 100%; border-collapse: collapse; font-size: .95rem; }
.sc th { text-align: right; font-size: .8rem; font-weight: 600; color: var(--muted); padding: 4px 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sc td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.sc th:first-child, .sc td:first-child { text-align: left; padding-left: 0; }
.sc td:first-child { font-weight: 600; }
.sc .how { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); }
.sc tr.on td:first-child::after { content: " *"; color: var(--brand); }
.sc tr:last-child td { border-bottom: 0; }
.sc tr.top td:first-child { color: var(--ink); }

/* Ball chips (this over) */
.over { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.over + .over { margin-top: 8px; }
.over small { width: 100%; color: var(--muted); font-size: .8rem; }
.b { min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px; display: inline-grid; place-items: center; font-family: var(--display); font-size: .95rem; font-weight: 700; border: 1px solid var(--line); background: var(--paper); font-variant-numeric: tabular-nums; }
.b--0 { color: var(--muted); }
.b--4, .b--6 { border-color: var(--brand-2); color: var(--brand-2); }
.b--6 { background: var(--brand-2); color: #fff; }
.b--W { background: var(--brand); border-color: var(--brand); color: #fff; }
.b--x { border-style: dashed; color: var(--ink-2); font-size: .82rem; }

/* Match rows (fixtures, results, home lists) */
.fx-group h3 { font-family: var(--body); font-size: .85rem; font-weight: 700; color: var(--muted); margin: 6px 0 8px; }
.fx { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); color: inherit; text-decoration: none; align-items: center; }
.fx:first-of-type { border-top: 0; }
a.fx:hover .fx-go { color: var(--brand); transform: translateX(2px); }
.fx-go { color: var(--muted); font-weight: 700; transition: transform .15s, color .15s; }
.fx-date { text-align: center; line-height: 1.05; align-self: start; padding: 4px 0; border-radius: var(--r-sm); background: var(--paper-2); }
.fx-date b { display: block; font-family: var(--display); font-stretch: var(--narrow); font-size: 1.4rem; font-weight: 800; }
.fx-date span { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); }
.fx-t { display: flex; align-items: baseline; gap: 8px; }
.fx-t .nm { font-weight: 600; }
.fx-t .sc2 { margin-left: auto; font-family: var(--display); font-stretch: var(--narrow); font-size: 1.1rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.fx-t .sc2 small { font-family: var(--body); font-stretch: 100%; font-size: .8rem; color: var(--muted); font-weight: 400; }
.fx-t--won .nm { font-weight: 800; }
.fx-res { font-size: .9rem; margin-top: 4px; }
.fx-note { font-size: .85rem; font-weight: 700; color: var(--win); margin-top: 2px; }
.fx-meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* Legal line in every page footer */
.legal { font-size: .75rem; opacity: .75; margin: 6px 0 0; }
