/* The hidden attribute must always win over component display rules (e.g. .retry-button). */
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: dark;
  --glass: rgba(0, 0, 0, 0.25);
  --line: rgba(255, 255, 255, 0.16);
  --muted: rgba(255, 255, 255, 0.68);
  --pink: #ffd6ea;
  --blue: #c8e6ff;
  --gold: #ffe066;
}

html {
  background: #1a0a2e; /* fallback */
}

body {
  position: relative;
  isolation: isolate;          /* keeps the layers inside body */
  min-height: 100vh;
  font-family: 'Poppins', sans-serif;
  color: #fff;
  background: none;            /* gradient lives in its own layer */
  overflow-x: clip;
  padding-bottom: 3rem;
}

/* LAYER 1 - pink/purple gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(135deg, #1a0a2e 0%, #6b1040 30%, #c02060 60%, #e8407a 80%, #d03070 100%);
}

/* LAYER 2 - islamic lines: ONE big centered image (no repeating tiles) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url('/assets/images/bg-pattern-desktop.png?v=4') center center / cover no-repeat;
  opacity: .05;                /* lower = more transparent */
}
@media (max-width: 760px) {
  body::after {
    background-image: url('/assets/images/bg-pattern-mobile.png?v=4');
  }
}

/* LAYER 3 - website content */
body > * {
  position: relative;
  z-index: 1;
}

header { text-align: center; padding: 2.5rem 1rem 1.2rem; }
.arabic-sub, footer .arabic { font-family: 'Amiri', serif; color: rgba(255,255,255,.72); }
.arabic-sub { font-size: 1.3rem; letter-spacing: .08em; }
h1 { font-size: clamp(2.15rem, 8vw, 3rem); font-weight: 900; font-style: italic; line-height: 1; text-shadow: 0 2px 20px rgba(0,0,0,.3); }
.header-sub { margin-top: .45rem; font-size: .85rem; color: var(--muted); letter-spacing: .08em; text-transform: capitalize; }

.page-shell { width: min(960px, 100%); margin: 0 auto; padding: 0 1rem; }
.countdown-wrap { max-width: 640px; margin: .8rem auto 0; }
.countdown-card, .panel {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.countdown-card { border-radius: 20px; padding: 1.35rem 2rem; text-align: center; min-height: 156px; }
.countdown-label { min-height: 1.2em; font-size: .78rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.countdown-label em { color: var(--pink); font-style: normal; }
.countdown-time { margin-top: .45rem; color: #4dff91; font-size: clamp(2.4rem, 10vw, 3.8rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 0 28px rgba(77,255,145,.5); }
.countdown-desc { min-height: 1.2em; margin-top: .55rem; font-size: .78rem; color: var(--muted); }
.state-dot { display: inline-block; width: 8px; height: 8px; margin-right: .4rem; border-radius: 50%; background: #4dff91; box-shadow: 0 0 7px #4dff91; animation: blink 1.2s ease-in-out infinite; }

.controls-wrap { display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap; margin: 1.5rem 0 1rem; }
.location-control { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.control-label { display: flex; align-items: center; gap: .4rem; font-size: .84rem; font-weight: 600; }
.city-select {
  min-width: 190px;
  padding: .58rem 2.5rem .58rem 1.2rem;
  color: #fff;
  font: 600 .9rem 'Poppins', sans-serif;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 30px;
  outline: none;
  appearance: none;
  cursor: pointer;
  background-color: rgba(0,0,0,.3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}
.city-select:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.city-select:disabled { opacity: .55; cursor: wait; }
.city-select option { background: #6b1040; }
.selected-city-pill { padding: .38rem .9rem; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.14); color: var(--pink); font-size: .78rem; font-weight: 700; }

.status-message { margin: .75rem auto; padding: .7rem 1rem; max-width: 700px; border-radius: 12px; text-align: center; font-size: .82rem; }
.status-message[hidden] { display: none; }
.status-loading { background: rgba(255,255,255,.12); }
.status-warning { background: rgba(255,215,0,.14); border: 1px solid rgba(255,215,0,.3); }
.status-error { background: rgba(100,0,20,.38); border: 1px solid rgba(255,130,150,.45); }
.retry-button { display: block; margin: .6rem auto 1.2rem; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 20px; background: rgba(0,0,0,.22); color: #fff; cursor: pointer; font: 600 .8rem 'Poppins', sans-serif; }

.prayer-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .65rem; min-height: 135px; }
.prayer-card {
  min-width: 0;
  padding: 1rem .5rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(20, 0, 15, .32);              /* dark tint = readable text */
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);     /* the frosted glass blur */
  box-shadow: 0 6px 20px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform .2s, background .2s, border-color .2s;
}
.prayer-card.next-prayer {
  transform: translateY(-4px);
  background: rgba(255,255,255,.22);
  border-color: rgba(255,214,234,.8);
  box-shadow: 0 10px 28px rgba(40,0,25,.35), inset 0 1px 0 rgba(255,255,255,.3);
}
.prayer-name { min-height: 2.5em; display: grid; place-items: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; color: rgba(255,255,255,.85); }
.prayer-detail { display: block; min-height: 1.5em; margin-top: .2rem; font-size: .62rem; color: rgba(255,255,255,.65); }
.prayer-time { display: block; margin-top: .65rem; font-size: clamp(1.15rem, 3vw, 1.65rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.source-attribution, .mapping-note { text-align: center; color: rgba(255,255,255,.62); font-size: .72rem; line-height: 1.55; }
.source-attribution { min-height: 1.5em; margin: .9rem auto .25rem; }
.mapping-note { color: rgba(255,255,255,.48); }

.section-title { margin: 2.3rem 0 .4rem; text-align: center; font-size: 1.35rem; }
.section-copy { margin: 0 auto 1rem; max-width: 720px; text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.history-details { border-radius: 18px; overflow: hidden; }
.history-details > summary { padding: 1rem 1.2rem; cursor: pointer; font-weight: 700; list-style-position: inside; }
.table-wrap { overflow-x: auto; padding: 0 .7rem 1rem; }
table { width: 100%; min-width: 650px; border-collapse: separate; border-spacing: 0 5px; }
th { padding: .7rem .45rem; background: rgba(0,0,0,.42); font-size: .75rem; }
th:first-child { border-radius: 12px 0 0 12px; text-align: left; }
th:last-child { border-radius: 0 12px 12px 0; }
.month-row td { padding: .8rem .4rem .2rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .18em; }
.data-row td { padding: .48rem .38rem; background: rgba(255,255,255,.07); text-align: center; font-size: .82rem; }
.data-row td:first-child { padding-left: .8rem; border-radius: 12px 0 0 12px; text-align: left; font-weight: 600; }
.data-row td:last-child { border-radius: 0 12px 12px 0; }
.day-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.25); font-weight: 700; }
.pill { display: inline-block; min-width: 58px; padding: .22rem .45rem; border-radius: 9px; font-weight: 700; }
.pill-imsak { color: var(--pink); background: rgba(255,200,230,.17); border: 1px solid rgba(255,200,230,.32); }
.pill-akshami { color: var(--blue); background: rgba(180,220,255,.16); border: 1px solid rgba(180,220,255,.3); }
.qadr-badge { display: inline-block; margin-left: .35rem; padding: .1rem .42rem; border-radius: 10px; color: var(--gold); background: rgba(255,215,0,.14); font-size: .58rem; }

.quran-wrap { margin-top: 2rem; }
.quran-frame { width: 100%; height: 600px; border: 2px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(0,0,0,.2); }
footer { padding: 2.5rem 1rem 1rem; text-align: center; color: rgba(255,255,255,.55); font-size: .73rem; line-height: 1.8; }
footer .arabic { display: block; font-size: 1.4rem; }

@keyframes blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
@media (max-width: 760px) { .prayer-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) {
  header { padding-top: 1.8rem; }
  .controls-wrap { display: grid; grid-template-columns: 1fr; gap: .65rem; }
  .location-control { display: grid; grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr); }
  .city-select { width: 100%; min-width: 0; }
  .selected-city-pill { justify-self: center; text-align: center; }
}
@media (max-width: 420px) {
  .page-shell { padding: 0 .7rem; }
  .countdown-card { padding: 1.2rem .7rem; }
  .prayer-grid { gap: .45rem; }
  .prayer-card { padding: .85rem .28rem; }
  .prayer-name { font-size: .65rem; }
  .prayer-detail { font-size: .58rem; }
}

/* ===== Quran reader (own page, no iframe) ===== */
.quran-reader { border-radius: 18px; padding: 1rem; }
.quran-toolbar { display: flex; align-items: center; justify-content: center; gap: .55rem; flex-wrap: wrap; }
.quran-select { min-width: 0; flex: 1 1 200px; max-width: 320px; }
.quran-edition { flex: 0 1 190px; }
.quran-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.3);
  color: #fff; font: 700 1.5rem/1 'Poppins', sans-serif; cursor: pointer;
}
.quran-btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.quran-btn:disabled { opacity: .35; cursor: default; }
.quran-btn:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.3); outline: none; }
.quran-btn-wide { width: auto; min-width: 120px; padding: 0 1.2rem; border-radius: 30px; font-size: .9rem; }
.quran-toolbar-bottom { margin-top: 1.2rem; }

.quran-body { margin-top: 1rem; }
.quran-surah-head { text-align: center; padding: 1rem 0 .4rem; }
.quran-surah-ar { font-family: 'Amiri', serif; font-size: 2.2rem; line-height: 1.4; }
.quran-surah-meta { margin-top: .2rem; color: var(--muted); font-size: .8rem; }
.quran-bismillah { text-align: center; font-family: 'Amiri', serif; font-size: 1.7rem; line-height: 2; padding: .5rem 0 .8rem; color: var(--pink); }

.quran-ayah {
  position: relative; margin-top: .6rem; padding: .9rem 1rem .9rem 3.2rem;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.2);
}
.quran-ayah-num {
  position: absolute; left: .8rem; top: .9rem; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.14);
  font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.quran-ayah-ar { font-family: 'Amiri', serif; font-size: 1.65rem; line-height: 2.1; text-align: right; }
.quran-ayah-sq { margin-top: .5rem; font-size: .92rem; line-height: 1.7; color: rgba(255,255,255,.88); }
.quran-credit { margin-top: 1rem; text-align: center; font-size: .68rem; color: rgba(255,255,255,.5); }

@media (max-width: 560px) {
  .quran-reader { padding: .7rem; }
  .quran-select { flex: 1 1 100px; }
  .quran-edition { flex: 1 1 100%; max-width: none; }
  .quran-ayah { padding: .8rem .8rem .8rem 2.8rem; }
  .quran-ayah-num { left: .6rem; width: 26px; height: 26px; }
  .quran-ayah-ar { font-size: 1.45rem; }
}
