/* The citizen phone pages (the Hayyak chat, National Digital ID, Hayyak Pay) and the hosted hub:
   AR (RTL) and EN. Each page sets its own --app colour in its page.css.

   Two layouts, switched at 480 px:
   - on a phone the page is the screen: full height, no frame, safe areas respected;
   - wider (a laptop, a projector) it is drawn inside an iPhone on a dark canvas: bezel, Dynamic
     Island, a status bar (.statusbar, hidden on a phone) and a home indicator.
   Directional styles use logical properties, so dir="rtl" mirrors the page. */
:root {
  --app: #14486b;
  --app-press: #0f3a57;
  --app-soft: rgb(20 72 107 / 0.1);
  --app-ring: rgb(20 72 107 / 0.35);
  --hayyak: #8a1538;
  --ink: #111316;
  --ink-2: #4a4f57;
  --ink-3: #7a808a;
  --paper: #ffffff;
  --ground: #f2f2f7;
  --fill: rgb(118 118 128 / 0.12);
  --fill-2: rgb(118 118 128 / 0.2);
  --line: rgb(17 19 22 / 0.1);
  --ok: #12804a;
  --ok-soft: rgb(18 128 74 / 0.12);
  --warn: #a35a00;
  --warn-soft: rgb(163 90 0 / 0.12);
  --stop: #c62828;
  --stop-soft: rgb(198 40 40 / 0.1);
  --neutral: #5b636d;
  --neutral-soft: rgb(91 99 109 / 0.12);
  --badge: #ff3b30;
  --radius-card: 20px;
  --radius-ctl: 14px;
  --shadow-card: 0 0 0 0.5px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px -12px rgb(0 0 0 / 0.14);
  --shadow-float: 0 0 0 0.5px rgb(0 0 0 / 0.08), 0 12px 32px -10px rgb(0 0 0 / 0.28);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 240ms;
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "SF Arabic", "Geeza Pro", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* The space under the last control: the phone's own safe area, or the frame's home indicator. */
  --home: env(safe-area-inset-bottom, 0px);
  /* The framed phone: an iPhone's screen (390 × 844 pt), shorter on a short window. */
  --screen-w: 390px;
  --screen-h: clamp(600px, calc(100vh - 64px), 844px);
  --bezel: 12px;
  --radius-phone: 60px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
html[lang="ar"] body { font-family: var(--font-ar); }

/* ---------- The phone: the screen itself on a phone, an iPhone on wider screens ---------- */
.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--ground);
  overflow: hidden;
  isolation: isolate;
}

.statusbar { display: none; }

@media (min-width: 480px) {
  :root { --home: 22px; }
  html { background: #0a0b0d; }
  body {
    display: grid;
    place-items: center;
    min-height: 100%;
    height: auto;
    padding: 32px 16px;
    background:
      radial-gradient(900px 640px at 50% 38%, color-mix(in srgb, var(--app) 20%, transparent), transparent 72%),
      radial-gradient(1400px 900px at 50% 120%, rgb(255 255 255 / 0.04), transparent 60%),
      #0a0b0d;
  }
  .phone {
    flex: none;
    width: calc(var(--screen-w) + 2 * var(--bezel));
    height: calc(var(--screen-h) + 2 * var(--bezel));
    margin: 0;
    border: var(--bezel) solid #0b0b0d;
    border-radius: var(--radius-phone);
    box-shadow:
      0 0 0 1.5px #44474d,
      0 0 0 3.5px #1b1c1f,
      0 0 0 4.5px #55585e,
      0 60px 120px -40px rgb(0 0 0 / 0.9),
      0 40px 80px -50px color-mix(in srgb, var(--app) 60%, transparent);
  }
  /* The Dynamic Island */
  .phone::before {
    content: "";
    position: absolute;
    z-index: 40;
    top: 11px;
    left: 50%;
    width: 120px;
    height: 35px;
    border-radius: 20px;
    background: #000;
    transform: translateX(-50%);
    pointer-events: none;
  }
  /* The home indicator */
  .phone::after {
    content: "";
    position: absolute;
    z-index: 40;
    bottom: 8px;
    left: 50%;
    width: 134px;
    height: 5px;
    border-radius: 3px;
    background: rgb(0 0 0 / 0.82);
    transform: translateX(-50%);
    pointer-events: none;
  }
  .statusbar {
    position: relative;
    z-index: 30;
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    padding: 4px 32px 0 40px;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    user-select: none;
  }
  [dir="rtl"] .statusbar { padding: 4px 40px 0 32px; }
  .sb-time { min-width: 54px; text-align: center; }
  .sb-icons { display: flex; align-items: center; gap: 6px; }
  .sb-icons svg { display: block; height: 12px; width: auto; }
  .appbar { padding-top: 6px !important; }
}

/* ---------- App header: the app's logo and title, clean on the screen's ground ---------- */
.appbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: var(--ink);
  background: var(--ground);
}
.logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--app) 78%, #fff), var(--app) 60%);
  box-shadow: 0 0 0 0.5px rgb(0 0 0 / 0.1), 0 6px 14px -6px color-mix(in srgb, var(--app) 70%, transparent);
}
.logo svg { width: 22px; height: 22px; }
.app-title { display: flex; flex: 1; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; }
.app-name {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.015em;
  line-height: 1.22;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.app-title .app-name { flex: none; }
.app-sub { max-width: 100%; overflow: hidden; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; text-overflow: ellipsis; }
.mock-badge {
  flex: none;
  margin-top: 3px;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  color: #3b2a00;
  background: #ffd24d;
}

/* The language switch: an iOS segmented control */
.langs {
  display: flex;
  flex: none;
  padding: 2px;
  border-radius: 999px;
  background: var(--fill);
}
.langs button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.langs button[lang="ar"] { font-family: var(--font-ar); }
.langs button[aria-pressed="true"] { color: var(--ink); background: var(--paper); box-shadow: 0 0 0 0.5px rgb(0 0 0 / 0.04), 0 2px 6px -1px rgb(0 0 0 / 0.16); }
.langs button:focus-visible { outline: 2px solid var(--app-ring); outline-offset: 1px; }

/* ---------- Content ---------- */
.content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 4px 16px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.content::-webkit-scrollbar { display: none; }
/* Room for the floating tab bar and the line under it. */
.has-dock .content { padding-bottom: calc(108px + var(--home)); }
.tab-panel { display: flex; flex: 1; flex-direction: column; gap: 12px; }

.citizen {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-card);
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 650;
  font-size: 17px;
  color: var(--app);
  background: var(--app-soft);
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who-label { font-size: 12px; color: var(--ink-3); }
.who-name { font-weight: 650; font-size: 15.5px; line-height: 1.3; letter-spacing: -0.01em; }
.who-sub { font-size: 12.5px; color: var(--ink-2); }
.who-sub bdi { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.net-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius-ctl);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--warn);
  background: var(--warn-soft);
}
.net-note::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }

.screen { flex: 1; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; gap: 10px; animation: enter var(--dur) var(--ease) both; }
.view:focus { outline: none; }
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

h1, h2 { margin: 0; line-height: 1.3; }
.lede { margin: 0; color: var(--ink-2); font-size: 14px; }

/* ---------- Outcomes (loading, idle, approved, declined, expired) ---------- */
.outcome { justify-content: center; align-items: center; gap: 8px; text-align: center; padding: 28px 12px; }
.outcome h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.outcome .lede { max-width: 290px; }
.mark { display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 12px; border-radius: 50%; animation: halo 520ms var(--ease) both; }
.mark svg { width: 34px; height: 34px; }
.mark.ok { color: #fff; background: var(--ok); box-shadow: 0 0 0 10px var(--ok-soft); }
.mark.stop { color: #fff; background: var(--stop); box-shadow: 0 0 0 10px var(--stop-soft); }
.mark.warn { color: var(--warn); background: var(--warn-soft); box-shadow: 0 0 0 10px rgb(163 90 0 / 0.06); }
.mark.neutral { color: var(--neutral); background: var(--paper); box-shadow: var(--shadow-card), 0 0 0 10px var(--neutral-soft); }
.mark.ok svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 420ms 160ms var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes halo { from { opacity: 0; transform: scale(0.7); } }
.outcome.quiet h1 { color: var(--ink-2); font-size: 17px; }
.receipt { margin: 6px 0 0; padding: 8px 14px; border-radius: 12px; font-size: 13px; color: var(--ink-2); background: var(--paper); box-shadow: var(--shadow-card); }
.receipt bdi { font-family: var(--mono); color: var(--ink); }

/* ---------- The pending request card ---------- */
.req {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.req:focus { outline: none; }
.req-head { display: flex; align-items: center; gap: 12px; }
.rp-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--hayyak) 78%, #fff), var(--hayyak) 60%);
}
.rp-mark svg { width: 21px; height: 21px; }
.req-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.req-head small { display: block; font-size: 12.5px; color: var(--ink-3); }
.req p { margin: 0; font-size: 14.5px; }
.asks { list-style: none; margin: 0; padding: 4px 0; display: flex; flex-direction: column; gap: 0; font-size: 14.5px; }
.asks li { display: flex; align-items: center; gap: 12px; min-height: 35px; border-bottom: 0.5px solid var(--line); }
.asks li:last-child { border-bottom: 0; }
.asks svg { flex: none; width: 26px; height: 26px; padding: 5px; border-radius: 8px; color: var(--app); background: var(--app-soft); }
.reason { color: var(--ink-3); font-size: 13px !important; }
.kv { display: flex; flex-direction: column; gap: 0; margin: 0; font-size: 14px; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 0.5px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { min-width: 0; color: var(--ink-3); }
.kv dd { margin: 0; text-align: end; font-weight: 550; white-space: nowrap; }
.kv .sub { padding-inline-start: 10px; font-size: 12.5px; }
.kv bdi { font-variant-numeric: tabular-nums; }
.amount-label { font-size: 12.5px; color: var(--ink-3); }
.amount { display: flex; align-items: baseline; gap: 6px; font-size: 38px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.amount small { font-size: 15px; font-weight: 650; letter-spacing: 0; color: var(--ink-3); }
.countdown {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0 0;
  padding: 8px 14px;
  border-radius: var(--radius-ctl);
  font-size: 13.5px;
  color: var(--ink-2);
  background: var(--ground);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.countdown bdi { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.countdown.urgent { color: var(--stop); background: var(--stop-soft); }
.countdown.urgent bdi { color: var(--stop); }

/* ---------- Buttons ---------- */
.actions, .row { display: flex; flex-direction: column; gap: 10px; }
.row { flex-direction: row; }
.row > * { flex: 1; }
button.primary, button.secondary, button.danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
button.primary { color: #fff; background: var(--app); box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--app) 85%, transparent); }
button.primary:hover { background: var(--app-press); }
button.primary svg { width: 20px; height: 20px; }
button.secondary { color: var(--ink); background: var(--fill); }
button.secondary:hover { background: var(--fill-2); }
button.danger { color: #fff; background: var(--stop); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
button:focus-visible { outline: 3px solid var(--app-ring); outline-offset: 2px; }

.confirm { display: flex; flex-direction: column; gap: 10px; }
.confirm .req { gap: 4px; }
.confirm-q { font-weight: 700; font-size: 16px !important; }

/* ---------- Face check / sending ---------- */
.scan { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 18px 0; }
.scan-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  border-radius: 34px;
  overflow: hidden;
  color: var(--app);
  background: var(--paper);
  box-shadow: var(--shadow-card), inset 0 0 0 3px var(--app);
}
.scan-ring svg { width: 54px; height: 54px; }
.scan-line {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: var(--app);
  box-shadow: 0 0 14px 4px var(--app-ring);
  animation: sweep 1s ease-in-out infinite alternate;
}
.scan-ring.done .scan-line { display: none; }
@keyframes sweep { from { top: 8%; } to { top: 90%; } }
.scan-label { margin: 16px 0 0; font-weight: 600; color: var(--ink-2); }

.sending { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; margin: 0; font-weight: 600; color: var(--ink-2); }
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--app-soft);
  border-top-color: var(--app);
  animation: spin 700ms linear infinite;
}
.spinner.big { width: 38px; height: 38px; border-width: 3px; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- The floating tab bar, and the line under it ---------- */
.dock {
  position: absolute;
  z-index: 10;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px calc(8px + var(--home));
  background: linear-gradient(to bottom, color-mix(in srgb, var(--ground) 0%, transparent), var(--ground) 42%);
  pointer-events: none;
}
.tabbar {
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.86);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: var(--shadow-float);
  pointer-events: auto;
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 104px;
  padding: 7px 16px 6px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-selected="true"] { color: var(--app); background: var(--app-soft); }
.tab:hover:not([aria-selected="true"]) { color: var(--ink-2); }
.tab:focus-visible { outline: 2px solid var(--app-ring); outline-offset: 1px; }
.tab-ico { position: relative; display: block; }
.badge {
  position: absolute;
  top: -4px;
  inset-inline-start: 15px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: var(--badge);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.95);
  animation: halo 360ms var(--ease) both;
}
.privacy {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
  pointer-events: auto;
}
.privacy::before {
  content: "";
  flex: none;
  width: 11px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 12'%3E%3Cpath d='M2.5 5V3.5a3 3 0 0 1 6 0V5h.5A1 1 0 0 1 10 6v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zm1.25 0h3.5V3.5a1.75 1.75 0 0 0-3.5 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 12'%3E%3Cpath d='M2.5 5V3.5a3 3 0 0 1 6 0V5h.5A1 1 0 0 1 10 6v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zm1.25 0h3.5V3.5a1.75 1.75 0 0 0-3.5 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- The card tab: the citizen's ID, or the wallet ---------- */
.card-view { justify-content: flex-start; gap: 16px; padding-top: 4px; }
.pass {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 214px;
  padding: 20px;
  border-radius: 24px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(420px 220px at 110% -10%, rgb(255 255 255 / 0.22), transparent 60%),
    radial-gradient(300px 200px at -20% 120%, rgb(0 0 0 / 0.25), transparent 70%),
    linear-gradient(150deg, color-mix(in srgb, var(--app) 82%, #fff), var(--app) 55%, var(--app-press));
  box-shadow: 0 20px 40px -20px color-mix(in srgb, var(--app) 90%, transparent), inset 0 0 0 0.5px rgb(255 255 255 / 0.2);
}
.pass-top { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 650; letter-spacing: 0.01em; }
.pass-top svg { width: 22px; height: 22px; }
.pass-body { display: flex; align-items: center; gap: 16px; }
.pass-photo {
  display: grid;
  place-items: center;
  flex: none;
  width: 62px;
  height: 74px;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 650;
  background: rgb(255 255 255 / 0.18);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25);
}
.pass dl { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; }
.pass dt { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.72; }
.pass dd { margin: 0; font-size: 15.5px; font-weight: 650; overflow-wrap: anywhere; }
.pass dd [lang] { font-size: 13.5px; font-weight: 500; opacity: 0.85; }
.pass dd [lang="ar"] { font-family: var(--font-ar); }
.pass .num { align-self: flex-start; margin-top: auto; font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.pass-chip { width: 40px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, #f3dc9a, #c9a24c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.card-note { margin: 0; padding: 0 8px; font-size: 13.5px; text-align: center; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .scan-line { top: 50%; }
}
