/* SA Acts Intelligence — colour system is the six official South African
   flag colours: black, gold, green, white, red (chili), blue. Black and
   white do real structural work here (ink/ground), not just decoration —
   the four accents are gold/green/red/blue. Light-theme accents sit close
   to the literal flag hex values; dark-theme accents are brighter,
   contrast-safe variants of the same four hues (tested against WCAG AA on
   every background this session). */

:root {
  --bg-primary: #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-card: #f0f2f5;
  --border-color: #d0d7de;
  --text-primary: #1f2328;   /* flag black */
  --text-secondary: #57606a;
  --text-muted: #5d6570;
  --accent-blue: #002395;
  --accent-green: #007A4D;
  --accent-gold: #9a6700;
  --accent-red: #C6302A;
  --accent: var(--accent-blue);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 6px 20px rgba(0, 0, 0, 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-primary: #0d1017;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --border-color: #30363d;
    --text-primary: #e6edf3;  /* flag white */
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #4C6FFF;
    --accent-green: #1FBE7A;
    --accent-gold: #FFB612;
    --accent-red: #F04438;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #0d1017;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-blue: #4C6FFF;
  --accent-green: #1FBE7A;
  --accent-gold: #FFB612;
  --accent-red: #F04438;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] { color-scheme: light; }

@view-transition { navigation: auto; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; }

/* ── Site header ────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 88px; width: auto; }
/* Logo swap: same three-block pattern as the token overrides above
   (explicit [data-theme] wins over prefers-color-scheme, which wins over
   the light-mode default) — proven working pattern, same as the fix
   applied to the old actintel earlier tonight. */
.brand__logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand__logo-light { display: none; }
  :root:not([data-theme="light"]) .brand__logo-dark { display: block; }
}
:root[data-theme="dark"] .brand__logo-light { display: none; }
:root[data-theme="dark"] .brand__logo-dark { display: block; }
.brand__slogan {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.site-nav a:hover { background: var(--bg-card); color: var(--text-primary); }
.site-nav a[aria-current="page"] { color: var(--accent-blue); background: var(--bg-card); }

/* ── Page layout ────────────────────────────────────────────────────── */
.page-header { padding: 28px 0 20px; }
.page-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.page-subtitle { color: var(--text-secondary); font-size: 13.5px; margin: 0; }

/* ── Stat tiles (Dashboard) ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin: 20px 0 32px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-card b {
  display: block;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-card i {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Search box ─────────────────────────────────────────────────────── */
.search-box { position: relative; margin: 0 0 8px; max-width: 640px; }
.search-box input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent-blue); }

/* ── Cards / results ────────────────────────────────────────────────── */
.section-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 28px 0 12px;
}
.results { display: flex; flex-direction: column; gap: 10px; }

.card {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s;
}
.card:hover { border-color: var(--accent-blue); }
.card__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card__title { font-weight: 600; font-size: 15.5px; margin: 0; color: var(--text-primary); }
.card__citation { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }
.card__summary {
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; margin: 8px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--text-muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; font-weight: 600; flex: none;
}
.pill--in-force { background: color-mix(in srgb, var(--accent-green) 14%, transparent); color: var(--accent-green); }
.pill--repealed { background: color-mix(in srgb, var(--accent-red) 14%, transparent); color: var(--accent-red); }
.pill--amended { background: color-mix(in srgb, var(--accent-gold) 14%, transparent); color: var(--accent-gold); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 40px 0; }
.loading { text-align: center; color: var(--text-muted); font-size: 12px; padding: 30px 0; }

.error-state { text-align: center; padding: 30px 0; }
.error-state__msg { color: var(--text-secondary); font-size: 13px; margin: 0 0 12px; }
.error-state__retry {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent-blue); background: transparent; color: var(--accent-blue);
  cursor: pointer;
}
.error-state__retry:hover { background: var(--accent-blue); color: #fff; }

/* ── Pagination ─────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 28px 0; }
.pagination button, .pagination span {
  font-family: inherit; font-size: 13px; padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-primary); cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .pagination__current { color: var(--text-muted); border: none; background: none; }

/* ── Act detail / reader ────────────────────────────────────────────── */
.detail__back {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted);
  text-decoration: none; margin-bottom: 20px;
}
.detail__back:hover { color: var(--accent-blue); }
.detail__head { display: flex; flex-direction: column; gap: 10px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.detail__title { font-weight: 700; font-size: 24px; margin: 0; }
.detail__meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.detail__summary { font-size: 13.5px; line-height: 1.7; color: var(--text-secondary); max-width: 68ch; }

.pdf-link { color: var(--accent-blue); text-decoration: none; font-weight: 600; border-bottom: 1px solid transparent; }
.pdf-link:hover { border-bottom-color: var(--accent-blue); }

.timeline { margin: 24px 0; display: flex; flex-direction: column; gap: 2px; }
.timeline__item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border-color); font-size: 12.5px; }
.timeline__item:last-child { border-bottom: none; }
.timeline__date { color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; width: 90px; }
.timeline__body { flex: 1; }
.timeline__body b { font-weight: 600; }

.provisions { display: flex; flex-direction: column; gap: 14px; }
.provision { border-left: 2px solid var(--border-color); padding-left: 14px; }
.provision__ref { font-size: 11px; color: var(--accent-blue); font-weight: 600; font-variant-numeric: tabular-nums; }
.provision__title { font-weight: 600; font-size: 14px; margin: 2px 0 6px; }
.provision__content { font-size: 12.5px; line-height: 1.7; max-width: 100%; overflow-x: auto; }
.provision__line { margin-bottom: 6px; }
.provision__line:last-child { margin-bottom: 0; }
.provision__table { border-collapse: collapse; margin: 6px 0 10px; font-size: 12px; }
.provision__table td { padding: 3px 10px 3px 0; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.provision__table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.provision__table tr:last-child td { border-bottom: none; }

@keyframes provision-highlight {
  from { background: color-mix(in srgb, var(--accent-blue) 10%, transparent); }
  to { background: transparent; }
}
.provision--highlight { animation: provision-highlight 2.5s ease-out; }

.flag {
  display: inline-block; font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 700; padding: 2px 6px; border-radius: 999px; margin-left: 4px; cursor: default;
}
.flag--repealed { background: color-mix(in srgb, var(--accent-red) 14%, transparent); color: var(--accent-red); }
.flag--amended { background: color-mix(in srgb, var(--accent-gold) 14%, transparent); color: var(--accent-gold); }

/* ── Role select (Check Exposure) ──────────────────────────────────── */
.role-select { display: flex; align-items: center; gap: 8px; margin: 0 0 24px; font-size: 13px; color: var(--text-secondary); }
.role-select select {
  font-family: inherit; font-size: 13px; padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-primary);
}

/* ── Obligation cards / penalty rows ────────────────────────────────── */
.obligation-card, .penalty-row {
  display: block; font-size: 12.5px; line-height: 1.6; color: var(--text-secondary);
  text-decoration: none; padding: 8px 10px; border-radius: var(--radius-sm);
  border-left: 2px solid var(--border-color); margin-bottom: 6px;
}
a.obligation-card:hover, a.penalty-row:hover { border-left-color: var(--accent-blue); background: var(--bg-card); }
.penalty-row__figures { font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.penalty-row__text { color: var(--text-muted); }

/* ── Doors (Check Exposure) ─────────────────────────────────────────── */
.doors { display: flex; flex-direction: column; gap: 20px; }
.door {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 18px 20px;
}
.door__title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 10px; }
.door--must .door__title { color: var(--accent-red); }
.door--must-not .door__title { color: var(--accent-red); }
.door--consequences .door__title { color: var(--accent-gold); }
.door--escape .door__title { color: var(--accent-green); }
.door__items { display: flex; flex-direction: column; gap: 10px; }
.severity-badge {
  display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
}
.severity-badge--high { background: color-mix(in srgb, var(--accent-red) 16%, transparent); color: var(--accent-red); }
.severity-badge--medium { background: color-mix(in srgb, var(--accent-gold) 16%, transparent); color: var(--accent-gold); }
.severity-badge--low { background: color-mix(in srgb, var(--accent-green) 16%, transparent); color: var(--accent-green); }
.integrity-flags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.integrity-flag {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border-color);
}

footer { text-align: center; font-size: 10.5px; color: var(--text-muted); margin-top: 60px; line-height: 1.7; }

@media (max-width: 700px) {
  .site-header { padding: 14px 16px; }
  .wrap { padding: 0 16px 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
