/* FRORP frontend — Africa CDC Design System v2.2.
   Loaded after brand/tokens.css. Every colour here resolves through a semantic
   token; no literal outside the palette appears in this file (CONSTRAINTS #4).

   Two rules that shaped this file and are easy to undo by accident:

   1. `--surface-emphasis` is a FILL and is deliberately identical in both
      themes, so it can never be used as a text colour. Green foreground text
      uses `--text-emphasis` (design system, Layer 1 note).
   2. Transitions name longhand properties only. A transitioned
      `background: var(--x)` shorthand does not re-resolve when the theme swaps
      the custom property, so the element stays pinned to the outgoing theme's
      colour (CONSTRAINTS #30). */

/* Tier 3, component tokens. Local exceptions, named for the component that owns
   them. `--text-on-emphasis` is white and is correct on the light theme's AU Red
   fill at 7.56:1, but --action-primary lifts to a pale pink in the dark tier,
   where white measures 2.34:1 and fails. A filled action control therefore needs
   its own foreground token rather than borrowing the on-emphasis one. */
:root { --button-primary-ink: var(--text-on-emphasis); }
[data-theme="dark"] { --button-primary-ink: var(--surface-page); }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body-size);          /* 14px analyst floor */
  line-height: 1.45;
  transition: background-color var(--motion-duration) var(--motion-easing),
              color var(--motion-duration) var(--motion-easing);
}

/* Numbers must not shift as they update. */
table, .stat-figure, .count, time, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- skip link: first focusable element on every page ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  min-height: 44px; display: inline-flex; align-items: center;
  background-color: var(--surface-emphasis); color: var(--text-on-emphasis);
  padding: 12px 16px; font-weight: 700; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- type ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-heading);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: 32px; font-weight: 900; }
h2 { font-size: 24px; font-weight: 900; }
h3 { font-size: 20px; font-weight: 700; }
p { margin: 0 0 12px; text-wrap: pretty; max-width: 70ch; }

.eyebrow {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--action-primary); margin: 0 0 8px;
}

a { color: var(--action-primary); text-decoration: none; }
a:hover { color: var(--surface-emphasis); text-decoration: underline; }

/* ---------- shell ---------- */
.masthead {
  background-color: var(--surface-raised);
  border-bottom: 1px solid var(--border-hairline);
}
.masthead-in {
  max-width: 1280px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
/* Logo top-left, 100px minimum, one icon-width of clear space, no effects. */
.brandmark { display: flex; align-items: center; gap: 12px; text-decoration: none;
              min-height: 44px; }
.brandmark img { width: 132px; height: auto; aspect-ratio: 300 / 97; display: block; }
.brandmark:hover { text-decoration: none; }
.product-name {
  font-family: var(--font-display); font-weight: 900; font-size: 16px;
  color: var(--text-emphasis); letter-spacing: -0.01em;
  padding-left: 12px; border-left: 1px solid var(--border-hairline);
}
.masthead-spacer { margin-left: auto; }

.identity { font-size: 13px; color: var(--text-secondary); text-align: right; }
.identity b, .identity { line-height: 1.35; }
.identity b { color: var(--text-primary); font-weight: 700; display: block; }

.toolbar { display: flex; align-items: center; gap: 8px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--text-secondary); margin: 8px 0 0; }

/* ---------- buttons: 44px target, 8px separation ---------- */
.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  min-height: 44px; padding: 10px 16px;
  border-radius: var(--radius-button);
  border: 1px solid var(--action-primary);
  background-color: var(--action-primary); color: var(--button-primary-ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-decoration: none;
  transition: background-color var(--motion-duration) var(--motion-easing),
              border-color var(--motion-duration) var(--motion-easing),
              color var(--motion-duration) var(--motion-easing);
}
.btn:hover { background-color: var(--action-hover); border-color: var(--action-hover);
             color: var(--button-primary-ink); text-decoration: none; }
.btn:active { opacity: .9; }                 /* no scale change */
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  background-color: transparent; color: var(--action-primary);
}
.btn-secondary:hover { background-color: var(--action-primary); color: var(--button-primary-ink); }

.btn-tertiary {
  background-color: transparent; border-color: transparent; color: var(--action-primary);
}
.btn-tertiary:hover { background-color: transparent; color: var(--action-hover);
                      text-decoration: underline; }

.btn-sm { min-height: 44px; padding: 8px 12px; font-size: 14px; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 14px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 6px;
}
.field .help { font-size: 12px; color: var(--text-secondary); margin: 0 0 6px; }
.field input, .field textarea, .field select {
  font-family: var(--font-body); font-size: 14px; width: 100%;
  min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border-hairline); border-radius: var(--radius-panel);
  background-color: var(--surface-page); color: var(--text-primary);
  transition: border-color var(--motion-duration) var(--motion-easing);
}
.field textarea { min-height: 72px; resize: vertical; }
.field .error-text {
  font-size: 12px; color: var(--status-critical); margin: 6px 0 0; font-weight: 700;
}
.field[data-invalid] input, .field[data-invalid] textarea {
  border: 2px solid var(--status-critical);
}

/* ---------- panels ---------- */
.panel {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);       /* 4px ceiling on panels */
  padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 16px; font-weight: 700; color: var(--text-emphasis);
               font-family: var(--font-display); margin: 0 0 12px; }

/* ---------- tabs: 3px underline, never a filled pill ---------- */
.tabs {
  display: flex; gap: 8px; border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 20px; overflow-x: auto; padding: 0; list-style: none;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 14px;
  font-size: 14px; color: var(--text-primary); text-decoration: none;
  border-bottom: 3px solid transparent; white-space: nowrap;
  transition: border-color var(--motion-duration) var(--motion-easing),
              color var(--motion-duration) var(--motion-easing);
}
.tab:hover { color: var(--action-primary); text-decoration: none; }
.tab[aria-current="page"] {
  border-bottom-color: var(--action-primary);
  color: var(--action-primary); font-weight: 700;
}
.tab .count { color: var(--text-secondary); font-size: 14px; }
.tab[aria-current="page"] .count { color: var(--action-primary); }

/* ---------- data table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-hairline);
              border-radius: var(--radius-panel); background-color: var(--surface-raised); }
table { border-collapse: collapse; width: 100%; }
thead th {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-emphasis);              /* foreground token, not the fill */
  text-align: left; padding: 10px 12px;
  background-color: var(--surface-sunken);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
tbody td {
  padding: 12px; border-bottom: 1px solid var(--border-hairline);
  vertical-align: top; font-size: 14px;
}
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }        /* no vertical rules anywhere */
tbody td a { display: inline-flex; align-items: center; min-height: 44px; }
.cell-sub { display: block; color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

/* ---------- status: colour plus a word, always ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-panel); border: 1px solid; white-space: nowrap;
}
.status-approved  { color: var(--status-stable);   border-color: var(--status-stable); }
.status-submitted { color: var(--text-primary);    border-color: var(--border-hairline);
                    background-color: var(--surface-sunken); }
.status-returned  { color: var(--status-critical); border-color: var(--status-critical); }
.status-rejected  { color: var(--status-critical); border-color: var(--status-critical); }

/* ---------- alert: full 1px border, tinted fill, never a side stripe ---------- */
.alert {
  border: 1px solid; border-radius: var(--radius-panel);
  padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.alert-title { font-weight: 700; margin: 0 0 4px; }
.alert p { margin: 0; max-width: none; }
.alert-critical { border-color: var(--status-critical); color: var(--text-primary); }
.alert-critical .alert-title { color: var(--status-critical); }
.alert-info { border-color: var(--border-hairline); background-color: var(--surface-sunken); }

/* ---------- provenance stamp ---------- */
.provenance {
  font-size: 11px; color: var(--text-secondary); margin: 8px 0 0;
  max-width: none; line-height: 1.5;
}
.provenance .required { color: var(--status-critical); font-weight: 700; }

/* ---------- empty state: a sentence plus the action that fills it ---------- */
.empty { padding: 32px 20px; text-align: center; }
.empty p { margin: 0 auto 12px; color: var(--text-secondary); max-width: 48ch; }

/* ---------- footer: red rule 3px, AU sign-off bottom-left ---------- */
.footer-rule { height: 3px; background-color: var(--action-primary); margin-top: 40px; }
footer {
  background-color: var(--surface-raised);
  padding: 20px 0 32px;
}
.footer-in {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.signoff { font-size: 12px; color: var(--text-secondary); }
.signoff b { display: block; color: var(--text-emphasis); font-family: var(--font-display);
             font-weight: 700; font-size: 13px; }

/* ---------- focus: 3px ring, 2px offset, never removed ---------- */
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

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

@media (max-width: 640px) {
  main, .masthead-in, .footer-in { padding-left: 16px; padding-right: 16px; }
  .masthead-spacer { margin-left: 0; }
  .identity { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
