/* ============================================================
   BillBook — Localized Ad-Creative Kit
   Premium static site. Brand teal -> gold on a clean canvas.
   ============================================================ */

:root {
  /* Brand */
  --teal:        #0e7c86;
  --teal-deep:   #0b5f67;
  --teal-ink:    #06363b;
  --gold:        #bf8a2b;
  --gold-soft:   #d9ab53;
  --gold-deep:   #9a6e1f;

  /* Canvas */
  --bg:          #f7f5f0;   /* warm ivory */
  --bg-2:        #fdfcf9;
  --card:        #ffffff;
  --ink:         #1c2b2d;
  --ink-soft:    #4a5b5d;
  --ink-faint:   #74878a;
  --line:        #e6e1d6;
  --line-soft:   #efeae0;
  --teal-wash:   #eef6f6;
  --gold-wash:   #f8f1e0;

  --radius:      16px;
  --radius-sm:   10px;
  --shadow-sm:   0 1px 2px rgba(11,95,103,.06), 0 2px 8px rgba(11,95,103,.05);
  --shadow-md:   0 6px 24px rgba(11,95,103,.10), 0 2px 6px rgba(11,95,103,.06);
  --shadow-lg:   0 18px 50px rgba(6,54,59,.16);

  --font: 'Inter', 'Noto Sans Sinhala', 'Noto Sans Tamil', 'Noto Sans Devanagari',
          'Noto Sans Bengali', 'Noto Nastaliq Urdu',
          system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --maxw: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-feature-settings: 'kern' 1, 'liga' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle paper texture behind everything */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(191,138,43,.06), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, rgba(14,124,134,.07), transparent 55%);
  pointer-events: none;
}

a { color: var(--teal-deep); text-decoration: none; }
a:hover { color: var(--gold-deep); }

/* ---------------- Top hero ---------------- */
.hero {
  background: linear-gradient(135deg, var(--teal-deep) 0%, var(--teal) 48%, #11929e 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid var(--gold);
}
.hero::after {
  content: '';
  position: absolute; right: -120px; top: -120px;
  width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(217,171,83,.30), transparent 62%);
  pointer-events: none;
}
.hero-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 22px 26px;
  position: relative; z-index: 1;
}
.hero-brand {
  display: flex; align-items: center; gap: 11px;
  font-weight: 800; letter-spacing: .2px; font-size: 15px;
  text-transform: uppercase; opacity: .92;
}
.hero-logo {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--gold-soft), var(--gold-deep));
  display: grid; place-items: center;
  color: var(--teal-ink); font-weight: 900; font-size: 17px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.hero h1 {
  font-size: clamp(26px, 5.2vw, 42px);
  line-height: 1.1; margin: 16px 0 6px; font-weight: 800;
  letter-spacing: -.5px;
}
.hero h1 .accent { color: var(--gold-soft); }
.hero-sub {
  font-size: clamp(15px, 2.4vw, 18px);
  opacity: .94; max-width: 680px; margin: 0;
  font-weight: 450;
}
.hero-stats {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px;
}
.hero-chip {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  padding: 6px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; backdrop-filter: blur(3px);
}
.hero-chip b { color: var(--gold-soft); }

/* ---------------- Sticky market nav ---------------- */
.marketnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(253,252,249,.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(6,54,59,.04);
}
.marketnav-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 10px 14px;
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.marketnav-inner::-webkit-scrollbar { display: none; }
.market-tab {
  flex: 0 0 auto;
  border: 1.5px solid var(--line);
  background: #fff; color: var(--ink-soft);
  padding: 9px 17px; border-radius: 999px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: all .18s ease; white-space: nowrap;
  font-family: var(--font);
}
.market-tab .flag { font-size: 16px; line-height: 1; }
.market-tab:hover { border-color: var(--teal); color: var(--teal-deep); }
.market-tab[aria-selected="true"] {
  background: linear-gradient(135deg, var(--teal-deep), var(--teal));
  border-color: var(--teal-deep); color: #fff;
  box-shadow: 0 4px 14px rgba(14,124,134,.28);
}
.market-tab .tcount {
  font-size: 11px; font-weight: 700;
  background: var(--gold-wash); color: var(--gold-deep);
  padding: 1px 7px; border-radius: 999px;
}
.market-tab[aria-selected="true"] .tcount {
  background: rgba(255,255,255,.22); color: #fff;
}

/* ---------------- Layout ---------------- */
.wrap {
  max-width: var(--maxw); margin: 0 auto;
  padding: 22px 16px 90px;
  display: grid; grid-template-columns: 220px 1fr; gap: 30px;
  align-items: start;
}
@media (max-width: 880px) {
  .wrap { grid-template-columns: 1fr; gap: 0; }
}

/* In-page jump list (creatives) */
.jumplist {
  position: sticky; top: 64px;
  align-self: start;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 90px); overflow-y: auto;
}
.jumplist h4 {
  margin: 2px 6px 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--gold-deep); font-weight: 800;
}
.jumplist a {
  display: block; padding: 7px 10px; border-radius: 9px;
  color: var(--ink-soft); font-weight: 600; line-height: 1.35;
  border-left: 2.5px solid transparent; margin-bottom: 1px;
}
.jumplist a:hover { background: var(--teal-wash); color: var(--teal-deep); }
.jumplist a.active { background: var(--teal-wash); color: var(--teal-deep); border-left-color: var(--gold); }
.jumplist a .jl-num {
  display: inline-block; min-width: 18px; font-weight: 800; color: var(--gold-deep);
}
.jumplist .jl-sep {
  margin: 9px 6px 5px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-faint); font-weight: 700;
  border-top: 1px dashed var(--line); padding-top: 9px;
}
.jumplist .jl-sep:first-of-type { border-top: 0; padding-top: 0; }
@media (max-width: 880px) {
  .jumplist { display: none; }
}

/* ---------------- Markdown content ---------------- */
.content { min-width: 0; }
.market-pane { display: none; }
.market-pane.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.md { color: var(--ink); }
.md h1 {
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 800; line-height: 1.18; letter-spacing: -.4px;
  margin: 40px 0 14px; padding-top: 14px;
  color: var(--teal-ink);
  scroll-margin-top: 70px;
}
.md h1:first-child { margin-top: 6px; }
/* Creative headers get a card-like treatment */
.md h1.creative-head {
  background: linear-gradient(120deg, var(--teal-deep), var(--teal));
  color: #fff; padding: 16px 20px; border-radius: 14px 14px 0 0;
  margin-bottom: 0; border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow-md);
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.md h1.creative-head .ch-badge {
  font-size: 12px; font-weight: 800; letter-spacing: .5px;
  background: var(--gold); color: var(--teal-ink);
  padding: 3px 10px; border-radius: 999px; text-transform: uppercase;
}
.md h2 {
  font-size: clamp(18px, 2.8vw, 22px);
  font-weight: 800; margin: 30px 0 10px; color: var(--teal-deep);
  letter-spacing: -.2px; scroll-margin-top: 70px;
  padding-bottom: 6px; border-bottom: 2px solid var(--line);
}
.md h3 {
  font-size: 15px; font-weight: 800; margin: 22px 0 8px;
  color: var(--gold-deep); text-transform: uppercase; letter-spacing: .5px;
}
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 24px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--teal); }
.md strong { color: var(--teal-ink); font-weight: 700; }
.md em { color: var(--ink-soft); }
.md hr {
  border: 0; height: 1px; margin: 34px 0;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}
.md a { color: var(--teal-deep); border-bottom: 1px solid rgba(14,124,134,.3); font-weight: 600; }
.md a:hover { color: var(--gold-deep); border-bottom-color: var(--gold); }

/* blockquotes (strategy/compliance notes) */
.md blockquote {
  margin: 16px 0; padding: 13px 18px;
  background: var(--gold-wash);
  border-left: 4px solid var(--gold);
  border-radius: 0 12px 12px 0;
  color: var(--ink); box-shadow: var(--shadow-sm);
}
.md blockquote p { margin: 6px 0; }
.md blockquote strong { color: var(--gold-deep); }

/* inline code & code blocks (routes, URLs, app strings) */
.md code {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  background: var(--teal-wash);
  color: var(--teal-deep);
  padding: 1.5px 6px; border-radius: 6px;
  font-size: .9em; font-weight: 600;
  border: 1px solid rgba(14,124,134,.12);
}
.md pre {
  background: var(--teal-ink); color: #d8eef0;
  padding: 14px 16px; border-radius: 12px; overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.md pre code { background: none; border: 0; color: inherit; padding: 0; }

/* ---------------- Tables (the beat-by-beat scripts + string banks) ---------------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 16px 0; border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  background: var(--card);
}
.md table {
  border-collapse: collapse; width: 100%;
  font-size: 14px; min-width: 560px;
}
.md table thead th {
  background: linear-gradient(180deg, var(--teal-deep), var(--teal));
  color: #fff; font-weight: 700; text-align: left;
  padding: 11px 14px; position: sticky; top: 0;
  font-size: 13px; letter-spacing: .2px;
  border-right: 1px solid rgba(255,255,255,.12);
}
.md table thead th:last-child { border-right: 0; }
.md table tbody td {
  padding: 11px 14px; border-top: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  vertical-align: top; line-height: 1.55;
}
.md table tbody td:last-child { border-right: 0; }
.md table tbody tr:nth-child(even) { background: #faf8f3; }
.md table tbody tr:hover { background: var(--teal-wash); }
.md table td strong { color: var(--teal-ink); }
.md table code { font-size: .85em; }
/* first column (beat #/time) emphasis */
.md table tbody td:first-child { font-weight: 600; color: var(--teal-deep); white-space: nowrap; }

/* ---------------- Copy affordance ---------------- */
/* table cells & list/quote blocks become copyable */
.copyable { cursor: copy; position: relative; transition: background .15s ease; border-radius: 4px; }
.copyable:hover { background: rgba(191,138,43,.10) !important; }
.copyable:hover::after {
  content: '⧉ copy';
  position: absolute; top: 2px; right: 4px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .3px;
  color: var(--gold-deep); background: var(--gold-wash);
  padding: 1px 6px; border-radius: 6px; opacity: .9;
  font-family: 'Inter', sans-serif; pointer-events: none;
}
.copyable.copied { background: rgba(14,124,134,.14) !important; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--teal-ink); color: #fff;
  padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 200; display: flex; align-items: center; gap: 8px;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .tcheck { color: var(--gold-soft); font-weight: 900; }

/* ---------------- RTL (Urdu) ---------------- */
/* Lines/cells whose content is Arabic-script get auto direction.
   We tag them with dir="auto" in JS; browser flows RTL while
   English/numbers inside stay LTR. Nastaliq needs extra line height. */
[dir="auto"] { unicode-bidi: plaintext; }
.rtl-line {
  direction: rtl; text-align: right; unicode-bidi: plaintext;
  line-height: 2.05; /* Nastaliq sits tall */
}
.md table td.rtl-line { line-height: 2.0; }
.urdu-pane .md p,
.urdu-pane .md li { line-height: 1.9; }

/* footer */
.foot {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 18px 50px;
  color: var(--ink-faint); font-size: 13px; text-align: center;
  border-top: 1px solid var(--line);
}
.foot b { color: var(--ink-soft); }

/* loading state */
.loading {
  padding: 60px 20px; text-align: center; color: var(--ink-faint);
  font-size: 15px;
}
.spinner {
  width: 26px; height: 26px; margin: 0 auto 14px;
  border: 3px solid var(--line); border-top-color: var(--teal);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* "back to top" */
#totop {
  position: fixed; right: 18px; bottom: 22px; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--teal-deep); color: #fff; border: 0;
  font-size: 20px; cursor: pointer; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .2s ease;
  display: grid; place-items: center;
}
#totop.show { opacity: .92; pointer-events: auto; }
#totop:hover { transform: translateY(-2px); opacity: 1; }

@media (max-width: 560px) {
  .hero-inner { padding: 24px 18px 22px; }
  .md table { font-size: 13px; }
  .md h1.creative-head { padding: 14px 16px; }
  #totop { right: 12px; bottom: 14px; }
}
