/* MyFaith — styles.
   One bold element: the sky at the top of the home screen, painted for the current prayer period.
   Everything else stays quiet: cool paper, one teal accent, Atkinson Hyperlegible for reading, Amiri for Arabic. */

:root {
  --paper: #f4f6f5;
  --surface: #ffffff;
  --ink: #14201e;
  --muted: #56645f;
  --line: #dbe2df;
  --accent: #13665c;
  --accent-ink: #ffffff;
  --accent-soft: #e0eeea;
  --danger: #a33a2c;
  --focus: #1b7fd1;

  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --arabic: 'Amiri', 'Traditional Arabic', 'Geeza Pro', serif;
  --tabs-h: 64px;
  --top-h: 56px;
  --r-s: 10px;
  --r-m: 16px;
  --r-l: 26px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1517; --surface: #172024; --ink: #e8eeec; --muted: #9eaca8; --line: #26343a;
    --accent: #5cc2b1; --accent-ink: #06231f; --accent-soft: #17312e; --danger: #f08a7a; --focus: #7cc0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1517; --surface: #172024; --ink: #e8eeec; --muted: #9eaca8; --line: #26343a;
  --accent: #5cc2b1; --accent-ink: #06231f; --accent-soft: #17312e; --danger: #f08a7a; --focus: #7cc0ff;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 var(--font);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { flex: none; }
.ar { font-family: var(--arabic); font-size: var(--ar-size, 1.8rem); line-height: 2; text-align: right; margin: .25rem 0 .5rem; }

/* ------------------------------------------------------------------ top bar & tabs */
.top {
  position: sticky; top: 0; z-index: 10; height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 16px; display: flex; align-items: center; justify-content: space-between;
  background: var(--paper);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand img { border-radius: 7px; }
.top-title { font-size: 1.15rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: none; color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--accent-soft); }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .78rem;
}
.tab[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tab[aria-current="page"] svg { stroke-width: 2.3; }

main { display: block; max-width: 560px; margin: 0 auto; outline: none; }

/* ------------------------------------------------------------------ buttons & form bits */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700;
  text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn-text { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled, fieldset:disabled .btn { opacity: .45; cursor: default; }
.stack { display: grid; gap: 10px; margin-top: 16px; }
.stack-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 10px; }
.note { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r-s) var(--r-s) 0; font-size: .92rem; }
.empty { color: var(--muted); padding: 24px 0; }

.field { display: grid; gap: 6px; margin-top: 14px; font-weight: 700; font-size: .92rem; }
select, input[type="search"] {
  min-height: 46px; border-radius: var(--r-s); border: 1.5px solid var(--line); background: var(--surface); padding: 0 12px; width: 100%;
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: .92rem; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 700; }

.page { padding: 8px 16px 32px; }
.page-title { font-size: 1.5rem; margin: 4px 0 8px; }

/* ------------------------------------------------------------------ the sky */
.sky {
  --sky-a: #0f1b3d; --sky-b: #2b3a72; --sky-ink: #f3f5ff; --sky-soft: rgba(243, 245, 255, .72); --sky-line: rgba(243, 245, 255, .35); --sun: #ffd46b;
  position: relative; overflow: hidden; margin: 0 12px; padding: 18px 18px 10px; border-radius: var(--r-l);
  color: var(--sky-ink); background: linear-gradient(172deg, var(--sky-a) 0%, var(--sky-b) 100%);
  transition: background .8s ease;
}
.sky[data-sky="fajr"]    { --sky-a: #232a5c; --sky-b: #b06f86; --sun: #ffd9a0; }
.sky[data-sky="morning"] { --sky-a: #3d7fb8; --sky-b: #f2c27a; --sky-ink: #ffffff; --sky-soft: rgba(255,255,255,.85); --sun: #fff1c2; }
.sky[data-sky="dhuhr"]   { --sky-a: #1d63a6; --sky-b: #6aaedd; --sky-ink: #ffffff; --sky-soft: rgba(255,255,255,.86); --sun: #fff6cf; }
.sky[data-sky="asr"]     { --sky-a: #8a4a1c; --sky-b: #d98e45; --sky-ink: #fffaf2; --sky-soft: rgba(255,250,242,.86); --sun: #ffe6a8; }
.sky[data-sky="maghrib"] { --sky-a: #3d1f55; --sky-b: #d0624f; --sun: #ffb27a; }
.sky[data-sky="isha"]    { --sky-a: #0b1430; --sky-b: #23305e; --sun: #f4e9c8; }

.sky-top { display: grid; justify-items: start; gap: 12px; }
.sky-top .loc-btn { order: -1; max-width: 100%; }
.sky-greg { font-weight: 700; }
.sky-hijri { color: var(--sky-soft); font-size: .95rem; }
.loc-btn {
  display: inline-flex; align-items: center; gap: 4px; max-width: 48%; min-height: 40px; padding: 0 12px 0 8px;
  border: 1.5px solid var(--sky-line); border-radius: 999px; background: rgba(255,255,255,.08); color: var(--sky-ink); font-size: .85rem;
}
.loc-btn svg { width: 18px; height: 18px; }
.loc-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sky-now { margin-top: 22px; color: var(--sky-soft); }
.sky-next { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.next-name, .next-time { font-size: clamp(2.4rem, 11vw, 3.4rem); line-height: 1.05; font-weight: 700; letter-spacing: -.01em; }
.next-time { font-variant-numeric: tabular-nums; }
.sky-count { font-size: 1.05rem; margin-top: 2px; }
.sky-arc { margin: 6px -8px 0; }
.arc { display: block; width: 100%; height: auto; }
.arc-day { fill: none; stroke: var(--sky-line); stroke-width: 1.5; stroke-dasharray: 2 5; stroke-linecap: round; }
.arc-night { fill: none; stroke: var(--sky-line); stroke-width: 1.2; stroke-dasharray: 1 5; stroke-linecap: round; opacity: .7; }
.arc-horizon { stroke: var(--sky-line); stroke-width: 1; }
.arc-dot { fill: var(--sky-ink); opacity: .75; }
.arc-dot.is-next { fill: none; stroke: var(--sky-ink); stroke-width: 2; opacity: 1; }
.arc-sun { fill: var(--sun); }
.arc-sun-glow { fill: var(--sun); opacity: .25; }
.arc-moon { fill: var(--sun); }
.arc-moon-cut { fill: var(--sky-b); }
.sky-loading { padding: 40px 0; }
.sky-msg { display: grid; gap: 14px; justify-items: start; padding: 22px 0; }
.btn-on-sky { background: rgba(255,255,255,.12); border-color: var(--sky-line); color: var(--sky-ink); }
.btn-on-sky:hover { border-color: var(--sky-ink); }
.btn-strong { background: var(--sky-ink); color: var(--sky-a); border-color: var(--sky-ink); }

/* first-run */
.sky-setup { padding: 34px 20px 22px; min-height: 62dvh; display: flex; flex-direction: column; }
.setup-title { font-size: clamp(2.2rem, 10vw, 3rem); line-height: 1.1; }
.setup-text { margin-top: 12px; max-width: 30ch; font-size: 1.1rem; color: var(--sky-soft); }
.setup-actions { display: grid; gap: 10px; margin-top: auto; padding-top: 32px; }
.setup-status { min-height: 1.5em; margin-top: 10px; color: var(--sky-ink); }
.setup-lang { display: flex; gap: 6px; margin-top: 10px; }
.setup-lang button { border: 0; background: none; color: var(--sky-soft); padding: 8px 6px; min-height: 40px; }
.setup-lang button.is-on { color: var(--sky-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

/* ------------------------------------------------------------------ the day's times */
.day { padding: 14px 16px 24px; }
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-label { display: grid; text-align: center; color: var(--ink); text-decoration: none; }
.day-label span { color: var(--muted); font-size: .88rem; }
.times { list-style: none; margin: 8px 0 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 1fr auto 48px; align-items: center; gap: 8px;
  min-height: 58px; padding-left: 14px; border-bottom: 1px solid var(--line); position: relative;
}
.row:last-child { border-bottom: 0; }
.row-name { font-size: 1.12rem; font-weight: 700; }
.row-time { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.row.is-minor .row-name, .row.is-minor .row-time { font-weight: 400; color: var(--muted); font-size: 1rem; }
.row.is-current { background: var(--accent-soft); border-radius: var(--r-s); border-bottom-color: transparent; }
.row.is-current::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--accent); }
.bell { width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; color: var(--muted); display: grid; place-items: center; }
.bell.is-on { color: var(--accent); }
.bell svg { width: 22px; height: 22px; }
.source { color: var(--muted); font-size: .82rem; margin-top: 14px; }

/* ------------------------------------------------------------------ qibla */
.qibla { text-align: center; display: grid; justify-items: center; }
.qibla .page-title { justify-self: start; }
.qibla-deg { display: grid; justify-items: center; }
.qibla-deg b { font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.qibla-deg span { color: var(--muted); }
.dial-wrap { width: min(86vw, 330px); margin: 18px 0 8px; }
.dial { width: 100%; height: auto; display: block; }
.dial-face { fill: var(--surface); stroke: var(--line); stroke-width: 2; transition: stroke .3s, fill .3s; }
.tick { stroke: var(--line); stroke-width: 1.5; }
.tick-major { stroke: var(--muted); stroke-width: 2; }
.dial-letter { font: 700 17px var(--font); fill: var(--muted); text-anchor: middle; dominant-baseline: central; }
.dial-letter.is-n { fill: var(--danger); }
.qibla-line { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.kaaba { fill: var(--ink); }
.kaaba-band { fill: #d6a93f; }
.phone-mark { fill: var(--ink); }
.dial-hub { fill: var(--accent); }
.dial-wrap[data-state="aligned"] .dial-face { stroke: var(--accent); stroke-width: 6; fill: var(--accent-soft); }
.qibla-status { min-height: 1.6em; font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; }
.qibla .hint { max-width: 36ch; }

/* ------------------------------------------------------------------ tasbih */
.tasbih { display: grid; gap: 14px; }
.dhikr { min-height: 9.5rem; text-align: center; display: grid; align-content: center; }
.dhikr .ar { text-align: center; font-size: 2.1rem; margin: 0; line-height: 1.8; }
.dhikr-step { color: var(--muted); font-size: .9rem; }
.dhikr-rumi { font-weight: 700; }
.dhikr-mean { color: var(--muted); font-size: .95rem; }
.counter {
  position: relative; justify-self: center; width: min(82vw, 320px); aspect-ratio: 1; border-radius: 50%;
  border: 0; background: var(--surface); color: var(--ink); display: grid; place-items: center; align-content: center;
  box-shadow: inset 0 0 0 1.5px var(--line); touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.counter:active { background: var(--accent-soft); }
.ring-wrap { position: absolute; inset: 0; }
.ring { width: 100%; height: 100%; }
.bead { fill: var(--line); transition: fill .15s; }
.bead.is-on { fill: var(--accent); }
.count { font-size: clamp(3.6rem, 18vw, 5rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; position: relative; }
.count-target { color: var(--muted); position: relative; }
.tasbih-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tasbih-tools .btn { white-space: nowrap; }
.today { grid-column: 1 / -1; grid-row: 2; color: var(--muted); font-size: .95rem; text-align: center; }

/* ------------------------------------------------------------------ doa */
.doa-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search { flex: 1; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--muted); width: 20px; height: 20px; }
.search input { padding-left: 40px; }
.size { display: flex; }
.aa-s { font-size: .85rem; font-weight: 700; }
.aa-l { font-size: 1.3rem; font-weight: 700; }
.doa-list { margin-top: 8px; }
.dua { border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--top-h) + env(safe-area-inset-top) + 8px); }
.dua summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 56px; cursor: pointer; font-weight: 700; font-size: 1.05rem;
}
.dua summary::-webkit-details-marker { display: none; }
.dua summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-right: 6px; }
.dua[open] summary::after { transform: rotate(-135deg); }
.dua-body { padding: 0 0 18px; }
.dua-rumi { font-style: italic; color: var(--ink); }
.dua-mean { margin-top: 8px; color: var(--muted); }
.dua-note { margin-top: 8px; font-size: .92rem; }
.dua-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.dua-foot cite { font-style: normal; font-size: .85rem; color: var(--muted); }

/* ------------------------------------------------------------------ calendar */
.cal-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; margin-bottom: 10px; }
.cal-head h2 { font-size: 1.35rem; }
.cal-head p { color: var(--muted); font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow { text-align: center; font-size: .78rem; color: var(--muted); padding: 4px 0; }
.dow.is-fri { color: var(--accent); font-weight: 700; }
.cell {
  position: relative; display: grid; align-content: center; justify-items: center; min-height: 54px; border-radius: var(--r-s);
  text-decoration: none; color: var(--ink); background: var(--surface);
}
.cell.is-empty { background: none; }
.cell .g { font-weight: 700; font-size: 1.02rem; line-height: 1.1; }
.cell .h { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.cell.is-hstart .h { color: var(--accent); font-weight: 700; }
.cell.is-fri .g { color: var(--accent); }
.cell.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.cell.is-special { background: var(--accent); }
.cell.is-special .g, .cell.is-special .h { color: var(--accent-ink); }
.cal-sub { font-size: 1.1rem; margin-top: 26px; }
.special { list-style: none; margin: 8px 0 0; padding: 0; }
.special a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.special b { grid-column: 1; }
.special span { grid-column: 1; color: var(--muted); font-size: .88rem; }
.special em { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-size: .88rem; font-weight: 700; color: var(--accent); }
.special .is-past a { opacity: .55; }
.special .is-past em { color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------------ settings */
.set-h { font-size: 1.05rem; margin: 26px 0 10px; }
.set-h:first-child { margin-top: 8px; }
.set-card { background: var(--surface); border-radius: var(--r-m); padding: 14px 16px; border: 1px solid var(--line); }
.set-zone b { margin-right: 4px; }
.set-label { font-weight: 700; font-size: .92rem; margin: 12px 0 6px; }
.set-label:first-child { margin-top: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--accent-soft); }
.seg button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: none; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(20, 32, 30, .18); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { flex: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--focus); outline-offset: 2px; }
.alerts { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; }
.alerts legend { font-weight: 700; font-size: .92rem; padding: 14px 0 4px; width: 100%; border-top: 1px solid var(--line); }
.alerts:disabled { opacity: .5; }
.alerts .btn { margin-top: 14px; }
.settings .seg + .set-label { margin-top: 16px; }

/* ------------------------------------------------------------------ sheet, toast, adhan banner */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(8, 14, 13, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet-wrap.open { background: rgba(8, 14, 13, .45); }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; background: var(--paper); outline: none;
  border-radius: var(--r-l) var(--r-l) 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.25rem; }
.zone-list { border: 0; padding: 0; margin: 14px 0 0; }
.zone-list legend { font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.zone-opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.zone-opt input { margin-top: 5px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: var(--r-m);
  background: var(--ink); color: var(--paper); font-size: .95rem;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.azan-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 536px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border-radius: var(--r-m); background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.azan-banner .btn { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }

@media (min-width: 600px) {
  .sky { margin: 0 auto; max-width: 536px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
