/* QiblaPulse v0.4.0 – Adhan & Compass · navy/gold, English-first (LTR), optional Urdu (RTL) */
:root {
  --navy: #081b40; --navy-deep: #040e24; --blue: #164ea0;
  --gold: #e8b632; --gold-light: #fad66e; --green: #0f7a43;
  --bg: #eef2f8; --card: #fff; --card2: #f3f6fb;
  --ink: #0d1a33; --ink2: #2a3a57; --muted: #56657f; --line: #e1e7f0;
  --head-1: #081b40; --head-2: #0c2657; --title: #081b40;
  --shadow: 0 1px 2px rgba(8,27,64,.06), 0 6px 18px rgba(8,27,64,.07);
  --radius: 16px; --tabbar-h: 66px; --tap: 44px; --col: 480px;
  --bottom-space: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  --desk-bg: #d9e0ec;
  --nq: "Noto Nastaliq Urdu", "Noto Naskh Arabic", "Segoe UI", serif;
  --nk: "Noto Naskh Arabic", "Segoe UI", system-ui, sans-serif;
  --lt: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #050c1a; --card: #0d1930; --card2: #14233f;
  --ink: #e8eef8; --ink2: #c4d0e4; --muted: #8b9cb9; --line: #1c2b48;
  --head-1: #030a1a; --head-2: #081a3d; --title: #f3f6fc;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  --desk-bg: #02060f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
/* Phone-width column: full width on phones, centred 480px "phone" on desktop */
body {
  margin: 0 auto; max-width: var(--col); min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: var(--nk); font-size: 16px; line-height: 1.7;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
@media (min-width: 520px) {
  html { background: var(--desk-bg); }
  body { box-shadow: 0 0 0 1px var(--line), 0 12px 48px rgba(8,27,64,.18); }
}
body.no-tabs .tabbar { display: none; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.en { font-family: var(--lt); direction: ltr; unicode-bidi: isolate; letter-spacing: .01em; }
.num { font-family: var(--lt); direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* splash */
#splash {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(circle at 50% 40%, #1a4a9a 0%, #081b40 55%, #040e24 100%);
  color: #fff; transition: opacity .4s, visibility .4s;
}
#splash img { width: 112px; height: 112px; border-radius: 28px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
#splash .sp-ur { font-family: var(--nq); font-size: 28px; color: var(--gold-light); margin-top: 12px; }
#splash .sp-en { font-family: var(--lt); font-weight: 800; letter-spacing: .18em; font-size: 11px; color: #dfe7f5; direction: ltr; }
#splash .sp-tag { font-size: 13px; color: #b9c8e2; margin-top: 6px; }
#splash .sp-bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 22px; }
#splash .sp-bar i { display: block; height: 100%; width: 40%; background: var(--gold); animation: load 1s ease-in-out infinite; }
#splash.hide { opacity: 0; visibility: hidden; }
@keyframes load { from { transform: translateX(160%); } to { transform: translateX(-260%); } }

/* off-screen via vertical offset only (a large left/right offset widened the RTL page on mobile) */
.skip-link {
  position: fixed; inset-inline-start: 8px; top: 0; transform: translateY(-120%); background: var(--gold); color: var(--navy);
  padding: 8px 12px; z-index: 200; border-radius: 0 0 10px 10px; transition: transform .15s;
}
.skip-link:focus { transform: none; }

/* header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; color: #fff; min-height: 56px;
  background: linear-gradient(180deg, var(--head-1), var(--head-2));
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 0 0 2px var(--gold); }
.brand-ur { font-family: var(--nq); font-size: 18px; color: var(--gold-light); line-height: 1.6; }
.brand-en { font-family: var(--lt); font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #dbe4f3; direction: ltr; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: #fff; display: grid; place-items: center; cursor: pointer;
}

/* bottom padding = tab bar + safe-area + breathing room, so the last row (e.g. Isha/Maghrib) is never hidden */
main { margin: 0 auto; padding: 8px 14px calc(var(--bottom-space) + 20px); outline: none; }
body.no-tabs main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); }

.page-h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 6px; }
.page-h h1 { font-family: var(--nq); font-weight: 400; font-size: 24px; margin: 0; color: var(--title); line-height: 1.8; }
.page-h .en { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.h-sec { font-family: var(--nq); font-size: 17px; margin: 0 0 10px; color: var(--title); display: flex; gap: 8px; align-items: baseline; }
.h-sec .en { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-family: var(--lt); }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 12px;
}
.card.list { padding: 4px 0; }

.note { display: flex; gap: 8px; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; line-height: 1.6; }
.note small { display: block; opacity: .9; margin-top: 4px; }
.gold-note { background: #fff7dd; border: 1px solid #f0d58a; color: #5b4300; }
[data-theme="dark"] .gold-note { background: #2a2208; border-color: #6a5518; color: #fad66e; }

/* next prayer */
.next-card {
  background: linear-gradient(145deg, var(--navy) 0%, #0c2a60 60%, #0a3d2a 100%);
  color: #fff; text-align: center; padding: 16px 14px;
}
.next-l { font-size: 13px; opacity: .85; }
.next-name { font-family: var(--nq); font-size: 26px; color: var(--gold-light); margin: 2px 0; }
.next-count { font-size: 30px; font-weight: 700; letter-spacing: .04em; margin: 2px 0; }
.next-at { opacity: .8; }
.progress { height: 4px; background: rgba(255,255,255,.15); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 4px; transition: width .4s; }

.place-card .place-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.place-line strong { font-family: var(--nq); font-size: 18px; }

.prayer-list .prayer-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 14px; border-bottom: 1px solid var(--line); min-height: 42px;
}
.prayer-list .prayer-row:last-child { border-bottom: 0; }
.prayer-row.active { background: rgba(232,182,50,.12); }
.prayer-row.active .pr-name b { color: var(--green); }
[data-theme="dark"] .prayer-row.active { background: rgba(232,182,50,.08); }
.pr-name b { font-family: var(--nq); font-size: 17px; margin-inline-end: 6px; }
.pr-time { font-size: 18px; font-weight: 700; }
.method-note { padding: 0 4px 8px; line-height: 1.55; }

/* onboarding / cities */
.onboard .ob-hero { text-align: center; margin-bottom: 16px; }
.onboard .ob-hero img { border-radius: 22px; }
.onboard .ob-hero h1 { font-family: var(--nq); font-size: 26px; margin: 10px 0 4px; color: var(--title); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.field input, .field select {
  min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); padding: 8px 12px;
}
.city-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.city-list.compact { max-height: 180px; }
.city-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: start; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; min-height: var(--tap);
}
.city-row:last-child { border-bottom: 0; }
.city-row:hover, .city-row:focus { background: var(--card2); }
.city-ur { font-family: var(--nq); font-size: 16px; }
.city-en { font-size: 12px; color: var(--muted); }
.empty { padding: 16px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 8px 16px; border-radius: 12px; border: 0;
  background: var(--navy); color: #fff; cursor: pointer; font-weight: 600; width: 100%; margin-bottom: 10px;
}
.btn .ic { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 120px; width: auto; margin-bottom: 0; }

.switch-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: var(--tap); font-size: 15px;
}
.switch-row input { width: 22px; height: 22px; }

.link-row {
  display: block; padding: 12px 16px; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.link-row:last-child { border-bottom: 0; }

/* compass */
.compass-card { text-align: center; }
.compass-wrap {
  position: relative; width: min(280px, 80vw); height: min(280px, 80vw);
  margin: 8px auto 16px;
}
.compass-dial {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #1a3a6e, var(--navy-deep));
  border: 3px solid var(--gold); box-shadow: inset 0 0 40px rgba(0,0,0,.35);
  transition: transform .12s linear;
}
.compass-ring {
  position: absolute; inset: 18px; border-radius: 50%;
  border: 1px dashed rgba(250,214,110,.35);
}
.c-mark {
  position: absolute; font-family: var(--lt); font-weight: 800; font-size: 14px; color: var(--gold-light);
}
.c-n { top: 10px; left: 50%; transform: translateX(-50%); }
.c-s { bottom: 10px; left: 50%; transform: translateX(-50%); color: #9bb; }
.c-e { right: 12px; top: 50%; transform: translateY(-50%); color: #9bb; }
.c-w { left: 12px; top: 50%; transform: translateY(-50%); color: #9bb; }
.qibla-needle {
  position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 28px; transition: transform .12s linear; pointer-events: none; z-index: 2;
}
.needle-arrow {
  width: 0; height: 0;
  border-left: 10px solid transparent; border-right: 10px solid transparent;
  border-bottom: 90px solid var(--gold);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}
.needle-kaaba {
  position: absolute; top: 22px; font-family: var(--nq); font-size: 11px; color: var(--navy);
  background: var(--gold-light); padding: 0 6px; border-radius: 6px; line-height: 1.6;
}
.compass-center {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px;
  border-radius: 50%; background: var(--gold); border: 3px solid #fff; z-index: 3;
}
.compass-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px;
}
.compass-stats .big { font-size: 18px; font-weight: 700; margin-top: 2px; }
.calib-tip {
  font-size: 13px; color: var(--muted); background: var(--card2); border-radius: 10px;
  padding: 8px 10px; margin: 8px 0 12px;
}

/* tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--col); z-index: 50;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(8,27,64,.06);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; min-height: var(--tap);
}
.tabbar a b { font-family: var(--nq); font-weight: 400; font-size: 13px; line-height: 1.4; }
.tabbar a small { font-family: var(--lt); font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }
.tabbar a.active { color: var(--gold); }
[data-theme="light"] .tabbar a.active { color: var(--navy); }
.tabbar a.active .ic { stroke: var(--gold); }
[data-theme="light"] .tabbar a.active .ic { stroke: var(--navy); }

/* toast */
/* toast sits above the tab bar (never over the last content row for long) and auto-hides after ~2 s */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-space) + 12px);
  transform: translateX(-50%) translateY(12px); z-index: 80;
  background: var(--navy); color: #fff; padding: 8px 16px; border-radius: 14px;
  font-size: 14px; line-height: 1.6; opacity: 0; visibility: hidden; pointer-events: none; transition: .25s;
  width: max-content; max-width: min(calc(100vw - 32px), calc(var(--col) - 32px)); text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); border: 1px solid rgba(232,182,50,.35);
}
body.no-tabs .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  #splash .sp-bar i, .compass-dial, .qibla-needle, .progress i, .toast { transition: none; animation: none; }
}

/* v0.2 additions */
.prayer-row.past .pr-time, .prayer-row.past .pr-name { opacity: .55; }
.prayer-row.sub { background: var(--card2); }
.prayer-row.sub .pr-name b { font-size: 14px; }
.prayer-row.sub .pr-time { font-size: 15px; font-weight: 600; color: var(--muted); }
.place-line .chg { margin-inline-start: auto; font-size: 13px; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; padding-inline: 8px; }
.next-at { color: rgba(255,255,255,.8); }
.sound-row { display: flex; gap: 8px; align-items: flex-end; }
.sound-row .field { flex: 1; min-width: 0; }
.sound-row .field select { width: 100%; }
.btn-test { width: auto; flex: none; margin-bottom: 12px; padding-inline: 14px; }
.adhan-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-space) + 10px); z-index: 70;
  width: calc(100% - 24px); max-width: calc(var(--col) - 24px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--navy);
  border-radius: 14px; padding: 6px 8px 6px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600;
}
.adhan-bar .ab-txt { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adhan-bar .ab-stop { min-height: var(--tap); border: 0; border-radius: 10px; background: var(--navy); color: #fff; padding: 0 14px; cursor: pointer; flex: none; }
body.no-tabs .adhan-bar { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
.perm-list { margin: 6px 0 0; padding-inline-start: 18px; font-size: 13.5px; }
.perm-list li { margin-bottom: 4px; }
.perm-list .en { display: block; opacity: .85; font-size: 12.5px; text-align: start; }
.place-line .chg .en { margin-inline-start: 4px; }
p[dir="ltr"] { text-align: left; }
body.adhan-on main { padding-bottom: calc(var(--bottom-space) + 96px); }

/* Maghrib/Isha must clear the tab bar when scrolled into view */
.prayer-row[data-k="Maghrib"], .prayer-row[data-k="Isha"] { scroll-margin-bottom: calc(var(--bottom-space) + 12px); }
.hijri-note { margin: 0 0 12px; }
.doc-page .card { margin-bottom: 12px; }

.place-card { padding: 10px 14px; }
.place-card .place-line strong { font-size: 16px; }
.hijri-note { font-size: 12px; margin: 0 0 8px; line-height: 1.45; }
.method-note { font-size: 12px; }


/* weather (Open-Meteo) */
.weather-card { padding: 12px 14px; }
.weather-card .wx-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.weather-card .wx-title {
  font-family: var(--nq); font-size: 16px; color: var(--title);
}
.weather-card .wx-title .en {
  font-family: var(--lt); font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin-inline-start: 6px;
}
.weather-card .wx-emoji { font-size: 22px; line-height: 1; }
.weather-card .wx-now {
  display: flex; gap: 14px; align-items: center; margin-bottom: 8px;
}
.weather-card .wx-temp {
  font-size: 36px; font-weight: 700; line-height: 1; color: var(--navy);
  min-width: 4.2rem;
}
[data-theme="dark"] .weather-card .wx-temp { color: var(--gold-light); }
.weather-card .wx-unit { font-size: 16px; font-weight: 600; margin-inline-start: 2px; opacity: .75; }
.weather-card .wx-cond { flex: 1; min-width: 0; line-height: 1.45; font-size: 14px; }
.weather-card .wx-cond b { font-family: var(--nq); font-size: 16px; }
.weather-card .wx-forecast {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px;
}
.weather-card .wx-day {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.weather-card .wx-day-name { width: 2.6rem; flex-shrink: 0; font-weight: 700; color: var(--muted); }
.weather-card .wx-day-ico { width: 1.4rem; text-align: center; }
.weather-card .wx-day-lab { flex: 1; min-width: 0; }
.weather-card .wx-day-lab b { font-family: var(--nq); font-weight: 400; }
.weather-card .wx-day-hl { margin-inline-start: auto; white-space: nowrap; }
.weather-card .wx-hi { font-weight: 700; margin-inline-end: 6px; }
.weather-card .wx-src { margin: 8px 0 0; }
.weather-card .wx-fail { margin: 4px 0 0; }
.weather-card .wx-skel { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; }
.weather-card .wx-skel-line {
  height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, var(--card2) 25%, var(--line) 50%, var(--card2) 75%);
  background-size: 200% 100%;
  animation: wx-shimmer 1.2s ease-in-out infinite;
}
.weather-card .wx-skel-line.short { width: 55%; }
@keyframes wx-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* v0.4.0 — English-first, LTR. Urdu (RTL) only when chosen in Settings. */
html[lang="en"] body { font-family: var(--lt); line-height: 1.55; }
html[lang="en"] .page-h h1, html[lang="en"] .h-sec, html[lang="en"] .next-name,
html[lang="en"] .brand-ur, html[lang="en"] #splash .sp-ur, html[lang="en"] .onboard .ob-hero h1,
html[lang="en"] .tabbar a b, html[lang="en"] .weather-card .wx-title,
html[lang="en"] .place-line strong, html[lang="en"] .pr-name b { font-family: var(--lt); }
html[lang="en"] .page-h h1 { font-weight: 700; font-size: 22px; line-height: 1.4; }
html[lang="en"] .h-sec { font-weight: 700; font-size: 16px; }
html[lang="en"] .brand-ur { font-weight: 800; font-size: 17px; letter-spacing: .01em; line-height: 1.3; }
html[lang="en"] .brand-en { letter-spacing: .08em; }
html[lang="en"] #splash .sp-ur { font-weight: 800; letter-spacing: .02em; }
html[lang="en"] #splash .sp-en { font-family: var(--nq); letter-spacing: 0; font-size: 15px; font-weight: 400; }
html[lang="en"] .next-name { font-weight: 700; font-size: 26px; }
html[lang="en"] .nx-ar { font-family: var(--nq); font-size: 16px; opacity: .75; margin-inline-start: 6px; font-weight: 400; }
html[lang="en"] .pr-name b { font-weight: 600; font-size: 16px; }
html[lang="en"] .pr-ar { font-family: var(--nq); font-size: 12px; color: var(--muted); margin-inline-start: 4px; }
html[lang="en"] .tabbar a b { font-weight: 600; font-size: 12px; }
html[lang="en"] .onboard .ob-hero h1 { font-weight: 800; }
html[lang="en"] .weather-card .wx-title { font-weight: 700; font-size: 15px; }
html[lang="en"] .weather-card .wx-cond b, html[lang="en"] .weather-card .wx-day-lab b { font-family: var(--lt); font-weight: 600; }
html[lang="en"] .needle-kaaba { font-family: var(--lt); font-weight: 700; }
html[lang="en"] .place-line strong { font-weight: 700; }
.city-name { font-weight: 600; font-size: 15px; }
input[type="search"] { direction: ltr; text-align: left; }
html[dir="ltr"] .adhan-bar { padding: 6px 8px 6px 14px; }
html[dir="rtl"] .adhan-bar { padding: 6px 14px 6px 8px; }
