/* TogoLex — institutional design system.
   Restrained Togo national identity: deep green base, gold accent, red for
   caution; tricolor only as a thin ceremonial strip. Self-hosted system fonts
   for speed + a tight CSP. WCAG-AA contrast throughout. */

:root {
  --green-900: #093d29;
  --green-800: #0a4d33;
  --green-700: #0b5d3b;
  --green-600: #14784c;
  --green-050: #eef4f0;
  --gold-500: #e2b53a;
  --gold-600: #c8991f;
  --red-600: #c8102e;
  --red-050: #fbecef;

  --ink: #14231c;
  --ink-soft: #465a50;
  --line: #e2e7e3;
  --paper: #ffffff;
  --paper-warm: #f7f6f1;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(9, 61, 41, .06), 0 1px 3px rgba(9, 61, 41, .08);
  --shadow-lg: 0 10px 30px rgba(9, 61, 41, .10), 0 2px 8px rgba(9, 61, 41, .06);
  --maxw: 940px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper-warm);
  line-height: 1.6;
  font-size: 17px;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
em { font-style: italic; }

.container { width: min(var(--maxw), 92vw); margin-inline: auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Tricolor ceremonial strip */
.tricolor { display: flex; height: 4px; }
.tricolor span { flex: 1; }
.tricolor span:nth-child(1) { background: var(--green-700); }
.tricolor span:nth-child(2) { background: var(--gold-500); }
.tricolor span:nth-child(3) { background: var(--red-600); }

/* Government identity bar */
.govbar { background: var(--green-900); color: #f4efe2; }
.govbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .5rem 0; min-height: 52px;
}
.govbar__id { display: flex; align-items: center; gap: .7rem; }
.emblem { color: var(--gold-500); flex: none; }
.govbar__text { display: flex; flex-direction: column; line-height: 1.2; }
.govbar__text strong { font-size: .92rem; letter-spacing: .02em; }
.govbar__text span { font-size: .72rem; color: #c7d6cc; letter-spacing: .06em; text-transform: uppercase; }
.govbar__status {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: #cddbd2;
  background: rgba(255,255,255,.06); padding: .35rem .75rem; border-radius: 999px;
}
.govbar__status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-500); box-shadow: 0 0 0 3px rgba(226,181,58,.2); }
.govbar__status.ok .dot { background: #5ad19a; box-shadow: 0 0 0 3px rgba(90,209,154,.2); }
.govbar__status.down .dot { background: var(--red-600); box-shadow: 0 0 0 3px rgba(200,16,46,.2); }

/* Masthead */
.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.masthead__inner { padding: 1.4rem 0; }
.brand { display: flex; align-items: center; gap: 1rem; }
.brand__mark {
  width: 52px; height: 52px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--green-700), var(--green-900));
  color: var(--gold-500); font-family: var(--serif); font-weight: 700; font-size: 1.35rem;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(226,181,58,.25);
}
.brand__name h1 { margin: 0; font-size: 1.7rem; color: var(--green-900); line-height: 1; }
.brand__name p { margin: .3rem 0 0; font-size: .86rem; color: var(--ink-soft); }
.brand__name p span { color: var(--green-700); }

/* Hero */
.hero { padding: clamp(2.2rem, 5vw, 3.6rem) 0 1.5rem; }
.hero__title {
  font-size: clamp(2rem, 5vw, 3rem); line-height: 1.08; margin: 0 0 1rem;
  color: var(--green-900); max-width: 18ch;
}
.hero__title em { color: var(--green-600); }
.hero__lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 62ch; margin-bottom: 1.8rem; }

/* Ask box */
.ask { margin: 0 0 1rem; }
.ask__field {
  display: flex; gap: .6rem; align-items: flex-end;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: .6rem .6rem .6rem 1.1rem; box-shadow: var(--shadow-lg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ask__field:focus-within { border-color: var(--green-600); box-shadow: 0 0 0 4px rgba(20,120,76,.12), var(--shadow-lg); }
.ask__field textarea {
  flex: 1; width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  font: inherit; color: var(--ink); padding: .55rem 0; min-height: 1.6rem;
  max-height: 200px; line-height: 1.5;
}
.btn {
  flex: none; display: inline-flex; align-items: center; gap: .5rem;
  background: var(--green-700); color: #fff; border: 0; border-radius: 10px;
  padding: .75rem 1.2rem; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--green-800); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn__icon { transition: transform .15s ease; }
.btn:not(:disabled):hover .btn__icon { transform: translateX(2px); }
.ask__hint { font-size: .78rem; color: var(--ink-soft); margin: .55rem .3rem 0; }

/* Example chips */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.chip {
  background: var(--green-050); color: var(--green-800); border: 1px solid #d6e4dc;
  border-radius: 999px; padding: .45rem .9rem; font: inherit; font-size: .84rem;
  cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.chip:hover { background: #e2ede7; border-color: var(--green-600); }

/* Answer card */
.answer {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.6rem; margin: 1.5rem 0; box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--green-700);
}
.answer__head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.answer__q { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 1.02rem; }
.badge {
  display: inline-flex; align-items: center; gap: .4rem; flex: none;
  font-size: .74rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: .32rem .7rem; border-radius: 999px;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--grounded { background: var(--green-050); color: var(--green-700); }
.badge--caution { background: var(--red-050); color: var(--red-600); }
.answer__body { font-size: 1.06rem; }
.answer__body :is(p):last-child { margin-bottom: 0; }
.answer__body .cite {
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--green-700);
  background: var(--green-050); border-radius: 5px; padding: 0 .3rem; font-size: .82em;
}

.sources { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px dashed var(--line); }
.sources__title { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 0 0 .7rem; }
.sources__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.sources__list li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .7rem;
  padding: .6rem .8rem; background: var(--paper-warm); border: 1px solid var(--line); border-radius: 9px;
}
.src__tag {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: .78rem;
  color: var(--green-700); background: var(--green-050); border-radius: 6px; padding: .2rem .5rem; flex: none;
}
.src__cite { font-size: .9rem; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.src__score { display: flex; align-items: center; gap: .5rem; flex: none; }
.src__meter { width: 60px; height: 6px; border-radius: 3px; background: #e3e8e4; overflow: hidden; }
.src__meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-600), var(--gold-500)); }
.src__pct { font-size: .74rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; width: 3ch; text-align: right; }

.answer__disclaimer { font-size: .8rem; color: var(--ink-soft); margin: 1.3rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }

.answer--error { border-top-color: var(--red-600); }
.answer--error .answer__body { color: var(--red-600); }

/* Loading skeleton */
.answer--loading .skeleton { border-radius: 6px; background: linear-gradient(90deg, #eef1ee 25%, #e3e8e4 37%, #eef1ee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton--badge { width: 120px; height: 20px; margin-bottom: 1.2rem; }
.skeleton--line { height: 14px; margin: .7rem 0; }
.skeleton--line.short { width: 55%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Trust pillars */
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2.5rem 0 3rem; }
.pillar { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.pillar__icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: var(--green-050); color: var(--green-700); margin-bottom: .8rem; }
.pillar h3 { font-size: 1.05rem; margin: 0 0 .4rem; color: var(--green-900); }
.pillar p { font-size: .9rem; color: var(--ink-soft); margin: 0; }

/* Footer */
.footer { background: var(--green-900); color: #cddbd2; margin-top: auto; }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 1.8rem 0; flex-wrap: wrap; }
.footer__brand { font-family: var(--serif); font-size: 1.2rem; color: var(--gold-500); font-weight: 600; }
.footer__inner p { margin: .2rem 0 0; font-size: .82rem; }
.footer__legal { max-width: 42ch; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .pillars { grid-template-columns: 1fr; }
  .ask__field { flex-direction: column; align-items: stretch; padding: .8rem; }
  .ask__field textarea { min-height: 2.2rem; padding: .3rem .2rem; }
  .btn { justify-content: center; }
  .govbar__status { display: none; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
  .sources__list li { grid-template-columns: auto 1fr; }
  .src__score { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
