/* =========================================================
   Threat Landscape — Stylesheet
   Clean, professional, accessible.  No dark hacker aesthetic.
   ========================================================= */

/* ── Custom properties ─────────────────────────────────── */
:root {
  --colour-bg:          #f8fafc;
  --colour-bg-alt:      #f1f5f9;
  --colour-card:        #ffffff;
  --colour-border:      #e2e8f0;
  --colour-border-hover:#cbd5e1;

  --colour-primary:     #1e3a5f;   /* dark navy */
  --colour-primary-mid: #2563eb;   /* blue-600 */
  --colour-accent:      #ea580c;   /* orange-600 — ATT&CK */

  --colour-text:        #1e293b;   /* slate-800 */
  --colour-text-mid:    #475569;   /* slate-600 */
  --colour-text-muted:  #94a3b8;   /* slate-400 */

  --colour-high:        #16a34a;   /* green — high confidence */
  --colour-medium:      #d97706;   /* amber — medium confidence */
  --colour-low:         #dc2626;   /* red — low confidence */
  --colour-cve:         #7c3aed;   /* violet — CVE */
  --colour-malware:     #be185d;   /* pink — malware */
  --colour-country:     #0369a1;   /* sky — country */
  --colour-sector:      #0f766e;   /* teal — sector */

  --shadow-sm:   0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
  --shadow-md:   0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg:   0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;

  --font-sans:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
                 Arial, "Noto Sans", sans-serif;
  --font-mono:   ui-monospace, SFMono-Regular, "SF Mono", Consolas,
                 "Liberation Mono", Menlo, monospace;

  --max-width: 900px;
  --gutter:    1.5rem;
}

/* ── Reset & base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure [hidden] always wins over any display: flex/block rules */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--colour-text);
  background: var(--colour-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--colour-primary-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--colour-primary-mid);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Layout ─────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #0b1527 0%, #102040 55%, #1a3260 100%);
  color: #fff;
  padding: 2.75rem 0 2.25rem;
  border-bottom: 3px solid var(--colour-accent);
  position: relative;
  overflow: hidden;
}
/* Subtle radial glow behind the title */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 120% at 20% 50%, rgba(37,99,235,0.18) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
  justify-content: space-between;
}

.header-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.4rem;
}

.header-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #fff;
}

.header-subtitle {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: #cbd5e1;
}

.header-meta { flex-shrink: 0; text-align: right; }

.updated-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.updated-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.updated-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
}

.stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.stat-pill {
  background: rgba(255 255 255 / 0.08);
  border: 1px solid rgba(255 255 255 / 0.18);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #e2e8f0;
  letter-spacing: 0.01em;
}

/* ── Main content ───────────────────────────────────────── */
.site-main { padding: 2rem 0 3rem; }

.pipeline-notices { margin-bottom: 1.5rem; }
.pipeline-notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  color: #92400e;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  background: var(--colour-card);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Search field with icon */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--colour-text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  background: var(--colour-bg-alt);
  color: var(--colour-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--colour-primary-mid);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}
.search-input::placeholder { color: var(--colour-text-muted); }

/* Clear filters button */
.btn-clear-filters {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--colour-bg-alt);
  color: var(--colour-text-mid);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn-clear-filters:hover {
  border-color: var(--colour-primary-mid);
  color: var(--colour-primary-mid);
  background: var(--colour-card);
}

/* Filter groups row */
.filter-groups-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
/* Separator between groups — visible when they sit side-by-side */
.filter-group + .filter-group {
  padding-left: 1rem;
  border-left: 2px solid var(--colour-border);
}
@media (max-width: 540px) {
  .filter-group + .filter-group {
    padding-left: 0;
    border-left: none;
    padding-top: 0.75rem;
    border-top: 1px solid var(--colour-border);
  }
  .filter-groups-row { flex-direction: column; gap: 0; }
}

.filter-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--colour-text-muted);
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.filter-chip {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--colour-border);
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--colour-card);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.filter-chip:hover { border-color: var(--colour-primary-mid); }
.filter-chip.active {
  background: var(--colour-primary-mid);
  border-color: var(--colour-primary-mid);
  color: #fff;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.2);
}

/* ── Threat list ─────────────────────────────────────────── */
.threat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Threat card ─────────────────────────────────────────── */
.threat-card {
  background: var(--colour-card);
  border: 1px solid var(--colour-border);
  border-left-width: 4px;    /* accent set by JS heatmap */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.18s;
  overflow: hidden;
}
.threat-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--colour-border-hover);
  transform: translateY(-2px);
}

/* Card header */
.card-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.25rem 0;
}

.rank-badge {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--colour-primary); /* overridden by JS heatmap */
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.rank-badge:hover { filter: brightness(1.15); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.rank-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.card-title-block { flex: 1; min-width: 0; }

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--colour-text);
  margin-bottom: 0.4rem;
}
.card-title-link {
  color: inherit;
  text-decoration: none;
}
.card-title-link:hover { color: var(--colour-primary-mid); }

.card-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--colour-text-mid);
}
.meta-separator { color: var(--colour-text-muted); }

.card-score {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--colour-bg-alt);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  min-width: 4.5rem;
  text-align: center;
  cursor: help;
}
.score-value { font-size: 1.1rem; font-weight: 800; color: var(--colour-primary); }
.score-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--colour-text-muted); }

/* Score tier label */
.score-tier {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  margin-top: 0.2rem;
}
.score-tier--high   { background: #f0fdf4; color: var(--colour-high);   border: 1px solid #86efac; }
.score-tier--medium { background: #fffbeb; color: var(--colour-medium); border: 1px solid #fcd34d; }
.score-tier--low    { background: #fef2f2; color: var(--colour-low);    border: 1px solid #fca5a5; }

/* Card body */
.card-body { padding: 0.85rem 1.25rem; }
.card-summary {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--colour-text-mid);
}

/* Badge row */
.badge-row {
  padding: 0 1.25rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--colour-border);
  background: var(--colour-bg-alt);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  text-decoration: none;
}

.badge--attack {
  background: #fff7ed;
  color: var(--colour-accent);
  border: 1px solid #fdba74;
}
.badge--attack:hover { background: #ffedd5; text-decoration: none; }

.badge--cve {
  background: #f5f3ff;
  color: var(--colour-cve);
  border: 1px solid #c4b5fd;
}
.badge--cve:hover { background: #ede9fe; text-decoration: none; }

.badge--malware {
  background: #fdf2f8;
  color: var(--colour-malware);
  border: 1px solid #f9a8d4;
}

.badge--sector {
  background: #f0fdfa;
  color: var(--colour-sector);
  border: 1px solid #99f6e4;
}

.badge--country {
  background: #f0f9ff;
  color: var(--colour-country);
  border: 1px solid #7dd3fc;
}

.badge--source {
  background: var(--colour-bg-alt);
  color: var(--colour-text-mid);
  border: 1px solid var(--colour-border);
}

.badge--company {
  background: #fefce8;
  color: #713f12;
  border: 1px solid #fde68a;
}

/* ── Threat-type badges ──────────────────────────────────── */
/* Match the pill shape and size of .source-badge/.badge exactly */
.threat-type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  /* default (Other / unknown) */
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}
/* Per-type colour variants */
.threat-type-badge--ransomware       { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.threat-type-badge--phishing         { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.threat-type-badge--malware          { background: #fdf2f8; color: #9d174d; border-color: #f9a8d4; }
.threat-type-badge--ddos             { background: #fefce8; color: #854d0e; border-color: #fcd34d; }
.threat-type-badge--data-breach      { background: #f5f3ff; color: #5b21b6; border-color: #c4b5fd; }
.threat-type-badge--apt              { background: #1e293b; color: #cbd5e1; border-color: #475569; }
.threat-type-badge--zero-day         { background: #fff1f2; color: #9f1239; border-color: #fda4af; }
.threat-type-badge--supply-chain     { background: #f0fdf4; color: #14532d; border-color: #86efac; }
.threat-type-badge--vulnerability    { background: #eff6ff; color: #1e40af; border-color: #93c5fd; }
.threat-type-badge--credential-theft { background: #fdf4ff; color: #6b21a8; border-color: #d8b4fe; }
.threat-type-badge--bec              { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.threat-type-badge--cryptojacking    { background: #f0fdfa; color: #134e4a; border-color: #5eead4; }
.threat-type-badge--wiper            { background: #292524; color: #fef3c7; border-color: #78716c; }
.threat-type-badge--web-shell        { background: #f8fafc; color: #334155; border-color: #94a3b8; }
.threat-type-badge--social-engineering { background: #fff7ed; color: #7c2d12; border-color: #fdba74; }
.threat-type-badge--exploitation     { background: #fff1f2; color: #881337; border-color: #fda4af; }
.threat-type-badge--insider-threat   { background: #f8fafc; color: #374151; border-color: #9ca3af; }
.threat-type-badge--mfa-bypass       { background: #fffbeb; color: #78350f; border-color: #fbbf24; }
.threat-type-badge--cloud-attack     { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.threat-type-badge--ot-ics           { background: #fdf4ff; color: #7e22ce; border-color: #d8b4fe; }
.threat-type-badge--infostealer      { background: #fdf2f8; color: #831843; border-color: #f9a8d4; }
.threat-type-badge--botnet           { background: #1c1917; color: #fef3c7; border-color: #57534e; }
.threat-type-badge--watering-hole    { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
.threat-type-badge--typosquatting    { background: #f0f9ff; color: #075985; border-color: #7dd3fc; }
.threat-type-badge--malvertising     { background: #fefce8; color: #713f12; border-color: #fde68a; }
.threat-type-badge--disinformation   { background: #f8fafc; color: #1e3a5f; border-color: #cbd5e1; font-style: italic; }

.source-badge {
  display: inline-block;
  background: var(--colour-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.source-badge--secondary {
  background: var(--colour-bg-alt);
  color: var(--colour-text-mid);
  border: 1px solid var(--colour-border);
}

.corroboration-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--colour-high);
  background: #f0fdf4;
  border: 1px solid #86efac;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.pub-date { font-size: 0.78rem; color: var(--colour-text-muted); }

/* Confidence badges */
.confidence-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.confidence-badge--high   { background: #f0fdf4; color: var(--colour-high);   border: 1px solid #86efac; }
.confidence-badge--medium { background: #fffbeb; color: var(--colour-medium); border: 1px solid #fcd34d; }
.confidence-badge--low    { background: #fef2f2; color: var(--colour-low);    border: 1px solid #fca5a5; }
.confidence-badge--unknown{ background: var(--colour-bg-alt); color: var(--colour-text-muted); border: 1px solid var(--colour-border); }

/* ── Expand toggle ───────────────────────────────────────── */
.expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--colour-text-mid);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.expand-toggle:hover { background: var(--colour-bg); border-color: var(--colour-border-hover); color: var(--colour-text); }
.expand-icon {
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.expand-toggle[aria-expanded="true"] .expand-icon { transform: rotate(180deg); }
.expand-toggle[aria-expanded="true"] .expand-label::before { content: "Hide"; }
.expand-toggle[aria-expanded="false"] .expand-label::before { content: "Show"; }
.expand-label::after { content: " details"; }

/* ── STIX buttons ────────────────────────────────────────── */
.stix-actions { display: flex; gap: 0.4rem; align-items: center; }

.btn-stix {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  line-height: 1;
}

.btn-stix--copy {
  background: var(--colour-primary);
  color: #fff;
  border: 1px solid var(--colour-primary);
}
.btn-stix--copy:hover { background: #1e3a5f; }

.btn-stix--download {
  background: transparent;
  color: var(--colour-primary-mid);
  border: 1px solid var(--colour-primary-mid);
}
.btn-stix--download:hover { background: #eff6ff; text-decoration: none; }

/* ── Detail panel ─────────────────────────────────────────── */
.detail-panel {
  padding: 1.25rem;
  border-top: 1px solid var(--colour-border);
  background: var(--colour-bg);
  animation: slide-down 0.2s ease;
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-section { margin-bottom: 1.25rem; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section--grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.detail-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--colour-text-muted);
  margin-bottom: 0.5rem;
}

.detail-text {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--colour-text-mid);
}

.badge-group { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ATT&CK table */
.attack-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.attack-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  background: var(--colour-bg-alt);
  border: 1px solid var(--colour-border);
  font-weight: 700;
  color: var(--colour-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.attack-table td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--colour-border);
  vertical-align: middle;
}
.attack-link { font-weight: 700; }

/* Attribution list */
.attribution-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.attribution-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.attr-statement { font-size: 0.78rem; color: var(--colour-text-muted); }

/* Supporting sources list */
.supporting-sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.supporting-source-link {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}
.supporting-source-link:hover .badge--source {
  background: var(--colour-primary-mid);
  color: #fff;
}
.supporting-source-url {
  font-size: 0.75rem;
  color: var(--colour-primary-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 38rem;
}
.supporting-source-link:hover .supporting-source-url {
  text-decoration: underline;
}

/* Score breakdown */
.score-grid { display: flex; flex-direction: column; gap: 0.4rem; }
.score-dim {
  display: grid;
  grid-template-columns: 130px 1fr 50px;
  align-items: center;
  gap: 0.5rem;
}
.score-dim-name { font-size: 0.78rem; color: var(--colour-text-mid); }

/* Dimension name in the expanded detail panel — has-explain applied by JS */
.score-dim-name.has-explain {
  cursor: help;
  text-decoration: underline dotted var(--colour-text-muted);
  text-underline-offset: 2px;
  position: relative;
}
.score-dim-name.has-explain::after {
  content: attr(data-explain);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  background: #1e293b;
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.71rem;
  font-weight: 400;
  line-height: 1.55;
  width: 240px;
  white-space: normal;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255 255 255 / 0.08);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.score-dim-name.has-explain:hover::after { opacity: 1; }
.score-bar-track {
  height: 6px;
  background: var(--colour-border);
  border-radius: 999px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: var(--colour-primary-mid);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.score-dim-val { font-size: 0.75rem; color: var(--colour-text-muted); text-align: right; }

/* STIX pre */
.stix-section { }
.stix-pre {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 1rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre;
}

/* Confidence note */
.confidence-note {
  font-size: 0.8rem;
  color: var(--colour-text-muted);
  background: var(--colour-bg-alt);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  line-height: 1.6;
}

/* ── View toggle ─────────────────────────────────────────── */
.view-toggle-bar {
  display: inline-flex;
  background: var(--colour-bg-alt);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-lg);
  padding: 0.3rem;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.1rem;
  border-radius: calc(var(--radius-lg) - 0.3rem);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--colour-text-mid);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: left;
  line-height: 1.25;
}
.view-toggle-btn:hover:not(.active) {
  background: var(--colour-card);
  color: var(--colour-text);
}
.view-toggle-btn.active {
  background: var(--colour-card);
  border-color: var(--colour-border);
  color: var(--colour-text);
  box-shadow: var(--shadow-sm);
}
.view-toggle-btn.active .view-toggle-label {
  color: var(--colour-primary-mid);
}
.view-toggle-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: inherit;
}
.view-toggle-btn.active .view-toggle-icon {
  color: var(--colour-primary-mid);
}
.view-toggle-label {
  font-size: 0.875rem;
  font-weight: 700;
  display: block;
}
.view-toggle-desc {
  font-size: 0.7rem;
  color: var(--colour-text-muted);
  display: block;
}

/* ── No mainstream state ──────────────────────────────────── */
.no-mainstream {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--colour-text-muted);
  font-size: 0.9rem;
}

/* ── No results ──────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--colour-text-muted);
}
.link-btn {
  background: none;
  border: none;
  color: var(--colour-primary-mid);
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--font-sans);
  text-decoration: underline;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--colour-text-muted);
}
.empty-state h2 { margin-bottom: 0.5rem; color: var(--colour-text); }

/* ── Sources section ─────────────────────────────────────── */
.sources-section {
  background: var(--colour-card);
  border-top: 1px solid var(--colour-border);
  padding: 2.5rem 0;
}

.sources-header { margin-bottom: 1.5rem; }
.sources-header .section-heading { margin-bottom: 0.4rem; }
.sources-intro { font-size: 0.875rem; color: var(--colour-text-muted); }

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}

.source-card {
  background: var(--colour-bg);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s;
}
.source-card:hover { border-color: var(--colour-border-hover); }

.source-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.source-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--colour-text);
  line-height: 1.3;
}

/* Credibility badge — three tiers */
.source-cred-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  line-height: 1.6;
}
.source-cred-badge--high {
  background: #f0fdf4;
  color: var(--colour-high);
  border: 1px solid #86efac;
}
.source-cred-badge--med {
  background: #eff6ff;
  color: var(--colour-primary-mid);
  border: 1px solid #93c5fd;
}
.source-cred-badge--std {
  background: var(--colour-bg-alt);
  color: var(--colour-text-muted);
  border: 1px solid var(--colour-border);
}

.source-rationale {
  font-size: 0.72rem;
  color: var(--colour-text-muted);
  line-height: 1.5;
  margin: 0 0 0.45rem;
}

.source-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.source-tag {
  font-size: 0.65rem;
  color: var(--colour-text-muted);
  background: var(--colour-bg-alt);
  border: 1px solid var(--colour-border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

/* Source overflow cards — hidden until expanded */
.source-card--overflow { display: none; }
#sources-grid.expanded .source-card--overflow { display: block; }

/* Sources toggle button */
.sources-toggle-row {
  margin-top: 1rem;
  text-align: center;
}
.sources-toggle-btn {
  background: none;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  padding: 0.45rem 1.1rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--colour-text-mid);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.sources-toggle-btn:hover {
  background: var(--colour-bg-alt);
  border-color: var(--colour-border-hover);
  color: var(--colour-text);
}

@media (max-width: 640px) {
  .sources-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ── Methodology section ─────────────────────────────────── */
.methodology {
  background: var(--colour-bg-alt);
  border-top: 1px solid var(--colour-border);
  padding: 3rem 0;
}
.section-heading {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--colour-text);
  margin-bottom: 1.5rem;
  padding-left: 0.9rem;
  border-left: 4px solid var(--colour-accent);
}
.methodology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
}
.method-card {
  background: var(--colour-card);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.method-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--colour-border-hover);
}
.method-icon {
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.6rem;
  color: var(--colour-primary-mid);
}
.method-icon svg { width: 100%; height: 100%; }
.method-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--colour-text);
}
.method-card p { font-size: 0.82rem; color: var(--colour-text-muted); line-height: 1.6; }

/* ── Disclaimer ──────────────────────────────────────────── */
.disclaimer {
  background: var(--colour-card);
  border-top: 1px solid var(--colour-border);
  padding: 2rem 0;
}
.disclaimer-heading {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--colour-text-muted);
  margin-bottom: 0.75rem;
}
.disclaimer p {
  font-size: 0.82rem;
  color: var(--colour-text-muted);
  line-height: 1.7;
  margin-bottom: 0.5rem;
}
.disclaimer p:last-child { margin-bottom: 0; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  background: #0f172a;
  padding: 1.25rem 0;
}
.site-footer p {
  font-size: 0.78rem;
  color: #64748b;
  text-align: center;
}
.footer-link { color: #94a3b8; }
.footer-link:hover { color: #e2e8f0; }

/* ── Copy toast ──────────────────────────────────────────── */
.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: fade-in-up 0.2s ease;
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Score tooltip popup ─────────────────────────────────── */
.score-tooltip-popup {
  position: fixed;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  min-width: 185px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  pointer-events: auto;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  border: 1px solid rgba(255 255 255 / 0.08);
}

/* Dimension label inside the score popup — dotted underline + sub-tooltip above */
.stt-dim-label {
  cursor: help;
  text-decoration: underline dotted rgba(255 255 255 / 0.35);
  text-underline-offset: 2px;
  position: relative;
}
.stt-dim-label::after {
  content: attr(data-explain);
  position: absolute;
  bottom: calc(100% + 7px);
  right: 0;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.71rem;
  font-weight: 400;
  line-height: 1.55;
  width: 230px;
  white-space: normal;
  box-shadow: 0 6px 20px rgba(0 0 0 / 0.55);
  border: 1px solid rgba(255 255 255 / 0.1);
  z-index: 401;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.stt-dim-label:hover::after { opacity: 1; }
.stt-total {
  font-weight: 700;
  font-size: 0.82rem;
  color: #f1f5f9;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255 255 255 / 0.12);
}
.stt-table { border-collapse: collapse; width: 100%; }
.stt-table tr + tr td { padding-top: 0.2rem; }
.stt-table td { padding: 0.05rem 0; vertical-align: middle; }
.stt-table td:first-child { color: #94a3b8; padding-right: 1rem; }
.stt-table td:last-child {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
}
.stt-bar {
  display: inline-block;
  height: 4px;
  background: #2563eb;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* ── Back to top ─────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--colour-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 99;
  transition: background 0.15s, transform 0.15s;
}
.back-to-top:hover { background: #0f2244; transform: translateY(-2px); }
.back-to-top svg { width: 1.1rem; height: 1.1rem; }

/* ── Responsive adjustments ──────────────────────────────── */
@media (max-width: 640px) {
  :root { --gutter: 1rem; }

  .header-inner { flex-direction: column; align-items: flex-start; }
  .header-meta { text-align: left; }
  .stats-pills { justify-content: flex-start; }
  .updated-badge { align-items: flex-start; }

  .card-header { flex-wrap: wrap; }
  .card-score { display: none; } /* hide score badge on small screens */

  .score-dim { grid-template-columns: 110px 1fr 40px; }

  .attack-table { font-size: 0.75rem; }
  .attack-table th, .attack-table td { padding: 0.3rem 0.4rem; }

  .card-footer { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

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

/* ── Tag hover tooltip ──────────────────────────────────────
   Shared across the cyber and ML/AI pages.
   Positioned by JavaScript; pointer-events:none so the mouse
   moving onto the tooltip does not hide it prematurely.      */
.tag-tooltip {
  position: fixed;
  z-index: 1200;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.55;
  max-width: 270px;
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.10);
  pointer-events: none;
  white-space: normal;
}

/* Badges that carry a tooltip get a subtle underline hint */
.threat-type-badge[data-tip],
.badge[data-tip] {
  cursor: help;
  text-decoration: underline dotted rgba(0, 0, 0, 0.25);
  text-underline-offset: 2px;
}
