/* ==========================================================================
   ecolod portal — stylesheet
   --------------------------------------------------------------------------
   * CSS custom properties drive both light and dark mode; the inline SVG
     charts read the same variables, so they follow the theme automatically.
   * Only logical properties (inline-start/end, padding-inline, …) are used,
     so the Arabic RTL build needs no separate stylesheet.
   * The font stack is injected per language via the `--font-stack` variable
     set on <html>, so no script has to sniff the language.
   ========================================================================== */

:root {
  --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #1f2328;
  --text-muted: #63676c;
  --accent: #2b6cb0;
  --accent-soft: #eef4fb;
  --forecast: #c53030;
  --focus: #f0a500;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --border: #2f353b;
    --text: #e6e8ea;
    --text-muted: #a2a8ae;
    --accent: #7bb0e8;
    --accent-soft: #1e2833;
    --forecast: #ff8a80;
    --focus: #ffc94d;
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  font-family: var(--font-stack);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  max-width: 60rem;
  margin-inline: auto;
  padding: 1.25rem;
}

/* ---------------------------------------------------------- accessibility */

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { inset-inline-start: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

/* ----------------------------------------------------------------- chrome */

header.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding-block-end: 0.75rem;
  border-block-end: 2px solid var(--accent);
  margin-block-end: 1.25rem;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

nav.langsw ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}
nav.langsw a { color: var(--text-muted); text-decoration: none; }
nav.langsw a[aria-current="true"] { color: var(--accent); font-weight: 700; }

h1 {
  font-size: 1.6rem;
  border-block-end: 1px solid var(--border);
  padding-block-end: 0.35rem;
}
h2 { font-size: 1.15rem; margin-block-start: 2rem; color: var(--accent); }

a { color: var(--accent); }

.breadcrumb { color: var(--text-muted); font-size: 0.82rem; margin-block-end: 0.6rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "›"; margin-inline-end: 0.35rem; color: var(--border); }
.breadcrumb a { color: var(--text-muted); }

/* ----------------------------------------------------------------- tables */

table {
  border-collapse: collapse;
  width: 100%;
  margin-block: 0.75rem;
  background: var(--surface);
}
caption {
  caption-side: top;
  text-align: start;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding-block-end: 0.35rem;
}
th, td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: end; }
th { background: var(--accent-soft); text-align: center; }
th[scope="row"], td.text { text-align: start; }
td.year, th.year { text-align: center; width: 5rem; }
.forecast { color: var(--forecast); }
tbody tr:hover { background: var(--accent-soft); }

/* ------------------------------------------------------------------ cards */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.6rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
}
.card .label { font-size: 0.85rem; }
.card .value { font-size: 1.25rem; font-weight: 700; margin-block-start: 0.2rem; }
.card .value.empty { color: var(--text-muted); }

/* ------------------------------------------------------------------ chart */

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem;
  overflow-x: auto;
}
.chart { width: 100%; height: auto; font-size: 11px; font-family: var(--font-stack); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); }
.chart-empty { fill: var(--text-muted); }
.chart-line { stroke: var(--accent); stroke-width: 2; }
.chart-line--forecast { stroke: var(--forecast); stroke-dasharray: 5 3; }
.chart-dot { fill: var(--accent); }
.chart-dot--forecast { fill: var(--forecast); }

/* Charts are mirrored back to LTR in RTL layouts: a time axis always runs
   left-to-right, even in Arabic typography. */
[dir="rtl"] .chart-wrap { direction: ltr; }

/* -------------------------------------------------------- range / toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block: 0.6rem;
  padding: 0;
  list-style: none;
}
.toolbar a {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
  font-size: 0.82rem;
}
.toolbar a[aria-current="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.is-loading { opacity: 0.55; transition: opacity 120ms ease-in; }

/* ----------------------------------------------------------------- search */

.search { margin-block: 1rem; }
.search input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.search-results { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.search-results li { padding: 0.2rem 0; }
.search-results .kind { color: var(--text-muted); font-size: 0.78rem; margin-inline-start: 0.4rem; }

/* No JS: the search box is useless, so hide it and rely on the full lists. */
html:not(.js) .search { display: none; }

.note { color: var(--text-muted); font-size: 0.8rem; margin-block-start: 0.4rem; }
.defn {
  background: var(--accent-soft);
  border-inline-start: 3px solid var(--accent);
  padding: 0.6rem 0.9rem;
  margin-block: 0.75rem;
  font-size: 0.9rem;
}
.lod-links { display: flex; flex-wrap: wrap; gap: 0.9rem; padding: 0; list-style: none; font-size: 0.85rem; }

footer.site {
  border-block-start: 1px solid var(--border);
  margin-block-start: 2.5rem;
  padding-block-start: 0.75rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

@media print {
  header.site nav, .toolbar, .search, .skip-link { display: none; }
  body { max-width: none; }
}

/* Country flags.
   `vertical-align: middle` keeps the flag on the text baseline in scripts with
   very different x-heights (Lao and Thai ascenders sit far higher than Latin);
   the 1px border keeps white flags (JP, PL) from vanishing on a white page. */
.flag {
  width: 1.5em;
  height: auto;
  margin-inline-end: 0.4em;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.flag-lg {
  width: 2.2em;
}
