/* ============================================================
   RUZIVO — National identity token system
   Government of Zimbabwe · citizen information assistant
   Flag palette · seal/heraldic motifs · dark + light
   ============================================================ */

/* ---- Fonts (display serif + UI grotesque + documentary mono) ---- */
/* The actual font files load via the Google Fonts <link> in index.html.
   These @font-face rules DECLARE the families (binding to a locally
   installed copy when present) so the design-system compiler resolves
   them. Tokens keep pointing at these exact families — no substitution. */
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: local("Spectral"), local("Spectral-Regular");
}
@font-face {
  font-family: "Spectral";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: local("Spectral Italic"), local("Spectral-Italic");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: local("Hanken Grotesk"), local("HankenGrotesk-Regular");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local("JetBrains Mono"), local("JetBrainsMono-Regular");
}

:root {
  /* ---- Brand constants (the flag) ---- */
  --zw-green: #1F8A4C;
  --zw-green-deep: #14653A;
  --zw-gold: #E8B530;
  --zw-gold-deep: #B8860B;
  --zw-red: #C0392B;
  --zw-black: #0B0F0C;
  --zw-paper: #FBFAF6;

  /* ---- Type ---- */
  --font-display: "Spectral", Georgia, "Times New Roman", serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* ---- Radii ---- */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* ---- Spacing rhythm ---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1); /* @kind other */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1); /* @kind other */
}

/* ============================================================
   DARK — the premium pitch theme (default)
   deep ink-green, gold hairlines, dramatic on a projector
   ============================================================ */
[data-theme="dark"] {
  color-scheme: dark;

  --bg:           #080C09;
  --bg-grain:     #0A0F0B;
  --elev:         #0E140F;
  --surface:      #121A14;
  --surface-2:    #18221A;
  --surface-3:    #1E2A20;

  --line:         rgba(232, 181, 48, 0.12);
  --line-soft:    rgba(255, 255, 255, 0.07);
  --line-strong:  rgba(232, 181, 48, 0.28);

  --ink:          #ECF2E9;
  --ink-soft:     #A4B0A2;
  --ink-faint:    #6B776A;
  --ink-inverse:  #0B0F0C;

  --accent:       #38C075;   /* brighter green for dark */
  --accent-deep:  #1F8A4C;
  --accent-tint:  rgba(56, 192, 117, 0.14);
  --accent-line:  rgba(56, 192, 117, 0.34);

  --gold:         #ECC04A;
  --gold-soft:    rgba(236, 192, 74, 0.16);
  --red:          #E5675A;
  --red-soft:     rgba(229, 103, 90, 0.16);

  --user-bubble:  #16271C;
  --user-line:    rgba(56, 192, 117, 0.22);

  --halo:         radial-gradient(1100px 620px at 50% -8%, rgba(31,138,76,0.30), transparent 62%),
                  radial-gradient(720px 460px at 88% 4%, rgba(236,192,74,0.10), transparent 60%); /* @kind other */

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 10px 30px -12px rgba(0,0,0,0.7);
  --shadow-lg: 0 30px 70px -24px rgba(0,0,0,0.8);
  --shadow-seal: 0 0 0 1px rgba(236,192,74,0.22), 0 14px 40px -18px rgba(0,0,0,0.85);
}

/* ============================================================
   LIGHT — bright, official, daytime
   warm paper, ink-green text, restrained gold
   ============================================================ */
[data-theme="light"] {
  color-scheme: light;

  --bg:           #FBFAF6;
  --bg-grain:     #F7F5EE;
  --elev:         #FFFFFF;
  --surface:      #FFFFFF;
  --surface-2:    #F5F3EC;
  --surface-3:    #EEEBE0;

  --line:         rgba(20, 40, 26, 0.12);
  --line-soft:    rgba(20, 40, 26, 0.08);
  --line-strong:  rgba(176, 125, 10, 0.40);

  --ink:          #15231B;
  --ink-soft:     #4C5A50;
  --ink-faint:    #8A968A;
  --ink-inverse:  #FBFAF6;

  --accent:       #1F8A4C;
  --accent-deep:  #14653A;
  --accent-tint:  rgba(31, 138, 76, 0.10);
  --accent-line:  rgba(31, 138, 76, 0.30);

  --gold:         #A9790A;
  --gold-soft:    rgba(184, 134, 11, 0.14);
  --red:          #C0392B;
  --red-soft:     rgba(192, 57, 43, 0.10);

  --user-bubble:  #E9F2EC;
  --user-line:    rgba(31, 138, 76, 0.20);

  --halo:         radial-gradient(1000px 560px at 50% -10%, rgba(31,138,76,0.10), transparent 60%),
                  radial-gradient(680px 420px at 86% 0%, rgba(184,134,11,0.08), transparent 60%); /* @kind other */

  --shadow-sm: 0 1px 2px rgba(20,40,26,0.06);
  --shadow-md: 0 14px 34px -16px rgba(20,40,26,0.20);
  --shadow-lg: 0 30px 64px -24px rgba(20,40,26,0.22);
  --shadow-seal: 0 0 0 1px rgba(176,125,10,0.18), 0 16px 40px -20px rgba(20,40,26,0.28);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
#root { height: 100%; }

::selection { background: var(--accent-tint); color: var(--ink); }

/* ---- Phosphor icons: inline alignment + crispness ---- */
i[class^="ph"], i[class*=" ph"] {
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: -0.5px;
  display: inline-flex;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbars ---- */
.scroll { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ---- The signature: 7-stripe national ribbon ---- */
.flag-ribbon {
  background: linear-gradient(
    90deg,
    var(--zw-green) 0 14.28%,
    var(--zw-gold)  14.28% 28.56%,
    var(--zw-red)   28.56% 42.84%,
    var(--zw-black) 42.84% 57.16%,
    var(--zw-red)   57.16% 71.44%,
    var(--zw-gold)  71.44% 85.72%,
    var(--zw-green) 85.72% 100%
  );
}
.flag-ribbon-v {
  background: linear-gradient(
    180deg,
    var(--zw-green) 0 14.28%,
    var(--zw-gold)  14.28% 28.56%,
    var(--zw-red)   28.56% 42.84%,
    var(--zw-black) 42.84% 57.16%,
    var(--zw-red)   57.16% 71.44%,
    var(--zw-gold)  71.44% 85.72%,
    var(--zw-green) 85.72% 100%
  );
}

/* ---- Animations ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes pulseDot { 0%,100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes sweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes ringPulse { 0% { transform: scale(0.8); opacity: 0.6; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes caretBlink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.fade-up { animation: fadeUp 0.55s var(--ease-out) both; }
.fade-in { animation: fadeIn 0.5s var(--ease) both; }
.scale-in { animation: scaleIn 0.4s var(--ease-out) both; }
.spin { animation: spin 0.7s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.caret::after {
  content: "▍"; margin-left: 1px; color: var(--accent);
  animation: caretBlink 1s steps(1) infinite; font-weight: 400;
}

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; display: block;
}

/* ---- Focus ring ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- Prose (answers) ---- */
.prose { font-size: 16px; line-height: 1.72; color: var(--ink); }
.prose p { margin: 0 0 0.85em; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose ul { margin: 0 0 0.85em; padding-left: 1.25em; list-style: none; }
.prose ul li { position: relative; margin-bottom: 0.4em; }
.prose ul li::before {
  content: ""; position: absolute; left: -1em; top: 0.62em;
  width: 5px; height: 5px; border-radius: 99px; background: var(--accent);
}
.prose ol { margin: 0 0 0.85em; padding-left: 1.3em; }
.prose ol li { margin-bottom: 0.4em; }

/* ---- Answer blocks (from answer.jsx) ---- */
.cite-chip {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
  padding: 1px 4px; margin: 0 1px; border-radius: 5px; vertical-align: super;
  background: var(--gold-soft); color: var(--gold); line-height: 1;
}
.min-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill); border: 1px solid; font-size: 11px; font-weight: 600;
}
.min-badge .dot { width: 6px; height: 6px; border-radius: 99px; }
.cite-card {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px 11px 16px; border-radius: var(--r-md); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); overflow: hidden;
  transition: all .18s var(--ease);
}
.cite-card:hover { border-color: var(--accent-line); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.cite-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.cite-num {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.cite-title { display: block; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.35; word-break: break-word; }
.pdf-tag {
  margin-left: 6px; font-size: 8.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 5px; background: var(--accent-tint); color: var(--accent);
  vertical-align: middle;
}
.cite-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11.5px; color: var(--ink-faint); }
.cite-open { color: var(--ink-faint); margin-top: 1px; transition: color .15s; }
.cite-card:hover .cite-open { color: var(--accent); }
.contact-card { padding: 13px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.contact-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; padding-bottom: 11px; border-bottom: 1px solid var(--line-soft); }
.contact-rows { display: flex; flex-direction: column; gap: 7px; }
.contact-row { display: grid; grid-template-columns: 18px 78px 1fr; gap: 8px; align-items: start; font-size: 12.5px; word-break: break-word; }
.contact-label { color: var(--ink-faint); }
.contact-val { color: var(--ink); font-weight: 500; }
.ans-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; margin-top: 4px; }
.ans-scope { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); }
.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer; color: var(--ink-faint);
  transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.src-medallion {
  width: 28px; height: 28px; border-radius: var(--r-xs); display: grid; place-items: center; flex-shrink: 0;
}
.src-medallion i { font-size: 15px; color: #fff; }
