/*
 * The guest page's styles (Decision 10 › Branding; slice 5.1).
 *
 * Tokens are copied from the website (docs/BRANDING.md, which cites the source
 * of every value); where the website defines nothing (the input, focus, the
 * send button), the values follow Decision 10's derivations. Rules that are
 * easy to break:
 *   - Small green text is always #17601C, never #248E1F (4.23:1 fails AA).
 *   - No small white text on #248E1F; the send button is a white ICON on it.
 *   - The input is 16px or larger, or iOS Safari zooms in on focus.
 *   - Layout uses logical properties (inline-start/end), so Arabic mirrors itself.
 */

/* ---------------------------------------------------------------------------
 * Fonts: self-hosted, IBM Plex Sans Arabic + IBM Plex Sans, 400 and 600 only.
 * Source: Fontsource 5.3.0 (@fontsource/ibm-plex-sans-arabic, @fontsource/ibm-plex-sans),
 * the same files the website ships, copied from cdn.jsdelivr.net/npm/@fontsource/…@5.3.0/files/.
 * Licence: SIL Open Font License 1.1 — fonts/OFL-*.txt must travel with the files.
 * unicode-range is copied from Fontsource's CSS (the Arabic file's rare ranges above
 * U+FFFF — historic and mathematical letters — left out): the browser downloads only the
 * files for the characters on the page (Arabic visit ≈ 40–85 KB, English ≈ 22–45 KB).
 * ------------------------------------------------------------------------- */
@font-face {
  font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------------------
 * Tokens (docs/BRANDING.md §1–3, 7; names kept from the website's tokens.css).
 * ------------------------------------------------------------------------- */
:root {
  --fp-green: #248E1F;
  --fp-green-hover: #1F7A1A;
  --fp-appbar-green: #17601C;
  --fp-black: #0A0A0A;
  --fp-cream: #F5F0E8;
  --fp-white: #FFFFFF;
  --fp-text-muted: rgba(10, 10, 10, 0.62);
  --fp-green-tint: rgba(36, 142, 31, 0.08);
  --fp-green-ring: rgba(36, 142, 31, 0.13);
  --fp-badge-amber-fill: rgba(255, 190, 60, 0.22);
  --fp-badge-amber-text: #8A5A00;

  --fp-border: 1px solid rgba(10, 10, 10, 0.08);
  /* Darker than the website's token (.14 → .50, slice 5.3): the white field on
     cream is only 1.13:1, so the border alone outlines where to type — .14 was
     1.36:1; .50 is 3.71:1 on white / 3.62:1 on cream (WCAG 1.4.11 needs 3:1). */
  --fp-border-input: 1.5px solid rgba(10, 10, 10, 0.5);

  --fp-font-latin: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --fp-font-arabic: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  --fp-size-body: 16px;
  --fp-size-small: 13.5px;
  --fp-size-caption: 12.5px;
  --fp-leading-body: 1.6;

  --fp-space-xs: 4px;
  --fp-space-sm: 8px;
  --fp-space-12: 12px;
  --fp-space-md: 16px;
  --fp-space-lg: 24px;

  --fp-radius-control: 10px;
  --fp-radius-btn-sm: 11px;
  --fp-radius-input: 14px;
  --fp-radius-btn: 15px;
  --fp-radius-card: 18px;
  --fp-radius-pill: 999px;

  --fp-shadow-card-subtle: 0 1px 3px rgba(10, 10, 10, 0.05);
  --fp-shadow-appbar: 0 1px 4px rgba(0, 0, 0, 0.12);
  --fp-focus-ring: 0 0 0 3px var(--fp-green-ring);
  --fp-transition-fast: 140ms ease;

  /* The chat column's width on wide screens. */
  --page-max: 720px;
}

/* ---------------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* The font follows each element's language, so an English bubble on the
   Arabic page (and the reverse) gets the right face. */
:lang(ar) { font-family: var(--fp-font-arabic); }
:lang(en) { font-family: var(--fp-font-latin); }

html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--fp-cream);
  color: var(--fp-black);
  font-size: var(--fp-size-body);
  line-height: var(--fp-leading-body);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--fp-green);
  outline-offset: 2px;
  border-radius: var(--fp-radius-control);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------
 * Header — always left to right (BRANDING.md §4.5): logo left, language right.
 * ------------------------------------------------------------------------- */
/* The green runs up behind the phone's status bar (safe-area-inset-top; the page
   uses viewport-fit=cover) — otherwise iOS Safari shows a cream strip above it and
   the bar looks cut off (seen on an iPhone 13, slice 5.3). Sticky, as on the
   website, so it stays put if Safari scrolls the page for the keyboard.
   Side insets keep it clear of the notch in landscape. */
.header {
  position: sticky;
  top: 0;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fp-space-md);
  min-block-size: 60px;
  padding-block: calc(var(--fp-space-sm) + env(safe-area-inset-top)) var(--fp-space-sm);
  padding-left: max(var(--fp-space-md), env(safe-area-inset-left));
  padding-right: max(var(--fp-space-md), env(safe-area-inset-right));
  background: var(--fp-appbar-green);
  box-shadow: var(--fp-shadow-appbar);
  color: var(--fp-white);
  z-index: 1;
}
.header__brand { display: flex; align-items: center; gap: var(--fp-space-12); min-inline-size: 0; }
/* The logo has an opaque white background, so it sits on a white plate. */
.logo-plate {
  flex: none;
  display: inline-flex;
  padding: var(--fp-space-xs) var(--fp-space-sm);
  border-radius: var(--fp-radius-btn-sm);
  background: var(--fp-white);
}
.logo-plate img { display: block; block-size: 34px; inline-size: auto; }
.header__title {
  margin: 0;
  font-size: var(--fp-size-body);
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The language pill (BRANDING.md §4.4), made 44px tall to meet the tap-target minimum. */
.lang-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  padding: 0 var(--fp-space-md);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--fp-radius-pill);
  color: var(--fp-white);
  font-size: var(--fp-size-small);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background var(--fp-transition-fast), border-color var(--fp-transition-fast);
}
.lang-pill:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); }
/* A green outline is invisible on the green header (BRANDING.md §10.1): use white there. */
.header :focus-visible { outline-color: var(--fp-white); }

/* ---------------------------------------------------------------------------
 * The conversation
 * ------------------------------------------------------------------------- */
.log {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--fp-space-12);
  padding-block: var(--fp-space-md);
  /* Centred column on wide screens; clear of the notch in landscape. */
  padding-left: max(var(--fp-space-md), env(safe-area-inset-left), calc((100% - var(--page-max)) / 2));
  padding-right: max(var(--fp-space-md), env(safe-area-inset-right), calc((100% - var(--page-max)) / 2));
}
.welcome { display: flex; flex-direction: column; gap: var(--fp-space-12); }

.bubble {
  max-inline-size: 85%;
  padding: var(--fp-space-12) var(--fp-space-md);
  border-radius: var(--fp-radius-card);
  white-space: pre-wrap;       /* the KB joins stored answers with blank lines */
  overflow-wrap: anywhere;     /* a long URL never widens the page */
}
.bubble--assistant {
  align-self: flex-start;
  background: var(--fp-white);
  border: var(--fp-border);
  box-shadow: var(--fp-shadow-card-subtle);
}
.bubble--guest {
  align-self: flex-end;
  background: var(--fp-green-tint);
  border: 1px solid rgba(36, 142, 31, 0.18);
}

/* Links and numbers inside a reply (slice 5.2). */
/* An allowlisted KB link: a labelled button in place of the URL (Decision 10). */
/* Slimmer than 44px so a sentence holding a button doesn't gape (seen on an
   iPhone 13, slice 5.3); the invisible ::before keeps the TAP area 44px tall.
   Filled with the website's green #1F7A1A (--fp-green-hover), the same as the
   send button (approved 2026-09-25): white text on it is 5.44:1 — white on the
   brighter brand green #248E1F would be 4.23:1, which fails AA (Decision 10). */
.link-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  min-block-size: 32px;
  margin: 1px 0;
  padding: 0 14px;
  border-radius: var(--fp-radius-pill);
  background: var(--fp-green-hover);
  color: var(--fp-white);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--fp-transition-fast);
}
.link-button::before {
  content: "";
  position: absolute;
  inset: -6px 0; /* 32 + 6 + 6 = 44px to tap */
}
.link-button:hover { background: var(--fp-appbar-green); }
/* A KB phone number: shown as written, tap-to-call. */
.phone {
  color: var(--fp-appbar-green);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
/* A URL that isn't allowed stays text; <bdi dir="ltr"> keeps it in order inside Arabic. */
.url { overflow-wrap: anywhere; }

/* The three fixed messages that are not answers: colour + icon, so they're told
   apart from answers and from each other without relying on colour alone
   (approved 2026-09-25). The bar sits on the reading-start edge. */
.bubble[data-kind="busy"],
.bubble[data-kind="session_limit"],
.bubble[data-kind="no_match"] {
  display: flex;
  align-items: flex-start;
  gap: var(--fp-space-sm);
}
.bubble__icon { flex: none; margin-block-start: 3px; }
.bubble__text { min-inline-size: 0; }
/* busy — the website's amber badge (Decision 10): out of capacity, try later. */
.bubble[data-kind="busy"] {
  background: linear-gradient(var(--fp-badge-amber-fill), var(--fp-badge-amber-fill)), var(--fp-white);
  border-color: rgba(138, 90, 0, 0.25);
  color: var(--fp-badge-amber-text);
}
/* session_limit — today's questions are used up. */
.bubble[data-kind="session_limit"] {
  background: linear-gradient(var(--fp-green-tint), var(--fp-green-tint)), var(--fp-white);
  border-inline-start: 4px solid var(--fp-appbar-green);
}
.bubble[data-kind="session_limit"] .bubble__icon { color: var(--fp-appbar-green); }
/* no_match — the KB doesn't have it. */
.bubble[data-kind="no_match"] { border-inline-start: 4px solid rgba(10, 10, 10, 0.35); }
.bubble[data-kind="no_match"] .bubble__icon { color: var(--fp-text-muted); }

/* The typing indicator: three dots in a reply bubble. */
.typing { display: flex; align-items: center; gap: 6px; min-block-size: 44px; }
.typing__dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  background: var(--fp-text-muted);
  animation: typing-dot 1.2s ease-in-out infinite;
}
.typing__dot:nth-child(3) { animation-delay: 0.15s; }
.typing__dot:nth-child(4) { animation-delay: 0.3s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chips__caption { color: var(--fp-text-muted); font-size: var(--fp-size-small); }
.chips { display: flex; flex-wrap: wrap; gap: var(--fp-space-sm); }
/* Chips: #17601C text on white with the green outline (BRANDING.md §4.1 "secondary-cream"). */
.chip {
  min-block-size: 44px;
  padding: var(--fp-space-sm) var(--fp-space-md);
  border: 1.5px solid var(--fp-green);
  border-radius: var(--fp-radius-pill);
  background: var(--fp-white);
  color: var(--fp-appbar-green);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-align: start;
  transition: background var(--fp-transition-fast);
}
.chip:hover { background: var(--fp-green-tint); }

/* A problem line (connection failed, check failed): not a reply, so not a bubble. */
.notice {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--fp-space-sm) var(--fp-space-md);
  padding: var(--fp-space-12) var(--fp-space-md);
  border: 1px dashed rgba(10, 10, 10, 0.3);
  border-radius: var(--fp-radius-card);
  color: var(--fp-text-muted);
  font-size: var(--fp-size-small);
}
.notice__button {
  min-block-size: 44px;
  padding: 0 var(--fp-space-md);
  border: 1.5px solid var(--fp-green);
  border-radius: var(--fp-radius-btn);
  background: var(--fp-white);
  color: var(--fp-appbar-green);
  font-weight: 600;
}
.notice__button:hover { background: var(--fp-green-tint); }

/* ---------------------------------------------------------------------------
 * The composer: robot check, status, input, questions left, privacy notice
 * ------------------------------------------------------------------------- */
.composer {
  flex: none;
  border-block-start: var(--fp-border);
  background: var(--fp-cream);
  padding-block: var(--fp-space-sm) max(var(--fp-space-sm), env(safe-area-inset-bottom));
  padding-left: max(var(--fp-space-md), env(safe-area-inset-left));
  padding-right: max(var(--fp-space-md), env(safe-area-inset-right));
}
.composer__inner {
  max-inline-size: var(--page-max);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--fp-space-sm);
}
.turnstile:empty { display: none; }
.turnstile { display: flex; justify-content: center; }
.status { color: var(--fp-text-muted); font-size: var(--fp-size-small); text-align: center; }

.composer__form { display: flex; gap: var(--fp-space-sm); align-items: center; }
/* The input: the website's unused input tokens, at 16px so iOS doesn't zoom (Decision 10). */
.composer__input {
  flex: 1 1 auto;
  min-inline-size: 0;
  min-block-size: 48px;
  padding: var(--fp-space-12) 15px;
  border: var(--fp-border-input);
  border-radius: var(--fp-radius-input);
  background: var(--fp-white);
  font-size: 16px;
}
.composer__input:focus-visible {
  outline: none;
  border-color: var(--fp-green);
  box-shadow: var(--fp-focus-ring);
}
/* Send: a white icon on #1F7A1A, 5.44:1 (icons need 3:1). */
.send {
  flex: none;
  display: inline-grid;
  place-items: center;
  inline-size: 48px;
  block-size: 48px;
  border: 0;
  border-radius: var(--fp-radius-btn);
  background: var(--fp-green-hover); /* the same green as the link buttons (approved 2026-09-25) */
  color: var(--fp-white);
  transition: background var(--fp-transition-fast);
}
.send:hover { background: var(--fp-appbar-green); }
.send:disabled { opacity: 0.5; cursor: default; }
/* The arrow points the way the text reads. */
[dir="rtl"] .send__icon { transform: scaleX(-1); }

.remaining { color: var(--fp-appbar-green); font-size: var(--fp-size-small); font-weight: 600; text-align: center; }
.privacy { color: var(--fp-text-muted); font-size: var(--fp-size-caption); line-height: 1.5; text-align: center; }

.noscript { padding: var(--fp-space-md); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .typing__dot { animation: none; opacity: 0.6; } /* still dots, no movement */
}
