@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Amiri:wght@400;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* AL-DALEEL — qibla3 shell.
   The instrument itself is drawn entirely with inline styles by qibla3.js, exactly as
   the artboard does. This file only carries the page chrome around it: the navy field,
   the hijri title line, the two round stage buttons, the legend, the annunciator, the
   readout and the place controls. Everything is scoped under #view-qibla so the
   instrument keeps its navy-and-cobalt identity on every app theme. */

/* The instrument is the hero — let it out of main's 560px column. The width is set
   in px by qibla3.js from documentElement.clientWidth (NOT 100vw, which counts the
   scrollbar and would push a horizontal scrollbar onto the page). */
#view-qibla { animation: none; overflow-x: clip; }

/* Rotating layers are full-size (inset:0) squares, so their axis-aligned bounding
   box is the stage DIAGONAL (880 * 1.414). Nothing of the dial is outside the
   circle, so clip the overflow horizontally — clip, not hidden, so the plate's
   drop shadow still bleeds down the page. */
#view-qibla .q3-panel { overflow-x: clip; }

/* The qibla view owns the whole screen: the app's global top bar is hidden here
   and the round back button on the stage takes over. */
body:has(#view-qibla.view.active) .topbar { display: none; }

#view-qibla .q3-panel {
  --q3-navy: #303090;
  --q3-cobalt: #0070e0;
  --q3-turq: #20c0f0;
  --q3-sky: #b0e0ff;
  --q3-red: #ff0000;
  --q3-ink: #eaf6ff;
  --q3-serif: "Cinzel", Georgia, "Times New Roman", serif;
  --q3-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  min-height: 100vh;
  background: radial-gradient(120% 90% at 50% 4%, #2a2f8c 0%, #171a5e 44%, #080a2c 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 18px 8px 60px;
  font-family: var(--q3-serif);
  color: var(--q3-ink);
  box-sizing: border-box;
}

/* ── title line: the hijri date, nothing else ── */
#view-qibla .q3-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.35;
}
#view-qibla .q3-hijri {
  font-size: 22px;
  letter-spacing: 0.22em;
  font-weight: 700;
  text-indent: 0.22em;
  white-space: nowrap;
  color: #ffffff;
}

/* ── the stage ── */
#view-qibla .q3-stagewrap { position: relative; flex-shrink: 0; }
#view-qibla .q3-stage {
  position: absolute;
  left: 0; top: 0;
  width: 880px; height: 880px;
  transform-origin: 0 0;
  touch-action: none;
  cursor: grab;
}
#view-qibla .q3-stage.dragging { cursor: grabbing; }

/* ── the two round buttons: back top-left, replay top-right ── */
#view-qibla .q3-rnd {
  position: absolute;
  top: 2px;
  z-index: 5;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle at 34% 26%, #ffffff 0%, #eaf5ff 52%, #cfe4ff 100%);
  box-shadow: 0 3px 10px rgba(4, 8, 40, 0.5), inset 0 0 0 2px var(--q3-navy);
}
#view-qibla .q3-back { left: 2px; }
#view-qibla .q3-replay { right: 2px; }
#view-qibla .q3-replay.running {
  background: radial-gradient(circle at 34% 26%, #ffffff 0%, #d6f2ff 52%, #9fdcff 100%);
  box-shadow: 0 0 0 3px var(--q3-turq), 0 3px 12px rgba(4, 8, 40, 0.5);
  animation: q3IconSpin 1s linear infinite;
}

@keyframes q3IconSpin { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes q3GlowPulse { 0%, 100% { filter: none; } 50% { filter: drop-shadow(0 0 9px rgba(255, 0, 0, 0.95)); } }
@keyframes q3SoftPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  #view-qibla .q3-replay.running { animation: none; }
}

/* ── legend ── */
#view-qibla .q3-legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 18px;
  width: min(880px, 100%);
  padding: 12px 16px;
  box-sizing: border-box;
  background: rgba(16, 20, 80, 0.7);
  border: 1px solid rgba(127, 212, 255, 0.35);
  border-radius: 3px;
}
#view-qibla .q3-lg { display: flex; align-items: center; gap: 9px; }
#view-qibla .q3-lg span {
  font-family: var(--q3-mono);
  font-size: 13px; letter-spacing: 0.08em; color: #c9e4ff;
}

/* ── annunciator ── */
#view-qibla .q3-ann {
  display: flex; flex-direction: column; gap: 10px;
  width: min(880px, 100%);
  box-sizing: border-box;
}
#view-qibla .q3-ann-main {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 14px 26px; border-radius: 4px;
  background: radial-gradient(circle at 30% 12%, #ffffff 0%, #f2faff 52%, #dceeff 100%);
  box-shadow: 0 10px 26px rgba(4, 8, 40, 0.5), inset 0 0 0 3px var(--q3-navy);
}
#view-qibla .q3-lamp { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
#view-qibla .q3-ann-word {
  min-width: 230px; text-align: center;
  font-size: 27px; font-weight: 700; letter-spacing: 0.16em;
  color: var(--q3-navy); line-height: 1;
}
#view-qibla .q3-ann-delta {
  font-family: var(--q3-mono);
  font-size: 13px; letter-spacing: 0.14em; color: var(--q3-cobalt);
}
#view-qibla .q3-chips3 { display: flex; gap: 10px; }
#view-qibla .q3-chip3 {
  flex: 1; padding: 11px 16px; border-radius: 3px; text-align: center;
  background: rgba(16, 20, 80, 0.8);
  border: 1px solid rgba(127, 212, 255, 0.45);
}
#view-qibla .q3-chip3 .k {
  font-family: var(--q3-mono); font-size: 13px; letter-spacing: 0.16em; color: #7fd4ff;
}
#view-qibla .q3-chip3 .v { font-size: 18px; color: #ffffff; letter-spacing: 0.06em; }

/* ── readout ── */
#view-qibla .q3-readout {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(127, 212, 255, 0.4);
  border: 1px solid rgba(127, 212, 255, 0.5);
  width: min(880px, 100%);
  box-sizing: border-box;
}
#view-qibla .q3-cell {
  background: #171a5e; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 5px;
}
#view-qibla .q3-cell .k {
  font-family: var(--q3-mono); font-size: 13px; letter-spacing: 0.14em; color: #7fd4ff;
}
#view-qibla .q3-cell .v { font-size: 20px; color: #ffffff; }

/* ── controls ── */
#view-qibla .q3-controls {
  display: flex; flex-direction: column; gap: 12px;
  width: min(880px, 100%);
  box-sizing: border-box;
  padding: 18px 20px;
  border: 1px solid rgba(127, 212, 255, 0.35);
  background: rgba(16, 20, 80, 0.7);
}
#view-qibla .q3-ctl-label {
  font-family: var(--q3-mono); font-size: 13px; letter-spacing: 0.14em; color: #7fd4ff;
}
#view-qibla .q3-places { display: flex; flex-wrap: wrap; gap: 8px; }
#view-qibla .q3-place {
  padding: 8px 14px; border-radius: 3px; cursor: pointer; white-space: nowrap;
  font-family: var(--q3-serif); font-size: 13px; letter-spacing: 0.08em;
  border: 1px solid rgba(127, 212, 255, 0.45);
  background: rgba(16, 20, 80, 0.8);
  color: #9fd6ff;
}
#view-qibla .q3-place.on {
  border-color: #ffffff;
  background: linear-gradient(178deg, #ffffff, #cfe4ff);
  color: var(--q3-navy);
}
#view-qibla .q3-live {
  align-self: flex-start;
  padding: 10px 18px; border-radius: 3px; cursor: pointer;
  font-family: var(--q3-serif); font-size: 13px; letter-spacing: 0.1em; font-weight: 700;
  border: 1px solid #ffffff;
  background: linear-gradient(178deg, #ff5a52, #b00d12);
  color: #ffffff;
}
#view-qibla .q3-live.on { background: linear-gradient(178deg, #20c0f0, #0070e0); }
#view-qibla .q3-fine {
  margin: 0;
  font-family: var(--q3-serif); font-size: 13px; line-height: 1.6; color: #9fd6ff;
}

@media (max-width: 620px) {
  #view-qibla .q3-hijri { font-size: 17px; letter-spacing: 0.16em; }
  #view-qibla .q3-panel { gap: 16px; }
  #view-qibla .q3-ann-main { padding: 12px 14px; gap: 12px; }
  #view-qibla .q3-ann-word { min-width: 0; font-size: 20px; letter-spacing: 0.1em; }
  #view-qibla .q3-legend { gap: 12px; }
  #view-qibla .q3-readout { grid-template-columns: 1fr 1fr; }
  #view-qibla .q3-chip3 { padding: 9px 8px; }
  #view-qibla .q3-chip3 .v { font-size: 15px; }
  #view-qibla .q3-chip3 .k { font-size: 11px; letter-spacing: 0.12em; }
}

/* live-sensor readout under the live button: source · event count · raw heading.
   Field-test diagnostic (v21) — tells us in one glance whether events are arriving. */
#view-qibla .q3-sensor { margin-top: 6px; font-size: .68rem; letter-spacing: .04em; color: rgba(255,255,255,.72); text-align: center; min-height: 1em; font-variant-numeric: tabular-nums; }

/* location bar (v22): the qibla is for a place — say which, fix in one tap */
#view-qibla .q3-loc { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 12px;
  padding: 11px 14px; border-radius: 3px; border: 1px solid #ffffff; cursor: pointer; text-align: left;
  background: linear-gradient(178deg, #ff5a52, #b00d12); color: #ffffff;
  font-family: var(--q3-serif); font-size: 12.5px; letter-spacing: .06em; font-weight: 700; }
#view-qibla .q3-loc.on { background: linear-gradient(178deg, #20c0f0, #0070e0); }
#view-qibla .q3-loc-pin { font-size: 16px; line-height: 1; }
#view-qibla .q3-loc-text { flex: 1; min-width: 0; white-space: normal; line-height: 1.35; }
