/* ============================================================
   Observatory report — an A4 document. Paper-white in both site themes
   (it is a document, not UI), and the only thing that prints.
   Above it, a sticky glass toolbar (screen only).
   ============================================================ */

.report-wrap { display: flex; flex-direction: column; gap: var(--s-5); align-items: center; }

/* ---------- toolbar: floats over the paper as you scroll ---------- */
.report-actions {
  position: sticky; top: var(--s-3); z-index: 6;
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; max-width: 860px;
  padding: 8px; padding-inline-start: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: var(--card-rim), var(--shadow-raise);
}
/* over white paper a dark glass turns grey: in the dark theme it stays nearly solid */
html[data-theme="dark"] .report-actions { background: color-mix(in srgb, var(--surface) 94%, transparent); }
.ra-doc { display: flex; align-items: center; gap: var(--s-3); min-width: 0; flex: 1; }
.ra-ico {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
}
.ra-ico .ico { width: 19px; height: 19px; }
.ra-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.ra-text b { color: var(--ink-hi); font-size: var(--fs-small); font-weight: 700; }
.ra-text span { color: var(--ink-dim); font-size: var(--fs-micro); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ra-hint { color: var(--ink-faint); font-size: var(--fs-micro); white-space: nowrap; margin-inline-end: var(--s-2); }
.report-actions .btn { flex: none; }

/* ---------- the sheet ---------- */
.report-sheet {
  --p-ink: #0f1530;
  --p-ink-2: #39425f;
  --p-dim: #5f6884;
  --p-line: #e3e6ef;
  --p-soft: #f4f5fa;
  --p-accent: #3346c0;
  --p-track: #e9ecf6;
  --p-good: #23803a;
  --p-bad: #b8362f;
  --p-pad-x: 60px; --p-pad-top: 0px;
  /* site tokens re-pointed at paper, so shared helpers (icons, units) read on white in dark theme too */
  --ink-hi: var(--p-ink); --ink: var(--p-ink-2); --ink-dim: var(--p-dim); --ink-faint: var(--p-dim);
  --line: var(--p-line); --accent: var(--p-accent);
  width: 100%; max-width: 860px;
  background: #ffffff; color: var(--p-ink-2);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(15, 21, 48, 0.06), 0 30px 80px -20px rgba(4, 6, 14, 0.45), 0 2px 6px rgba(4, 6, 14, 0.12);
  padding: var(--p-pad-top) var(--p-pad-x) 40px;
  font-size: 13.5px; line-height: 1.75;
}
html[lang="en"] .report-sheet { line-height: 1.6; }
.report-sheet .num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.report-sheet bdi.num { unicode-bidi: isolate; direction: ltr; }

/* ---------- cover: the city still (or a survey plate) as a band ---------- */
.rp-cover { border-bottom: 2px solid var(--p-ink); padding-bottom: 22px; margin-bottom: 34px; }
.rp-band {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; justify-content: space-between;
  height: 176px; margin-inline: calc(-1 * var(--p-pad-x));
  padding: 20px var(--p-pad-x) 18px;
  border-radius: 8px 8px 0 0;
  color: var(--stage-ink);
  background-color: var(--stage-bg);
  background-image:
    var(--scrim-up),
    linear-gradient(to bottom, rgba(4, 6, 14, 0.45), transparent 42%),
    var(--still, none),
    radial-gradient(120% 140% at 85% 0%, rgba(154, 168, 255, 0.22), transparent 55%),
    repeating-linear-gradient(0deg, rgba(196, 204, 255, 0.06) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(196, 204, 255, 0.06) 0 1px, transparent 1px 28px),
    linear-gradient(160deg, var(--stage-bg-2), var(--stage-bg));
  /* the still is drawn closer than the workspace masthead above it: the cover is the city centre */
  background-size: cover, cover, auto 160%, cover, auto, auto, cover;
  background-position: center, center, 50% 46%, center, center, center, center;
}
.rp-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13.5px; color: var(--stage-accent); text-shadow: var(--stage-text-shadow); }
.rp-mark { width: 26px; height: 26px; flex: none; }
.rp-mark svg { display: block; width: 100%; height: 100%; }
.rp-city { color: #ffffff; font-size: 36px; font-weight: 800; line-height: 1.2; margin: 2px 0 0; text-shadow: var(--stage-text-shadow); text-wrap: balance; }
html[lang="en"] .rp-city { letter-spacing: -0.01em; }

.rp-meta { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); justify-content: start; gap: 8px 0; margin: 22px 0 0; }
.rp-meta > div { padding-inline: 0 32px; margin-inline-end: 32px; border-inline-end: 1px solid var(--p-line); }
.rp-meta > div:last-child { border-inline-end: 0; margin-inline-end: 0; padding-inline-end: 0; }
.rp-meta dt { font-size: 11.5px; color: var(--p-dim); }
.rp-meta dd { margin: 0; font-weight: 700; color: var(--p-ink); font-size: 15px; }
.rp-meta dd.num { unicode-bidi: isolate; direction: ltr; text-align: start; }
.report-sheet[dir="rtl"] .rp-meta dd.num { text-align: right; }

/* ---------- sections — numbered because a report is read in order ---------- */
.rp-section { margin-top: 34px; }
.rp-h { display: flex; align-items: baseline; gap: 12px; color: var(--p-ink); font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.rp-n { color: var(--p-accent); font-size: 13px; font-weight: 700; min-width: 20px; }
.rp-section h3 { color: var(--p-ink); font-size: 14.5px; font-weight: 800; margin-bottom: 10px; }
.rp-unit { color: var(--p-dim); font-weight: 600; font-size: 11.5px; }
.rp-lead { margin-bottom: 12px; }
.rp-ok { color: var(--p-good); font-weight: 700; }
.rp-dim { color: var(--p-dim); }

.rp-verdict { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-inline-start: 3px solid var(--p-accent); background: var(--p-soft); border-radius: 4px; }
.rp-verdict b { color: var(--p-ink); font-size: 15px; }
.rp-verdict.rb_ready { border-color: var(--p-good); }
.rp-verdict.rb_caveats, .rp-verdict.rb_partial { border-color: #b9821d; }
.rp-verdict.rb_not_ready { border-color: var(--p-bad); }

.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 20px; }
.rp-kpi { display: flex; flex-direction: column; gap: 2px; padding: 2px 18px; border-inline-start: 1px solid var(--p-line); min-width: 0; }
.rp-kpi:first-child { border-inline-start: none; padding-inline-start: 0; }
.rp-kpi > bdi { align-self: flex-start; font-size: 30px; font-weight: 700; color: var(--p-ink); line-height: 1.15; letter-spacing: -0.02em; }
.rp-kpi > bdi small { font-size: 0.55em; font-weight: 600; color: var(--p-dim); letter-spacing: 0; margin-inline-start: 0.06em; }
.rp-kpi > span { font-size: 12px; color: var(--p-dim); }

/* ---------- tables ---------- */
.rp-scroll { max-width: 100%; overflow-x: auto; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.rp-table th { text-align: start; font-size: 11.5px; color: var(--p-dim); font-weight: 700; padding: 6px 8px; border-bottom: 1.5px solid var(--p-ink); white-space: nowrap; }
.rp-table td { padding: 7px 8px; border-bottom: 1px solid var(--p-line); vertical-align: baseline; }
.rp-table .end { text-align: end; }
.rp-table .rp-group td { background: var(--p-soft); color: var(--p-ink); font-weight: 800; font-size: 12px; padding-block: 5px; }
.rp-table .rp-ind { color: var(--p-ink); }
.rp-val { color: var(--p-ink); font-weight: 700; white-space: nowrap; }
.rp-table td.nil { color: #b3b9cc; }
.rp-good { color: var(--p-good); font-weight: 700; }
.rp-bad { color: var(--p-bad); font-weight: 700; }
.rp-flat { color: var(--p-ink-2); font-weight: 600; }

/* quality: colour only in the dot; awaiting data is a task, not an alarm */
.rp-q { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rp-q::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--q, #9aa1ba); }
.rp-q[data-q="validated"] { --q: #2f9e4f; }
.rp-q[data-q="estimated"] { --q: #c9922e; }
.rp-q[data-q="pending"] { --q: #7c5cd6; }
.rp-q[data-q="missing"], .rp-q[data-q="blocked"] { --q: transparent; color: var(--p-dim); }
.rp-q[data-q="missing"]::before, .rp-q[data-q="blocked"]::before { box-shadow: inset 0 0 0 1.5px #c9922e; }

/* ---------- district rankings: neutral accent bars on a shared scale ---------- */
.rp-dist + .rp-dist { margin-top: 26px; }
.rp-dist-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; }
.rp-sub { font-size: 11.5px; color: var(--p-dim); font-weight: 700; margin-bottom: 4px; }
.rp-bar-row { display: grid; grid-template-columns: 20px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, auto); gap: 10px; align-items: center; padding: 3px 0; font-size: 12.5px; }
.rp-bar-row .rk { color: var(--p-dim); font-size: 11px; }
.rp-bar-row .rn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--p-ink); }
.rp-bar-row .rb { height: 6px; background: var(--p-track); border-radius: 99px; overflow: hidden; }
.rp-bar-row .rb i { display: block; height: 100%; border-radius: inherit; background: var(--p-accent); }
.rp-low .rb i { background: color-mix(in srgb, var(--p-accent) 55%, #ffffff); }
.rp-bar-row .rv { font-weight: 700; color: var(--p-ink); text-align: end; min-width: 6ch; }

.rp-list { margin: 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; }
.rp-list b { color: var(--p-ink); margin-inline-end: 6px; }
.rp-foot { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--p-line); font-size: 11px; color: var(--p-dim); }

/* dates/numbers keep their own LTR order inside Arabic text */
.rp-foot bdi { unicode-bidi: isolate; direction: ltr; }

/* ---------- smaller screens ---------- */
@media screen and (max-width: 1180px) {
  .ra-hint { display: none; }
}
@media screen and (max-width: 980px) {
  .report-actions { position: static; }   /* the shell's own top bar is sticky here */
}
@media screen and (max-width: 760px) {
  .report-wrap { gap: var(--s-4); }
  .report-actions { flex-wrap: wrap; padding: 10px; }
  .ra-doc { flex-basis: 100%; }
  .report-actions .btn { flex: 1; justify-content: center; }
  .report-sheet { --p-pad-x: 20px; padding-bottom: 28px; }
  .rp-band { height: 148px; padding-block: 16px 14px; }
  .rp-city { font-size: 28px; }
  .rp-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; }
  .rp-meta > div { border: 0; margin: 0; padding: 0; }
  .rp-kpis { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .rp-kpi:nth-child(3) { border-inline-start: none; padding-inline-start: 0; }
  .rp-dist-cols { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
/* the results table stacks: indicator on top, its figures in a labelled line below */
@media screen and (max-width: 600px) {
  .rp-results thead { display: none; }
  .rp-results, .rp-results tbody, .rp-results .rp-group, .rp-results .rp-group td { display: block; }
  .rp-results tr:not(.rp-group) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 10px 2px; border-bottom: 1px solid var(--p-line); }
  .rp-results tr:not(.rp-group) td { padding: 0; border: 0; }
  .rp-results td.rp-ind { flex-basis: 100%; font-weight: 600; }
  .rp-results td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 600; color: var(--p-dim); line-height: 1.4; }
  .rp-results td.nil { display: none; }
  .rp-results tr:not(.rp-group) { align-items: flex-end; }
  .rp-results td:has(.rp-q)::before { display: none; }
  .rp-gaps, .rp-gaps thead, .rp-gaps tbody { display: block; }
  .rp-gaps tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 10px 2px; border-bottom: 1px solid var(--p-line); }
  .rp-gaps thead tr { padding-block: 0 6px; border-bottom: 1.5px solid var(--p-ink); }
  .rp-gaps th { padding: 0; border: 0; }
  .rp-gaps th:nth-child(2) { display: none; }
  .rp-gaps td { padding: 0; border: 0; }
  .rp-gaps td.rp-ind { font-weight: 600; }
  .rp-gaps td:nth-child(2) { grid-row: 2; color: var(--p-dim); font-size: 12px; }
  .rp-gaps td.end { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 16px; font-weight: 700; color: var(--p-ink); }
}

/* ---------- print: only the sheet ----------
   Everything that neither is the sheet nor contains it disappears, whatever the shell
   is called; its ancestors lose their layout. */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  :root { color-scheme: light !important; }   /* a dark canvas would paint the page margins */
  html, body { background: #fff !important; }
  body:has(.report-sheet) :not(:has(.report-sheet)):not(.report-sheet):not(.report-sheet *) { display: none !important; }
  body:has(.report-sheet) :has(.report-sheet) {
    display: block !important; position: static !important; margin: 0 !important; padding: 0 !important;
    max-width: none !important; width: auto !important; min-height: 0 !important; height: auto !important;
    border: 0 !important; background: none !important; box-shadow: none !important;
    transform: none !important; animation: none !important; overflow: visible !important;
  }
  body:has(.report-sheet) :has(.report-sheet)::before, body:has(.report-sheet) :has(.report-sheet)::after { display: none !important; }
  .report-sheet { border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; --p-pad-x: 0px; }
  .rp-band { margin-inline: 0; padding-inline: 22px; border-radius: 6px; height: 150px; }
  .rp-cover, .rp-verdict, .rp-kpis, .rp-dist, .rp-table tr, .rp-list li { break-inside: avoid; }
  .rp-h, .rp-lead, .rp-section h3 { break-after: avoid; }
  .rp-table thead { display: table-header-group; }
  .rp-band *, .rp-brand, .rp-city { text-shadow: none; }   /* blurred shadows print as boxes */
  .rp-scroll { overflow: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
