/* oPt Education Cluster — public landing page.
   Mobile-first. Everything that has a side uses logical properties (inline-start/end rather
   than left/right) so that setting dir="rtl" on <html> flips the whole layout without a
   second stylesheet. */

:root {
  /* The logo's palette. --primary is UNICEF cyan; --deep carries the headings and the footer. */
  --primary: #1CABE2;
  --primary-dark: #0d8dbf;
  --deep: #0033A0;
  --deeper: #002F6C;
  --ink: #1A2B49;
  --ink-soft: #4a5a75;
  --bg: #F5FAFE;
  --surface: #ffffff;
  --line: #dce8f3;

  /* The rainbow under the header and above the footer, straight off the open book. */
  --green: #4FA845;
  --yellow: #F9C013;
  --orange: #F26A21;
  --red: #E2231A;
  --cyan: #00AEEF;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(26, 43, 73, .06), 0 6px 20px rgba(26, 43, 73, .08);
  --shadow-lg: 0 2px 6px rgba(26, 43, 73, .08), 0 18px 40px rgba(26, 43, 73, .12);

  --font-latin: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-arabic: 'Cairo', 'Tajawal', 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;

  --wrap: 1120px;
}

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

html { scroll-behavior: smooth; }
/* The header is sticky and about 76px tall, so without this an anchor jump parks the
   section's own heading underneath it. The hero's primary button is such a jump. */
section[id], [id]:target { scroll-margin-top: 92px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* Arabic gets Cairo/Tajawal and a touch more line-height — the script needs the room. */
html[lang="ar"] body { font-family: var(--font-arabic); line-height: 1.85; }

h1, h2, h3 { color: var(--deeper); line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 5vw, 2.85rem); }
h2 { font-size: clamp(1.35rem, 3.4vw, 1.9rem); }
p { margin: 0 0 1rem; }
a { color: var(--deep); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
.section { padding-block: clamp(2.25rem, 6vw, 3.75rem); }
.prose { max-width: 68ch; color: var(--ink-soft); font-size: 1.03rem; }
.note { color: var(--ink-soft); font-size: .9rem; }

.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 1200;
  background: var(--deep); color: #fff; padding: .75rem 1.15rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { inset-inline-start: 0; }

/* Visible focus everywhere. The default outline disappears against the cyan. */
:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; border-radius: 6px; }

/* ---------- the rainbow rule ---------- */
.rainbow {
  height: 4px;
  background: linear-gradient(to right,
    var(--green) 0 20%, var(--yellow) 20% 40%, var(--orange) 40% 60%,
    var(--red) 60% 80%, var(--cyan) 80% 100%);
}
/* Mirrored in RTL so the colour order reads the same way the page does. */
html[dir="rtl"] .rainbow { background: linear-gradient(to left,
    var(--green) 0 20%, var(--yellow) 20% 40%, var(--orange) 40% 60%,
    var(--red) 60% 80%, var(--cyan) 80% 100%); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--line);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 72px; padding-block: .6rem;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; min-width: 0; }
.brand img { height: 52px; width: auto; object-fit: contain; border-radius: 10px; flex: none; }
.brand-name {
  font-weight: 700; color: var(--deeper); line-height: 1.2;
  font-size: clamp(.85rem, 2.4vw, 1.05rem); max-width: 22ch;
}

.lang-toggle { display: flex; gap: .25rem; flex: none; background: var(--bg); padding: .25rem; border-radius: 999px; border: 1px solid var(--line); }
.lang-btn {
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  border: 0; background: transparent; color: var(--ink-soft);
  padding: .4rem .85rem; border-radius: 999px; line-height: 1.4;
}
.lang-btn[aria-pressed="true"] { background: var(--deep); color: #fff; }
.lang-btn[lang="ar"] { font-family: var(--font-arabic); }

/* ---------- hero ---------- */
.hero {
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(28, 171, 226, .22) 0%, rgba(28, 171, 226, 0) 60%),
    linear-gradient(160deg, #eaf6fd 0%, #f7fbff 55%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero-inner { padding-block: clamp(2.5rem, 8vw, 5rem); }
/* Measure on the text, not on the container: .hero-inner is also a .wrap, and a max-width
   there would inherit .wrap's auto margins and centre the whole hero out of line with the
   sections below it. */
.hero-inner h1, .tagline { max-width: 42rem; }
.tagline { font-size: clamp(1.05rem, 2.6vw, 1.3rem); color: var(--deep); font-weight: 600; }
.crisis {
  color: var(--ink-soft);
  border-inline-start: 4px solid var(--primary);
  padding-inline-start: 1rem;
  margin-block: 1.5rem;
  max-width: 60ch;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  padding: .8rem 1.5rem; border-radius: 999px; border: 1px solid transparent;
  text-decoration: none; text-align: center; transition: background-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--deep); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: #002b8a; }
.btn-ghost { background: var(--surface); color: var(--deep); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); background: #f2f9fe; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ---------- cards ---------- */
.cards { display: grid; gap: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem;
}

.figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.figure { display: flex; flex-direction: column; gap: .35rem; }
.figure-value {
  font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 700; color: var(--deep);
  line-height: 1.1; font-variant-numeric: tabular-nums;
  /* Numerals stay Latin in both languages: that is what the cluster publishes. */
  font-family: var(--font-latin);
}
.figure-label { color: var(--ink-soft); font-size: .95rem; }

.docs { grid-template-columns: 1fr; }
.doc {
  display: grid; gap: .4rem; text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.doc:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.doc-icon {
  justify-self: start; font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  background: #fdeceb; color: var(--red); padding: .25rem .5rem; border-radius: 6px;
  font-family: var(--font-latin);
}
.doc-title { font-weight: 700; color: var(--deeper); font-size: 1.05rem; }
.doc-blurb { color: var(--ink-soft); font-size: .93rem; }
.doc-link { color: var(--deep); font-weight: 600; font-size: .93rem; margin-top: .25rem; }
.doc-link::after { content: " →"; }
html[dir="rtl"] .doc-link::after { content: " ←"; }

/* ---------- finder ---------- */
.finder-section { background: linear-gradient(180deg, #fff 0%, var(--bg) 100%); border-top: 1px solid var(--line); }

.finder-controls {
  display: grid; gap: 1rem; margin-block: 1.75rem 1rem;
  grid-template-columns: 1fr;
}
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; color: var(--ink); }
.field input {
  font: inherit; padding: .75rem .9rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); min-width: 0;
  /* Coordinates are Latin numerals and read left-to-right even on an RTL page. */
  direction: ltr; text-align: start;
}
html[dir="rtl"] .field input { text-align: right; }
.field input:focus { border-color: var(--primary); }
.field-actions { flex-direction: row; flex-wrap: wrap; gap: .6rem; align-items: end; }
.field-actions .btn { flex: 1 1 auto; }

#map {
  height: clamp(320px, 60vh, 540px); width: 100%;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow); margin-block: 1rem; background: #e8eef4;
  /* Leaflet's own controls are LTR widgets; keep the canvas out of the RTL flip. */
  direction: ltr;
}

.finder-status { font-weight: 600; color: var(--deep); min-height: 1.6em; margin-block: .75rem; }
.finder-status.is-empty { color: var(--ink-soft); font-weight: 400; }
.finder-status.is-error { color: var(--red); }

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.result {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.1rem; display: grid; gap: .2rem;
}
.result-name { font-weight: 700; color: var(--deeper); }
.result-meta { color: var(--ink-soft); font-size: .9rem; }
.result-meta b { color: var(--ink); font-weight: 600; }

/* Leaflet popups inherit the page font, and flip with it. */
.leaflet-popup-content { font-family: inherit; margin: .8rem 1rem; line-height: 1.55; }
html[dir="rtl"] .leaflet-popup-content { direction: rtl; text-align: right; }
.tls-popup-name { font-weight: 700; color: var(--deeper); display: block; margin-bottom: .3rem; }
.tls-popup dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; font-size: .88rem; }
.tls-popup dt { color: var(--ink-soft); }
.tls-popup dd { margin: 0; font-weight: 600; }

/* ---------- footer ---------- */
.site-footer { background: var(--deeper); color: #dbe6f5; margin-top: clamp(2rem, 6vw, 4rem); }
.footer-inner { display: flex; gap: 1.25rem; align-items: flex-start; padding-block: 2.25rem; }
.footer-logo { height: 56px; width: auto; object-fit: contain; border-radius: 10px; background: #fff; padding: 4px; flex: none; }
.footer-text p { margin: 0 0 .3rem; font-size: .93rem; }
.footer-name { font-weight: 700; color: #fff; font-size: 1rem; }
.site-footer a { color: #9ed8f2; }
.footer-year { color: #94a9c9; margin-top: .6rem !important; font-size: .85rem; }

/* ---------- wider screens ---------- */
@media (min-width: 640px) {
  .finder-controls { grid-template-columns: 1fr 1fr; }
  .field-actions { grid-column: 1 / -1; }
  .docs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .docs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finder-controls { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .field-actions { grid-column: auto; }
  .field-actions .btn { flex: 0 0 auto; }
  .brand-name { max-width: none; }
}
