/* أمطار كل النماذج — dark glass theme, RTL-first */

:root {
  --bg0: #070c16;
  --bg1: #0b1322;
  --card: rgba(18, 26, 44, .82);
  --edge: #223252;
  --edge-soft: rgba(56, 96, 168, .25);
  --ink: #e9effb;
  --dim: #8fa2c6;
  --accent: #38bdf8;
  --accent2: #2563eb;
  --gold: #f5c15c;
  --gold2: #b45309;
  --ok: #34d399;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scrollbar-color: #2a3a5e var(--bg0); }

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(37, 99, 235, .22), transparent 60%),
    radial-gradient(900px 420px at 5% 110%, rgba(56, 189, 248, .10), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 380px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px 40px;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.wrap { width: 100%; max-width: 1120px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 4px 14px; flex-wrap: wrap;
}
.top h1 { font-size: 21px; letter-spacing: -.3px; }
.top .sub { display: block; color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.top .actions { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 99px; padding: 7px 14px; font-size: 13px; border: 1px solid var(--edge);
  background: var(--card); color: var(--ink);
}
.pill.pro { border-color: rgba(52, 211, 153, .4); color: var(--ok); }
.pill.home { padding: 7px 11px; }

/* ---------- model chips ---------- */
.models {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: thin; scroll-snap-type: x proximity;
}
.mchip {
  flex: 0 0 auto; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 9px 12px 7px;
  background: var(--card); border: 1px solid var(--edge); border-radius: 14px;
  color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.mchip:hover { border-color: var(--edge-soft); transform: translateY(-1px); }
.mchip.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 22px rgba(56, 189, 248, .18);
}
.mchip .f { font-size: 17px; line-height: 1; }
.mchip .a { font-size: 12.5px; font-weight: 700; direction: ltr; }
.mchip .n { font-size: 10px; color: var(--dim); max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mchip .n.ai { color: var(--gold); }
.mchip .stale { font-size: 9.5px; color: #f87171; }

/* ---------- controls row ---------- */
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 2px 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--edge); border-radius: 12px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--dim);
  padding: 8px 18px; border-radius: 9px; font-size: 14px;
}
.seg button.on { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; font-weight: 700; }
.ghostbtn {
  background: var(--card); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 12px; padding: 9px 16px; font-size: 13.5px;
}
.ghostbtn.on { border-color: var(--accent); color: var(--accent); }

/* ---------- stage ---------- */
.stage { background: var(--card); border: 1px solid var(--edge); border-radius: var(--radius); padding: 10px; backdrop-filter: blur(6px); }
.frameWrap {
  position: relative; width: 100%; aspect-ratio: 1582 / 1104;
  border-radius: 10px; overflow: hidden; background: #39424e;
}
.frame, .cities {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
/* No transition: the time step must land instantly. The two stacked <img>
   elements still double-buffer — the incoming frame is fully decoded before it
   is shown — so the swap is one repaint with no fade and no blank flash. */
.frame { opacity: 0; }
.frame.show { opacity: 1; }
.cities { z-index: 3; pointer-events: none; }

.chip {
  position: absolute; z-index: 4; font-size: 11.5px;
  background: rgba(7, 12, 22, .72); color: #fff; border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px; padding: 4px 10px; backdrop-filter: blur(4px);
}
.runChip { top: 8px; right: 8px; }
.timeChip { top: 8px; left: 8px; direction: ltr; font-variant-numeric: tabular-nums; }
.timeChip b { color: var(--accent); }

/* lock panel over the stage */
.lockPanel {
  position: absolute; inset: 0; z-index: 5; display: none;
  align-items: center; justify-content: center; text-align: center;
}
.lockPanel.show { display: flex; }
.lockPanel .blur {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(14px) brightness(.45) saturate(1.1); transform: scale(1.1);
}
.lockPanel .inner {
  position: relative; max-width: 430px; padding: 26px 22px;
  background: rgba(10, 15, 28, .78); border: 1px solid rgba(245, 193, 92, .35);
  border-radius: 18px; backdrop-filter: blur(6px); margin: 0 14px;
}
.lockPanel .lock { font-size: 34px; }
.lockPanel h3 { font-size: 18px; margin: 8px 0 6px; }
.lockPanel p { color: var(--dim); font-size: 13.5px; line-height: 1.9; }
.lockPanel .cta {
  display: block; margin-top: 12px; border: 0; border-radius: 12px;
  padding: 12px; font-size: 15px; font-weight: 700; width: 100%;
  background: linear-gradient(135deg, var(--gold2), var(--gold)); color: #1c1000;
}

.legend { display: block; width: 100%; max-width: 655px; margin: 10px auto 0; border-radius: 8px; }

/* ---------- timeline ---------- */
.timeline {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 12px;
}
.tbtn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--edge); background: rgba(56, 189, 248, .08); color: var(--ink);
  font-size: 15px; display: grid; place-items: center;
}
.tbtn:hover { border-color: var(--accent); }
.tbtn.speed { font-size: 12.5px; font-weight: 700; width: 46px; border-radius: 12px; }
.sliderCol { flex: 1 1 auto; min-width: 0; }
.hourRow { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.hourRow .cur { color: var(--ink); font-size: 14px; font-weight: 700; }
.hourRow .cur .lockmark { color: var(--gold); }

.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: 99px; outline: 0; background: #22304f; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5); cursor: grab;
}
.slider.locked::-webkit-slider-thumb { border-color: var(--gold); }
.slider::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  border: 3px solid var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .5); cursor: grab;
}
.slider.locked::-moz-range-thumb { border-color: var(--gold); }

/* ---------- compare grid ---------- */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 10px; }
.ccard {
  background: var(--card); border: 1px solid var(--edge); border-radius: 14px;
  overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s;
}
.ccard:hover { border-color: var(--accent); transform: translateY(-2px); }
.ccard .chead {
  display: flex; align-items: center; gap: 7px; padding: 8px 11px; font-size: 12.5px;
}
.ccard .chead .a { font-weight: 700; direction: ltr; }
.ccard .chead .n { color: var(--dim); font-size: 10.5px; margin-inline-start: auto; }
.ccard .cwrap { position: relative; aspect-ratio: 1582 / 1104; background: #39424e; }
.ccard .cwrap img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ccard .miss, .ccard .mlock {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--dim); background: rgba(7, 12, 22, .55); text-align: center;
}
.ccard .mlock { color: var(--gold); font-size: 22px; }

.cbanner {
  display: none; margin: 0 0 10px; padding: 13px 16px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(180, 83, 9, .25), rgba(245, 193, 92, .12));
  border: 1px solid rgba(245, 193, 92, .4); font-size: 13.5px; text-align: center;
}
.cbanner.show { display: block; }
.cbanner a { color: var(--gold); font-weight: 700; }

/* ---------- toast + footer ---------- */
.toast {
  position: fixed; bottom: 18px; inset-inline: 0; margin: auto; width: fit-content; max-width: 90%;
  background: rgba(10, 15, 28, .92); border: 1px solid var(--edge); color: var(--ink);
  border-radius: 12px; padding: 11px 18px; font-size: 13px; z-index: 50;
  opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

.foot { margin-top: 26px; color: var(--dim); font-size: 12px; text-align: center; line-height: 2; }

/* No backdrop by default. This layer appears on EVERY time step while the next
   frame decodes, so tinting it darkened the map for an instant and read as a
   flash. The spinner alone sits over the live map now. */
.loading {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  color: var(--dim); font-size: 13px; background: none;
}
/* Terminal states only — a text message with no map under it. Here the scrim
   is what keeps the text readable: measured 3.95:1 on the bare wrap against
   6.04:1 with it. */
.loading.msg {
  background: rgba(7, 12, 22, .55); color: var(--ink); padding: 0 18px;
  text-align: center; line-height: 1.7;
}
.spin {
  width: 30px; height: 30px; border: 3px solid var(--edge); border-top-color: var(--accent);
  border-radius: 50%; animation: sp 1s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .top h1 { font-size: 18px; }
  .seg button { padding: 8px 13px; font-size: 13px; }
  .timeline { padding: 10px; gap: 8px; }
  .tbtn { width: 38px; height: 38px; }
}
