/* QERIS base layer: reset, typography, layout primitives and shared components.
   Every value comes from tokens.css. Page stylesheets only add page-specific layout. */

/* Tokens are imported here too, so any page that loads styles.css (including registry pages
   cached before a deploy or published by the scanner) always has the design tokens. */
@import url("/assets/css/tokens.css");

* { box-sizing: border-box; }

html {
  background-color: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 8%, rgba(47, 69, 216, 0.055), transparent 23rem),
    linear-gradient(180deg, #f8f6f0 0%, var(--bg) 46%, #f1eee6 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

a { color: inherit; }

a:focus-visible,
button:focus-visible,
select:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  background: var(--signal);
  color: #fff;
  padding: 9px 13px;
  border-radius: var(--radius-control);
  z-index: calc(var(--z-menu) + 1);
  font-weight: var(--fw-meta);
}

.skip-link:focus { top: 12px; }

/* ---------- Typography scale ---------- */

h1,
h2,
h3 {
  color: var(--text);
  overflow-wrap: break-word;
}

h1 {
  max-width: var(--measure);
  margin: 0 0 16px;
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: var(--fw-h1);
  letter-spacing: var(--ls-h1);
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: var(--fw-h2);
  letter-spacing: var(--ls-h2);
}

h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: var(--fw-h3);
  letter-spacing: var(--ls-h3);
}

.lead,
.page-hero > p,
.hero p {
  font-size: var(--fs-lead);
  line-height: var(--lh-lead);
  color: var(--muted);
}

small { font-size: var(--fs-small); }

.eyebrow,
.kicker {
  color: var(--signal-deep);
  font-size: var(--fs-meta);
  line-height: var(--lh-meta);
  font-weight: var(--fw-meta);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
}

.eyebrow { margin-bottom: 12px; }

/* ---------- Layout primitives ---------- */

.shell {
  width: min(var(--page-max-width), calc(100% - 2 * var(--page-padding)));
  margin-inline: auto;
  position: relative;
}

main { position: relative; }

.section {
  padding-block: var(--section-gap);
  border-top: 1px solid rgba(17, 19, 24, 0.11);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.section h2 { margin: 0; }

.section-head p {
  color: var(--muted);
  max-width: 600px;
  line-height: var(--lh-body);
  font-size: var(--fs-body);
}

/* Page heading block. It is a normal .shell, so its start edge is the same as the
   header, the sections below it and the footer. Only the text measure is limited. */
.page-hero {
  padding-block: var(--hero-pad-top) var(--hero-pad-bottom);
}

.page-hero > * { max-width: var(--measure); }
.page-hero > p { margin: 0; }

.prose { max-width: 880px; }

.prose p,
.prose li {
  color: var(--muted);
  line-height: var(--lh-body);
  font-size: var(--fs-body);
}

.prose h2 { margin-top: 38px; }

/* Home hero: same shell, two columns on wide screens. */
.hero {
  padding-block: var(--hero-pad-top) var(--hero-pad-bottom);
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 48px;
  align-items: start;
}

.hero p {
  max-width: 680px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-control);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  font-size: var(--fs-small);
  font-weight: var(--fw-meta);
  line-height: 1.2;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.btn-primary {
  background: var(--signal);
  color: #fff;
  border-color: var(--signal);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--signal-deep);
  border-color: var(--signal-deep);
}

.btn-secondary { background: rgba(255, 255, 255, 0.58); }

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--signal);
  color: var(--signal-deep);
}

/* ---------- Cards and panels ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
}

.card {
  border: var(--border);
  background: var(--panel-tint);
  border-radius: var(--radius-card);
  padding: 20px;
  min-height: 156px;
  text-decoration: none;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.card:hover,
.card:focus-visible {
  border-color: rgba(47, 69, 216, 0.48);
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.card small {
  color: var(--signal-deep);
  text-transform: uppercase;
  letter-spacing: var(--ls-eyebrow);
  font-size: var(--fs-meta);
  font-weight: var(--fw-meta);
}

.card h3 { margin: 16px 0 7px; }

.card p {
  color: var(--muted);
  margin: 0;
  line-height: var(--lh-body);
  font-size: var(--fs-body);
}

.signal-card {
  border: var(--border);
  border-top: 3px solid var(--signal);
  background: var(--panel-tint);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.score-orbit {
  width: 100%;
  height: 164px;
  margin: 12px auto 18px;
  border-radius: var(--radius-control);
  display: grid;
  place-items: center;
  border: var(--border);
  background: var(--panel);
  position: relative;
  overflow: hidden;
}

.score-orbit strong {
  color: var(--text);
  font-size: var(--fs-stat);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.signal-row { display: flex; gap: 7px; justify-content: center; align-items: center; }
.signal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); }
.signal-line { width: 40px; height: 1px; background: rgba(47, 69, 216, 0.28); }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border: var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--line-soft);
}

.metric {
  background: var(--panel-tint);
  padding: 16px;
  min-height: 104px;
  border-inline-end: var(--border);
  position: relative;
}

.metric:last-child { border-inline-end: 0; }

.metric::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 28px;
  height: 2px;
  background: var(--signal);
}

.metric strong {
  display: block;
  color: var(--signal-deep);
  font-size: var(--fs-stat);
  line-height: 1.1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.metric span {
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.notice {
  border-inline-start: 3px solid var(--signal);
  background: var(--signal-soft);
  padding: 14px 16px;
  color: var(--text-soft);
  border-start-end-radius: var(--radius-control);
  border-end-end-radius: var(--radius-control);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: var(--fs-small);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.rating-pending {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Table component (shared by every data table) ---------- */

.data-table-wrap {
  overflow: auto;
  border: var(--border);
  border-radius: var(--radius-card);
  background: var(--panel-tint);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

/* Wide data tables scroll inside their own wrapper; other tables fit the column. */
.data-table-wrap > table,
.registry-table-wrap > table { min-width: 760px; }

caption {
  text-align: start;
  padding: var(--table-pad-y) var(--table-pad-x);
  color: var(--muted);
  border-bottom: var(--border);
  font-size: var(--fs-small);
}

th,
td {
  text-align: start;
  padding: var(--table-pad-y) var(--table-pad-x);
  border-bottom: var(--border);
  font-size: var(--fs-table);
  line-height: var(--lh-table);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: var(--fw-meta);
  text-transform: uppercase;
  letter-spacing: var(--ls-eyebrow);
  background: var(--table-head-bg);
}

tbody tr:hover { background: rgba(47, 69, 216, 0.035); }

td a {
  text-decoration: none;
  color: var(--signal-deep);
}

td a:hover,
td a:focus-visible { text-decoration: underline; }

/* ---------- Footer fallback (pages without the shared footer) ---------- */

footer {
  padding: 32px 0 46px;
  border-top: 1px solid rgba(17, 19, 24, 0.11);
  color: var(--muted);
  font-size: var(--fs-small);
}

.footer-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

/* ---------- Arabic: never track Arabic letters ---------- */

html[lang="ar"] :is(h1, h2, h3, h4, h5, h6, p, li, td, th, dt, dd, label, small, span, strong, b, em, a, button, div, caption, summary) {
  letter-spacing: 0 !important;
}

html[lang="ar"] .brand strong { letter-spacing: var(--ls-brand) !important; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .signal-card { max-width: 560px; }
  .grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric { border-bottom: var(--border); }
}

@media (max-width: 720px) {
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
  }

  .section-head p { margin: 0; }

  .card { min-height: 0; padding: 18px; }

  .metric-strip { grid-template-columns: 1fr; }
  .metric { min-height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
