/* ساعة فطومي | Fattomi Sa'a */

:root {
  /* ---------------------------------------------------------------------
     Approved title gradient (Option B) — MAIN TITLE ONLY, never buttons.
     --------------------------------------------------------------------- */
  --title-gradient: linear-gradient(
    95deg,
    #ff6198 0%,
    #fc433e 16%,
    #fd702a 30%,
    #f0a500 44%,
    #e3b800 53%,
    #13bd64 70%,
    #03acad 82%,
    #3690fa 100%
  );
  --brand-blue-gradient: linear-gradient(90deg, #2f6fdd 0%, #3f8cff 45%, #67b7ff 100%);

  /* Blue palette, keyed to the pale-blue clock artwork. */
  --blue-900: #10406f;
  --blue-700: #1b5fa8;
  --blue-600: #2f80d6;
  --blue-400: #6ba8e0;
  --blue-050: #f2f8fe;
  --blue-line: #6aa7ea;

  /* The sky-blue base — same hue as before, now covering the whole page. */
  --sky: #e3f0fb;

  --ink: #17324d;
  --card: #ffffff;
  --lcd-blue: #5c9ce4;
  --shadow: 0 2px 8px rgba(21, 71, 122, 0.1);

  /* Bold geometric Arabic display face, used for the title only. */
  --font-display: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  /* Naskh/serif face, used for the elapsed box only. */
  --font-naskh: 'Noto Naskh Arabic', 'Amiri', 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  /* Same sky-blue family, distributed as a soft wash instead of flat blocks. */
  background: linear-gradient(180deg, #e8f4fd 0%, #eef8ff 38%, #dceffc 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.4;
}
body[data-lang="ar"], body[data-lang="fa"] {
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Times New Roman", serif;
}

/* --------------------------------- topbar --------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px clamp(12px, 3vw, 30px);
  border-bottom: 1px solid var(--blue-line);
  background: rgba(255, 255, 255, 0.82);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.brand-mark {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--blue-700);
  font-family: "Segoe UI", system-ui, sans-serif; /* brand stays Latin */
  font-size: clamp(15px, 1.5vw, 19px);
}

.topbar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lang-buttons { display: flex; gap: 6px; }

/* Blue pill buttons — no gradient anywhere here. */
.btn-blue, .lang-btn {
  font: inherit;
  font-weight: 700;
  font-size: clamp(12.5px, 1.1vw, 15px);
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  background: #fff;
  color: var(--blue-700);
  border: 1.5px solid var(--blue-line);
  box-shadow: var(--shadow);
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.btn-blue:hover, .lang-btn:hover { transform: translateY(-1px); border-color: var(--blue-400); }

.lang-btn.is-active,
.btn-blue.is-on {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}

/* ---------------------------------- page ---------------------------------- */

.page {
  max-width: 1560px;
  margin: 0 auto;
  padding: clamp(6px, 1vw, 12px) clamp(10px, 2.4vw, 28px) 14px;
}

/* --------------------------------- layout ---------------------------------
   Column 1 is the inline-start side: the RIGHT in Arabic/Persian. The title
   sits in column 2, so it is shifted left and the side panel can begin at the
   very top of the page beside it.
   -------------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(270px, 350px) minmax(0, 1fr);
  gap: clamp(10px, 1.4vw, 20px);
  align-items: start;
}

.side { display: flex; flex-direction: column; gap: clamp(6px, 0.8vw, 10px); }

.main-col {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 0.6vw, 8px);
  justify-self: start;
  width: 100%;
  max-width: clamp(600px, 58vw, 940px);
}

/* ------------------------- the approved title style ------------------------ */

.titles { text-align: center; margin: 0; }

.brand-title {
  /* Bold geometric Arabic display face. Size and colours are unchanged. */
  font-family: var(--font-display);
  font-size: clamp(23px, 3.3vw, 44px);
  font-weight: 900;
  line-height: 1.14;
  margin: 0;
}

.title-rest,
.title-brand-blue {
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  paint-order: stroke fill;
  -webkit-text-stroke: 1.1px rgba(18, 28, 58, 0.3);
}
.title-rest { background-image: var(--title-gradient); }
.title-brand-blue { background-image: var(--brand-blue-gradient); }

.tagline {
  color: var(--blue-700);
  margin: 2px auto 0;
  max-width: 68ch;
  font-size: clamp(12px, 1.1vw, 14.5px);
  opacity: 0.85;
}

/* --------------------------------- date card ------------------------------- */

.date-card {
  background: var(--card);
  border: 3px solid var(--blue-line);
  border-radius: 20px;
  padding: clamp(7px, 0.9vw, 12px) 14px;
  text-align: center;
}

/* Hijri leads: on top, larger, bolder. */
.date-card .hijri-line {
  font-size: clamp(16px, 1.6vw, 23px);
  font-weight: 800;
  color: #173f83;
  margin-bottom: 2px;
}
.date-card .hijri-line.is-unavailable {
  font-weight: 600;
  opacity: 0.75;
  font-size: clamp(13px, 1.2vw, 17px);
}

/* Gregorian is secondary: below, smaller. */
.date-card .greg-line {
  font-size: clamp(12.5px, 1.15vw, 16px);
  font-weight: 600;
  color: #3c5f93;
  opacity: 0.92;
}

/* ----------------------------- location controls --------------------------- */

.location-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  background: var(--card);
  border: 3px solid var(--blue-line);
  border-radius: 20px;
  padding: clamp(7px, 0.9vw, 12px) 13px;
}

.field { display: flex; flex-direction: column; gap: 3px; }

.field-label {
  font-size: clamp(13px, 1.25vw, 17px);
  font-weight: 800;
  color: #1f56a6;
}

select {
  font: inherit;
  font-size: clamp(13.5px, 1.25vw, 17px);
  font-weight: 700;
  color: var(--blue-900);
  padding: 6px 9px;
  border-radius: 10px;
  border: 1.5px solid var(--blue-line);
  background: var(--blue-050);
  cursor: pointer;
}
select:focus { outline: 2px solid var(--blue-400); outline-offset: 1px; }

/* ------------------------------- prayer times ------------------------------ */

.prayer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.6vw, 8px);
}

.prayer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: clamp(6px, 0.8vw, 11px) 16px;
  border-radius: 18px;
  background: var(--card);
  border: 3px solid var(--blue-line);
}
/* Imsak leads the list during Ramadan and is tinted to stand apart. */
.prayer-row.is-imsak { background: var(--blue-050); }

.prayer-name {
  font-weight: 800;
  color: #2b69c8;
  font-size: clamp(14px, 1.4vw, 20px);
}
.prayer-time {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  color: #123e80;
  font-size: clamp(16px, 1.65vw, 24px);
  direction: ltr;
}

/* ------------------------- the two equal status boxes ---------------------- */

.status-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1vw, 16px);
  align-items: stretch;
}

/* Both boxes are identical: same border, radius, background and height. */
.status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: clamp(74px, 8.4vw, 112px);
  background: var(--card);
  border: 3px solid var(--blue-line);
  border-radius: 22px;
  padding: clamp(6px, 0.8vw, 12px) 14px;
  text-align: center;
}
.status-card[hidden] { display: none; }

.status-label {
  color: var(--blue-700);
  font-weight: 800;
  font-size: clamp(13px, 1.35vw, 20px);
  line-height: 1.15;
}

/* Elapsed box: words, no seconds. Naskh/serif, a step larger than before. */
#elapsed-box .status-label {
  font-family: var(--font-naskh);
  font-size: clamp(17px, 1.95vw, 30px);
  font-weight: 700;
  line-height: 1.2;
}

.status-value-text {
  font-family: var(--font-naskh);
  color: #124b90;
  font-weight: 800;
  font-size: clamp(16px, 1.9vw, 28px);
  line-height: 1.15;
}

/* Countdown box: the live timer. */
.status-value-time {
  color: #124b90;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  font-family: "Segoe UI", Consolas, "DejaVu Sans Mono", monospace;
  font-size: clamp(24px, 3vw, 46px);
  letter-spacing: 0.03em;
  direction: ltr;
  line-height: 1;
}

.notice {
  background: #fff4f4;
  border: 1.5px solid #f3c9c9;
  color: #9b2c2c;
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0;
  font-weight: 700;
  text-align: center;
  font-size: 13.5px;
}

.retry-btn {
  font: inherit;
  font-weight: 700;
  border: 1.5px solid var(--blue-line);
  color: var(--blue-700);
  background: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  align-self: center;
}

/* --------------------------------- clocks --------------------------------- */

/* The clocks sit directly under the status row — the removed helper line's
   space is reclaimed here — on a soft sky-blue field that fades outward so
   there is no hard white/blue edge behind the artwork. */
.clocks {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: clamp(8px, 1.3vw, 22px);
  align-items: center;
  margin: 0;
  padding: clamp(4px, 0.7vw, 10px) clamp(6px, 1vw, 16px);
  border-radius: 32px;
  background:
    radial-gradient(
      ellipse at 50% 45%,
      rgba(255, 255, 255, 0.85) 0%,
      rgba(238, 248, 255, 0.6) 42%,
      rgba(220, 239, 252, 0.35) 72%,
      rgba(220, 239, 252, 0) 100%
    );
}

.clock-card { margin: 0; display: flex; justify-content: center; }

.analog-wrap, .digital-wrap { position: relative; container-type: inline-size; }
.digital-wrap { width: clamp(230px, 29vw, 500px); }
.analog-wrap { width: clamp(200px, 25vw, 430px); }

/* The derived PNGs carry their own white ground. Multiply blends that white
   into the sky-blue field so no hard white rectangle shows — a purely visual
   CSS effect; the image files are untouched. */
.clock-art {
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;
}

/* ------------------------------ analog overlay ----------------------------- */

.analog-hands {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.analog-hands .hand,
.analog-hands .second-pulse {
  transform-box: view-box;
  transform-origin: 50% 50%;
}

.analog-hands .hand-label {
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
  paint-order: stroke fill;
  pointer-events: none;
}

@container (max-width: 320px) {
  .analog-hands .hand-label { display: none; }
}

/* ------------------------------ digital overlay ---------------------------- */

/* Measured from the artwork: the LCD panel occupies 12.00%–76.19% horizontally
   and 42.93%–81.01% vertically of the derived image, tilted ~1.2°. */
.digital-time {
  position: absolute;
  left: 12%;
  right: 23.81%;
  top: 42.93%;
  bottom: 18.99%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(1.2deg);
  color: var(--lcd-blue);
  font-family: "Segoe UI", Consolas, "DejaVu Sans Mono", monospace;
  font-weight: 700;
  font-size: 13.6cqw;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  white-space: nowrap;
  line-height: 1;
}

/* Audio elements are required by their APIs but are not visual.
   Clipped in place rather than pushed off-screen: a negative offset would
   extend the scrollable area in an RTL document. */
.offscreen-audio {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  pointer-events: none;
  overflow: hidden;
  clip-path: inset(50%);
}

/* -------------------------------- responsive ------------------------------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .main-col { max-width: none; }
  .clocks { grid-template-columns: 1fr; justify-items: center; }
  .digital-wrap { width: clamp(230px, 44vw, 420px); }
  .analog-wrap { width: clamp(200px, 38vw, 360px); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .main-col { justify-self: stretch; }
  .status-row { grid-template-columns: 1fr; }
  .clocks { justify-content: center; }
  .digital-wrap, .analog-wrap { width: min(420px, 88vw); }
}

@media (max-width: 420px) {
  .location-card { grid-template-columns: 1fr; }
}
