/* Reusable components: top bar, hero, tabs, cards, counter, nav, sheets, toast. */

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.topbar__in { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 4px; }
.brand { flex: 1; min-width: 0; }
.brand b { font-family: var(--font-display); font-size: 20px; color: var(--acc); display: block; line-height: 1.2; }
.brand span { font-size: 12px; color: var(--muted); display: block; min-height: 1.5em; line-height: 1.5; } /* reserved before the date is written: no jump */
/* «دون اتصال» after the date, only while the device is offline */
.is-offline .brand span::after { content: " · دون اتصال"; color: var(--acc); }

/* ---------- hero ---------- */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 14px 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title ring" "sub ring" "actions actions";
  column-gap: 12px; align-items: center;
}
.hero__main { display: contents; }
.hero h1 { grid-area: title; font-family: var(--font-display); font-size: 28px; margin: 0; color: var(--acc); line-height: 1.25; min-height: 1.25em; }
.hero__sub {
  grid-area: sub; align-self: start; justify-self: start; text-align: start; margin: 0; color: var(--muted); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 2px 0; min-height: calc(1.6em + 4px);
}
.hero__sub::after { content: ""; width: 6px; height: 6px; border-inline-start: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); opacity: .6; margin-top: -2px; }
.hero__sub:hover { color: var(--acc); }
.hero .ring { grid-area: ring; }
.hero__actions {
  grid-area: actions; margin-top: 12px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.hero__actions .pill-btn { min-height: 42px; padding: 0 10px; white-space: nowrap; }
.hero__actions #btn-resume { grid-column: 1 / -1; }
@media (min-width: 640px) and (max-width: 1023px) {
  .hero__actions { display: flex; flex-wrap: wrap; }
  .hero__actions #btn-resume { grid-column: auto; }
}

.ring { width: 72px; height: 72px; flex-shrink: 0; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__value {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-family: var(--font-display); font-size: 18px; color: var(--acc); line-height: 1.1;
}
.ring__value small { display: block; font-family: var(--font-body); font-size: 11px; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
/* Before the first draw: reserve the strip when the period about to show has tabs (index.html
   guesses from the address or the last visit), and nothing when it has none. */
.tabs:empty { padding: 0; }
[data-tabs] .tabs:empty { min-height: 62px; }
.tab {
  white-space: nowrap; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 700; color: var(--muted); min-height: 42px;
}
.tab[aria-selected="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.tab__count { font-family: var(--font-display); font-size: 11px; opacity: .8; margin-inline-start: 6px; }
.screen-sub { margin: 8px 4px 10px; font-size: 13px; color: var(--muted); font-weight: 400; font-family: inherit; line-height: 1.7; min-height: 1.7em; }

/* ---------- section headers ---------- */
.section-title {
  display: flex; align-items: center; gap: 8px; margin: 18px 4px 10px;
  font-family: var(--font-display); font-size: 15px; color: var(--acc);
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.fold {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: start;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 16px;
  padding: 12px 14px; margin: 0 0 12px; color: var(--muted); font-size: 14px; min-height: 52px;
}
.fold b { color: var(--ink); }
.fold svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform .2s; }
.fold[aria-expanded="true"] svg.chev { transform: rotate(180deg); }
.fold .ok { color: var(--ok); }

/* ---------- item card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; margin: 0 0 12px; box-shadow: var(--shadow);
  scroll-margin-top: 84px; transition: opacity .2s, border-color .2s;
}
.card.is-done { opacity: .62; }
.card.is-focus { border-color: var(--acc); }
.card.is-quran { background: var(--acc-soft); border-color: transparent; }
.card__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card__num { font-family: var(--font-display); font-size: 13px; color: var(--acc); min-width: 22px; }
.chip {
  font-family: var(--font-display); font-size: 12px; color: var(--acc);
  border: 1.5px solid var(--acc); border-radius: 999px; padding: 1px 10px;
}
.chip.is-core { background: var(--acc); color: var(--acc-ink); }
.card__spacer { flex: 1; }
.check {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  border: 1.5px solid var(--line); color: transparent;
}
.check svg { width: 20px; height: 20px; }
.is-done .check, .check[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.card h3 { font-size: calc(15px * var(--fs)); margin: 2px 0 6px; line-height: 1.6; }
.text { font-size: calc(18px * var(--fs)); line-height: 2; margin: 0; white-space: pre-line; }
.text + .text { margin-top: .6em; }
.quran { font-family: var(--font-quran); font-size: calc(22px * var(--fs)); line-height: 2.15; margin: 0; }
.ayah-no { font-family: var(--font-marker); color: var(--acc); font-size: .9em; white-space: nowrap; }
.card__foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card__source { font-size: 12px; color: var(--muted); margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }

/* ---------- counter ---------- */
.counter {
  flex: 1; min-width: 170px; position: relative; overflow: hidden; border-radius: 14px;
  background: var(--surface-2); min-height: 52px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; font-family: var(--font-display);
  font-size: 17px; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.counter__fill { position: absolute; inset: 0 0 0 auto; width: 0; background: var(--acc-soft); transition: width .15s; }
.counter > span { position: relative; }
.counter__hint { font-family: var(--font-body); font-size: 12.5px; color: var(--muted); }
.counter.is-full { background: var(--acc); color: var(--acc-ink); }
.counter.is-full .counter__hint { color: var(--acc-ink); }
.counter.bump { animation: bump .16s; }
@keyframes bump { 50% { transform: scale(.98); } }
.square-btn { width: 52px; padding: 0; min-height: 52px; }

/* ---------- checkpoint (obligatory prayer) ---------- */
.checkpoint {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin: 0 0 12px;
  border-radius: var(--radius); border: 2px solid var(--acc); background: var(--surface);
}
.checkpoint__icon { width: 44px; height: 44px; border-radius: 12px; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; flex-shrink: 0; }
.checkpoint__icon svg { width: 24px; height: 24px; }
.checkpoint__body { flex: 1; min-width: 0; }
.checkpoint__body b { display: block; font-family: var(--font-display); font-size: 17px; color: var(--acc); }
.checkpoint__body span { font-size: 13px; color: var(--muted); }
.checkpoint.is-done { border-style: dashed; opacity: .75; }

/* ---------- Quran wird card ---------- */
.wird { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow); }
.wird__top { display: flex; align-items: center; gap: 10px; }
.wird__top b { font-family: var(--font-display); font-size: 17px; color: var(--acc); flex: 1; }
.wird__range { font-size: calc(17px * var(--fs)); margin: 6px 0 2px; font-weight: 700; }
.wird__meta { font-size: 13px; color: var(--muted); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--acc); border-radius: 99px; transition: width .3s; }
.wird__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- bottom navigation ---------- */
.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav__in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
.bottom-nav__in:empty { min-height: 77px; } /* a drawn button's height (icon, name, count): the bar does not grow when they appear */
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  border-radius: 14px; font-size: 11.5px; color: var(--muted); min-height: 58px; position: relative;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn[aria-current="page"] { color: var(--acc); background: var(--acc-soft); }
.nav-btn__count { font-family: var(--font-display); font-size: 10px; }
.nav-btn__now { position: absolute; top: 6px; inset-inline-end: calc(50% - 20px); width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---------- sheets (dialogs) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(10, 8, 5, .45); display: none; align-items: flex-end; justify-content: center; }
.sheet.is-open { display: flex; }
.sheet__panel {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 88vh; max-height: 88dvh; overflow: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0; padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet__panel:focus { outline: none; }
/* dvh: the visible height, so nothing hides behind a phone browser's toolbar. */
.sheet.is-full .sheet__panel { max-height: 100vh; max-height: 100dvh; height: 100vh; height: 100dvh; border-radius: 0; }
.sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; background: var(--bg); padding: 12px 0 8px; z-index: 2;
}
.sheet.is-full .sheet__head { padding-top: calc(8px + env(safe-area-inset-top)); }
.sheet__head h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Something that should stay in view under the head while the sheet scrolls (search fields). */
.sheet-sticky { position: sticky; top: var(--head-h, 56px); z-index: 1; background: var(--bg); padding: 2px 0 10px; }
.sheet__head h2 { font-family: var(--font-display); color: var(--acc); margin: 0; font-size: 22px; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row > span { font-size: 15px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { min-width: 48px; min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); font-family: var(--font-display); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--acc-ink); }
.field { width: 100%; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 16px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: .25s;
  z-index: 70; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translateX(-50%); }

/* ---------- «update ready» bar ---------- */
.update-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 12px); z-index: 65;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; padding-inline-start: 16px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18); font-size: 14px; max-width: calc(100vw - 24px);
}
.update-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-bar .icon-btn { font-size: 20px; line-height: 1; }

/* ---------- special prayers / occasions ---------- */
.special { background: linear-gradient(160deg, var(--acc-soft), var(--surface) 70%); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow); }
.special__top { display: flex; align-items: center; gap: 10px; color: var(--acc); }
.special__top svg { width: 24px; height: 24px; flex-shrink: 0; }
.special__top b { display: block; font-family: var(--font-display); font-size: 17px; }
.special__top span { font-size: 13px; color: var(--muted); }
.special-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.special-list button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: start; padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.special-list button:hover { background: var(--surface-2); }
.special-list button.is-done { opacity: .7; }
.special-list svg.chev { width: 16px; height: 16px; transform: rotate(90deg); color: var(--muted); flex-shrink: 0; }
.special-name { flex: 1; min-width: 0; font-weight: 700; font-size: calc(15px * var(--fs)); }
.special-name small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.special-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.is-done .special-dot { background: var(--ok); border-color: var(--ok); }
.special-dot svg { width: 14px; height: 14px; }
.special-when { display: flex; align-items: center; gap: 8px; color: var(--acc); font-weight: 700; margin: 0 0 6px; }
.special-when svg { width: 18px; height: 18px; }
.special-text { margin-top: .6em; }
.special-lib h3 { font-family: var(--font-display); color: var(--acc); font-size: 16px; margin: 16px 0 4px; }

/* ---------- short screens (small phones, landscape): give the content more room ---------- */
@media (max-height: 700px) {
  .topbar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .nav-btn { min-height: 48px; padding: 4px 2px; gap: 0; }
  .nav-btn svg { width: 21px; height: 21px; }
  .hero { padding: 12px 14px; }
  .hero h1 { font-size: 24px; }
  .hero .ring { width: 60px; height: 60px; }
  .hero__actions { margin-top: 10px; }
  .hero__actions .pill-btn { min-height: 40px; }
}

/* ---------- install offer ---------- */
.install {
  position: fixed; z-index: 40; left: 50%; bottom: calc(var(--nav-h) + 12px);
  width: min(520px, calc(100% - 24px)); transform: translate(-50%, 16px); opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 6px;
  background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--acc) 45%, var(--line)); border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28); transition: opacity .25s, transform .25s;
}
.install.is-on { opacity: 1; transform: translate(-50%, 0); }
.install__icon { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
.install__text { flex: 1; min-width: 0; }
.install__text b { display: block; font-family: var(--font-display); color: var(--acc); font-size: 15px; }
.install__text span { font-size: 12.5px; color: var(--muted); }
.install .pill-btn { min-height: 40px; padding: 0 16px; flex-shrink: 0; }
.install__close { width: 36px; height: 36px; color: var(--muted); flex-shrink: 0; }
.install__close svg { width: 18px; height: 18px; }
.ins-steps { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; }
.ins-step {
  display: grid; grid-template-columns: 26px 40px 1fr; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px;
  font-size: 14.5px; line-height: 1.7;
}
.ins-step i { font-style: normal; font-family: var(--font-display); color: var(--acc); font-size: 16px; text-align: center; }
.ins-step__icon { width: 40px; height: 40px; border-radius: 12px; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; }
.ins-step__icon svg { width: 22px; height: 22px; }
@media (prefers-reduced-motion: reduce) { .install { transition: none; } }
