/* Masjid Al Firdaus – green & gold, mobile first. */

:root {
  --green-900: #063d24;
  --green-800: #08532f;
  --green-700: #0b6b3a;
  --green-600: #11804a;
  --green-50: #e8f4ec;
  --gold: #d6a92f;
  --gold-deep: #b48717;
  --gold-soft: #f7edd2;

  --bg: #f4f2ea;
  --surface: #ffffff;
  --text: #1c2a22;
  --muted: #5e6c64;
  --border: #e1e5dc;
  --row-active: #e8f4ec;
  --live: #e53935;
  --idle: #9aa59e;
  --shadow: 0 8px 28px rgba(6, 61, 36, 0.10);
  --radius: 22px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1511;
    --surface: #15201a;
    --text: #e5eee8;
    --muted: #9fb1a6;
    --border: #25352c;
    --row-active: #183326;
    --green-50: #183326;
    --gold-soft: #3a3118;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1511;
  --surface: #15201a;
  --text: #e5eee8;
  --muted: #9fb1a6;
  --border: #25352c;
  --row-active: #183326;
  --green-50: #183326;
  --gold-soft: #3a3118;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Elements with display rules must still disappear when marked hidden. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.ar {
  font-family: "Noto Naskh Arabic", "Noto Sans Arabic", "Amiri", "Geeza Pro", "Segoe UI", Tahoma, serif;
  line-height: 1.6;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------------------------- */

.hero {
  color: #fff;
  text-align: center;
  padding: calc(28px + env(safe-area-inset-top)) 16px 64px;
  border-radius: 0 0 36px 36px;
  background:
    /* eight-point star lattice */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.09' stroke-width='1.2'%3E%3Crect x='14' y='14' width='28' height='28'/%3E%3Crect x='14' y='14' width='28' height='28' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='6'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(circle at 50% 0%, rgba(214, 169, 47, 0.28), transparent 60%),
    linear-gradient(160deg, var(--green-600), var(--green-800) 55%, var(--green-900));
}

.hero-inner { max-width: 520px; margin: 0 auto; }

.logo-arch {
  width: 132px;
  margin: 0 auto 14px;
  padding: 14px 12px 10px;
  background: #fff;
  border-radius: 66px 66px 20px 20px;
  border: 3px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.logo-arch img { display: block; width: 100%; height: auto; }

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2rem);
  letter-spacing: 0.02em;
}
.hero-ar { margin: 2px 0 0; font-size: 1.35rem; color: var(--gold-soft); }

.dates {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}
.dot-sep { color: var(--gold); }

.clock {
  margin: 8px 0 0;
  font-size: clamp(2.2rem, 11vw, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.clock .sec { color: var(--gold); font-size: 0.55em; margin-left: 2px; }
.clock .ampm { font-size: 0.4em; margin-left: 6px; opacity: 0.85; letter-spacing: 0.08em; }

/* ---------------------------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------------------------- */

main {
  max-width: 520px;
  margin: -40px auto 0;
  padding: 0 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0;
  font-size: 1.15rem;
  color: var(--green-700);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card h2 { color: #7fd1a3; }
}
:root[data-theme="dark"] .card h2 { color: #7fd1a3; }

.card h2 svg { width: 22px; height: 22px; fill: currentColor; }
.small-ar { font-size: 0.95rem; color: var(--muted); font-weight: 400; }

/* Live card -------------------------------------------------------------------------------- */

.live-card { border-top: 4px solid var(--gold); }

.live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
}
.badge-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.badge.live { color: #fff; background: var(--live); border-color: var(--live); }
.badge.live .badge-dot { background: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
}

.live-text { margin: 14px 0 0; color: var(--muted); line-height: 1.5; }
.live-text strong { color: var(--text); }
.live-text a { color: var(--green-700); font-weight: 700; word-break: break-all; }

.listener-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--green-700);
  background: var(--green-50);
}
.listener-count[hidden] { display: none; }
.listener-count svg { width: 18px; height: 18px; fill: currentColor; flex: none; }

.meter { display: block; width: 100%; height: 56px; margin-top: 14px; }

.volume { display: flex; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); }
.volume svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.volume input { flex: 1; accent-color: var(--green-700); }

.btn-listen {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  margin-top: 18px;
  padding: 14px 20px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--green-600), var(--green-800));
  box-shadow: 0 6px 18px rgba(11, 107, 58, 0.35);
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn-listen svg { width: 24px; height: 24px; fill: currentColor; }
.btn-listen:hover { filter: brightness(1.07); }
.btn-listen:active { transform: scale(0.98); }
.btn-listen:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* Live and not yet listening: gold, gently pulsing to invite a tap. */
.btn-listen.is-live {
  color: var(--green-900);
  background: linear-gradient(135deg, #f1cf63, var(--gold));
  box-shadow: 0 6px 20px rgba(214, 169, 47, 0.45);
  animation: invite 2s ease-in-out infinite;
}
@keyframes invite {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

/* "Notify me when live": secondary outline button under Listen. */
.btn-notify {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-700);
  background: transparent;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.btn-notify svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.btn-notify:hover { background: var(--green-50); }
.btn-notify:active { transform: scale(0.98); }
.btn-notify:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn-notify[data-state="on"] { border-color: var(--green-600); background: var(--green-50); }
.btn-notify[data-state="blocked"] { color: var(--muted); }
.btn-notify[data-state="busy"] { opacity: 0.7; cursor: progress; }
.notify-hint { margin: 8px 4px 0; font-size: 0.85rem; color: var(--muted); text-align: center; }

/* Listening: quiet outline "Stop" button. */
.btn-listen.is-stop {
  color: var(--green-700);
  background: transparent;
  border: 2px solid var(--border);
  box-shadow: none;
}

/* Next prayer -------------------------------------------------------------------------------- */

.next-card {
  background:
    radial-gradient(circle at 100% 0%, var(--gold-soft), transparent 55%),
    var(--surface);
}
.next-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}
.next-label .small-ar { text-transform: none; letter-spacing: 0; }
.next-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 4px; }
.next-name { margin: 0; font-size: 2rem; font-weight: 800; color: var(--text); }
.next-ar { margin: 0; font-size: 1.1rem; color: var(--muted); text-align: left; }
.next-countdown {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-700);
  background: var(--green-50);
  padding: 8px 12px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.next-times { margin: 10px 0 0; color: var(--muted); }
.next-times strong { color: var(--text); }

/* Timetable ------------------------------------------------------------------------------------ */

.times-head,
.times-list li {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  align-items: center;
  gap: 8px;
}
.times-head {
  margin-top: 14px;
  padding: 0 12px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.times-head span:not(:first-child),
.times-list .t { text-align: right; }

.times-list { list-style: none; margin: 6px 0 0; padding: 0; }
.times-list li {
  position: relative;
  padding: 10px 12px;
  border-radius: 14px;
}
.times-list li + li { margin-top: 2px; }
.times-list .name { font-weight: 700; }
.times-list .name .ar { display: block; font-weight: 400; font-size: 0.9rem; color: var(--muted); line-height: 1.6; text-align: left; }
.times-list .t { font-variant-numeric: tabular-nums; }
.times-list .jamaat { font-weight: 700; color: var(--green-700); }
.times-list li.muted { color: var(--muted); }
.times-list li.muted .name { font-weight: 500; }

.times-list li.current { background: var(--row-active); }
.times-list li.current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 4px;
  background: var(--green-700);
}
.times-list li.next { box-shadow: inset 0 0 0 2px var(--gold); background: var(--gold-soft); }
.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--green-900);
  background: var(--gold);
}
.tag.now { color: #fff; background: var(--green-700); }

.times-note { margin: 12px 4px 0; font-size: 0.8rem; color: var(--muted); }

/* Jumu'ah ------------------------------------------------------------------------------------- */

.jumuah-card { display: flex; gap: 16px; align-items: center; }
.jumuah-card p { margin: 6px 0 0; color: var(--muted); }
.jumuah-card p strong { color: var(--text); }
.jumuah-icon {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--green-50);
  color: var(--green-700);
}
.jumuah-icon svg { width: 28px; height: 28px; fill: currentColor; }

/* Footer ---------------------------------------------------------------------------------------- */

.footer {
  max-width: 520px;
  margin: 0 auto;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .badge.live .badge-dot,
  .btn-listen.is-live { animation: none; }
}

/* Notices: rotating bar at the top of the header ------------------------------------------- */

.notice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: -12px auto 18px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--green-900);
  background: var(--gold-soft);
  border: 1px solid rgba(214, 169, 47, 0.6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  text-align: start;
}
.notice-icon { flex: none; width: 20px; height: 20px; fill: var(--gold-deep); }
.notice-window { flex: 1; min-width: 0; overflow: hidden; }
.notice-text {
  display: inline-block;
  white-space: nowrap;
  font-weight: 600;
  line-height: 1.5;
  transition: opacity 0.35s ease;
  will-change: transform;
}
.notice-text.is-hidden { opacity: 0; }
.notice-count { flex: none; font-size: 0.75rem; font-weight: 700; color: var(--gold-deep); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notice-bar { color: #f7edd2; }
}
:root[data-theme="dark"] .notice-bar { color: #f7edd2; }

/* No sideways movement: long notices wrap instead. */
@media (prefers-reduced-motion: reduce) {
  .notice-bar { border-radius: 18px; }
  .notice-text { white-space: normal; transition: none; }
}

.board-empty { margin: 12px 0 0; color: var(--muted); }

/* Upcoming Events ----------------------------------------------------------------------------- */

.events-list { display: grid; gap: 14px; margin-top: 12px; }
.event-day { display: flex; gap: 14px; align-items: flex-start; }
.event-tile {
  flex: none;
  width: 56px;
  padding: 6px 0;
  border-radius: 14px;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, var(--green-600), var(--green-800));
  display: grid;
  line-height: 1.1;
}
.event-tile-day { font-size: 1.5rem; font-weight: 800; }
.event-tile-month { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-soft); }
.event-body { flex: 1; min-width: 0; }
.event-heading { margin: 2px 0 6px; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.event-heading .tag { margin-left: 0; }
.event-body ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.event-body li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--green-50);
  line-height: 1.45;
}
.event-time { flex: none; font-weight: 700; color: var(--green-700); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-text { overflow-wrap: anywhere; white-space: pre-line; }
