/* ── coverage page ──────────────────────────────────────────── */

.cov-page {
  /* Wants more room than the frame gives; clamped by .frame's --measure in
     practice, so this only bites on viewports narrower than the frame. */
  max-width: min(1640px, calc(100vw - 3rem));
  margin: 0 auto;
}
@media (max-width: 880px) {
  .cov-page { max-width: 100%; }
}

.cov-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.6rem;
}
.cov-head h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.cov-head .sub {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0;
  max-width: 64ch;
}

/* filter + stat strip */
.cov-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.cov-bar form {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.cov-bar form label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cov-bar select {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.38em 1.8em 0.38em 0.7em;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% + 1px), calc(100% - 9px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.cov-bar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.cov-bar .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}
.cov-bar .stats b {
  color: var(--ink-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 0.3em;
}

/* legend */
.cov-legend {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.cov-legend .swatches {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cov-legend .sw {
  width: 28px;
  height: 14px;
  border-right: 1px solid var(--rule);
}
.cov-legend .sw:last-child { border-right: 0; }

/* Heat fills — a monochrome indigo ramp, tokenized because the light values
   invert badly: in dark mode the palest step (#e7e9fb) is near-white, and the
   tile text is near-white too, so the count on the lightest cells would have
   vanished entirely.

   The dark ramp runs the other way, from a near-black indigo up to a bright
   one. Every step was contrast-checked against the text it carries and clears
   WCAG AA; the light values are unchanged. */
:root {
  --cov-1-bg: #e7e9fb; --cov-1-fg: var(--ink);
  --cov-2-bg: #c8caf2; --cov-2-fg: var(--ink);
  --cov-3-bg: #9a99e0; --cov-3-fg: var(--ink);
  --cov-4-bg: #6962cf; --cov-4-fg: #fff;
  --cov-5-bg: #3a2da6; --cov-5-fg: #fff;
  /* The gap marker's hatching and the scroll-edge shadow both need to be a
     tint of the *opposite* end of the scale from the surface they sit on. */
  --cov-gap-1: rgba(197, 48, 48, 0.06);
  --cov-gap-2: rgba(197, 48, 48, 0.12);
  --cov-gap-3: rgba(197, 48, 48, 0.45);
  --cov-edge: rgba(12, 14, 18, 0.05);
  --cov-lift: rgba(12, 14, 18, 0.22);
  --cov-stage-tint: rgba(67, 56, 202, 0.04);
}
:root[data-theme="dark"] {
  --cov-1-bg: #1a1c38; --cov-1-fg: var(--ink);
  --cov-2-bg: #262a5c; --cov-2-fg: var(--ink);
  --cov-3-bg: #383a85; --cov-3-fg: var(--ink);
  --cov-4-bg: #4f4ab5; --cov-4-fg: #fff;
  --cov-5-bg: #6d66df; --cov-5-fg: #fff;
  --cov-gap-1: rgba(255, 138, 128, 0.10);
  --cov-gap-2: rgba(255, 138, 128, 0.18);
  --cov-gap-3: rgba(255, 138, 128, 0.50);
  --cov-edge: rgba(0, 0, 0, 0.35);
  --cov-lift: rgba(0, 0, 0, 0.55);
  --cov-stage-tint: rgba(157, 149, 245, 0.07);
}

/* Selectors are compound so they win against the generic `.cov-tile`
   background defined further down. */
.cov-tile.cov-1, .cov-legend .sw.cov-1 { background: var(--cov-1-bg); color: var(--cov-1-fg); }
.cov-tile.cov-2, .cov-legend .sw.cov-2 { background: var(--cov-2-bg); color: var(--cov-2-fg); }
.cov-tile.cov-3, .cov-legend .sw.cov-3 { background: var(--cov-3-bg); color: var(--cov-3-fg); }
.cov-tile.cov-4, .cov-legend .sw.cov-4 { background: var(--cov-4-bg); color: var(--cov-4-fg); }
.cov-tile.cov-5, .cov-legend .sw.cov-5 { background: var(--cov-5-bg); color: var(--cov-5-fg); }
/* gap marker — what an empty cell looks like in "show missing" mode */
.cov-tile.cov-0 {
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--cov-gap-1) 4px 8px);
  border: 1px dashed var(--cov-gap-3);
  color: var(--sev-critical);
}
.cov-tile.cov-0:hover {
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--cov-gap-2) 4px 8px);
  border-color: var(--sev-critical);
}
.cov-legend .sw.cov-0 {
  background: repeating-linear-gradient(135deg, transparent 0 3px, var(--cov-gap-3) 3px 6px);
}

/* toggle (Show gaps) */
.cov-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45em 0.85em;
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color 100ms ease, color 100ms ease, background 100ms ease;
}
.cov-toggle:hover { border-color: var(--ink-soft); }
.cov-toggle input {
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--ink-soft);
  border-radius: 3px;
  background: var(--bg-elev);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
}
.cov-toggle input::before {
  content: "";
  width: 8px;
  height: 8px;
  transform: scale(0);
  transition: transform 100ms ease;
  background: #fff;
  clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 20%, 84% 6%, 38% 70%);
}
/* The tick sits on --sev-critical, which lightens to a coral in dark mode —
   a white tick on it all but disappears. */
:root[data-theme="dark"] .cov-toggle input::before { background: var(--bg); }
.cov-toggle input:checked {
  background: var(--sev-critical);
  border-color: var(--sev-critical);
}
.cov-toggle input:checked::before { transform: scale(1); }
.cov-toggle:has(input:checked) {
  color: var(--sev-critical);
  border-color: var(--sev-critical);
  background: var(--sev-critical-bg);
}
.cov-toggle .hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.cov-toggle:has(input:checked) .hint { color: var(--sev-critical); opacity: 0.7; }

/* ── matrix grid ────────────────────────────────────────────── */

.cov-matrix-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow-x: auto;
  overflow-y: visible;
  /* hint that horizontal scroll is available */
  background-image:
    linear-gradient(to right, var(--bg-elev) 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), var(--bg-elev) 70%),
    linear-gradient(to right, var(--cov-edge), rgba(255,255,255,0)),
    linear-gradient(to left,  var(--cov-edge), rgba(255,255,255,0));
  background-position: left center, right center, left center, right center;
  background-size: 24px 100%, 24px 100%, 8px 100%, 8px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.cov-matrix {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 178px;
  gap: 0;
  min-width: 100%;
}

.cov-col {
  border-right: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cov-col:last-child { border-right: 0; }

.cov-col-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--rule);
  padding: 0.7rem 0.75rem 0.65rem;
}
.cov-col-head .tactic-name {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.84rem;
  letter-spacing: -0.005em;
  color: var(--ink-strong);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cov-col-head .tactic-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}
.cov-col-head .tactic-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.cov-col-head .tactic-meta b {
  color: var(--ink-strong);
  font-weight: 600;
}
.cov-col-head .tactic-meta .label {
  color: var(--ink-faint);
  letter-spacing: 0.03em;
}

.cov-col-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
}

/* The tile carries two links — technique and count, see the comment in
   `_coverage_matrix.html`. Anchors cannot nest, so the tid's hit area is
   stretched over the whole tile with a pseudo-element and the count is lifted
   above it. Hover and the shading stay on the tile itself, so a tile still
   reads and behaves as one object. */
.cov-tile {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  align-items: baseline;
  padding: 0.45rem 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 100ms ease, box-shadow 100ms ease, filter 100ms ease;
  border: 1px solid transparent;
}
.cov-tile:hover {
  text-decoration: none;
  color: inherit;
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 4px 14px -8px var(--cov-lift);
  border-color: var(--accent);
}
.cov-tile.is-sub { margin-left: 14px; position: relative; }
.cov-tile.is-sub::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--rule);
}
.cov-tile .tid {
  grid-row: 1;
  grid-column: 1;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: currentColor;
  letter-spacing: 0.01em;
  text-decoration: none;
}
/* The stretched hit area. `inset: 0` covers the tile without covering the
   is-sub connector, which sits at a negative offset outside it.

   `a.tid` itself must stay unpositioned or the pseudo-element would resolve
   against the few characters of the id instead of the tile. Its z-index still
   applies: grid items paint in document order as though they were `z-index: 0`,
   so without this the name — a later grid item — sits on top of the hit area
   and the tile's biggest text is the one place the link doesn't work. */
a.tid { z-index: 1; }
a.tid::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
/* Keyboard focus lands on the small id text, so the ring is drawn on the tile
   it actually activates. */
.cov-tile:has(a.tid:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
/* Retired ids sit in the column their replacement occupies. Dimmed and
   dashed so a stale tag never reads as current ATT&CK, but still legible —
   the rules behind it are real coverage. */
.cov-tile.is-retired {
  border-style: dashed;
  border-color: var(--rule);
  opacity: 0.72;
}
.cov-tile.is-retired:hover { opacity: 1; border-color: var(--accent); }
.cov-tile .tid .retired {
  margin-left: 0.35em;
  font-weight: 400;
  font-size: 0.92em;
  opacity: 0.75;
}
.cov-tile .count {
  grid-row: 1;
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: currentColor;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
/* Above the tid's stretched hit area, and given its own padding so the number
   is a target in its own right rather than a few pixels of digit. The negative
   margin keeps the padding from changing the tile's layout; it stays inside the
   tile's own 0.55rem of horizontal padding. */
a.count {
  z-index: 2;
  text-decoration: none;
  margin: -0.35rem -0.45rem;
  padding: 0.35rem 0.45rem;
}
a.count:hover { opacity: 1; text-decoration: underline; text-underline-offset: 2px; }
.cov-tile .tname {
  grid-row: 2;
  grid-column: 1 / -1;
  font-size: 0.78rem;
  line-height: 1.25;
  color: currentColor;
  opacity: 0.82;
  margin-top: 0.18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cov-col-empty {
  padding: 1.1rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  text-align: center;
}

/* ── unattributed bucket ───────────────────────────────────── */

.cov-unattr {
  margin-top: 2rem;
  padding: 1.25rem 1.3rem 1.4rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.cov-unattr .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.cov-unattr h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-strong);
  margin: 0;
}
.cov-unattr .count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
}
.cov-unattr .note {
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin: 0 0 0.85rem;
  max-width: 70ch;
}
.cov-unattr .tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px;
}

/* empty state */
.cov-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  background: var(--bg-elev);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

/* ── fullscreen stage ──────────────────────────────────────── */

.cov-stage { position: relative; }

.fs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding: 0.45em 0.8em;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 100ms ease, color 100ms ease, background 100ms ease, transform 80ms ease;
}
.fs-toggle:hover { border-color: var(--accent); color: var(--accent); }
.fs-toggle:active { transform: scale(0.98); }
.fs-toggle svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.7; fill: none; }
.fs-toggle .kbd {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding: 0.05em 0.4em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--bg-elev);
  line-height: 1.3;
}
/* button label/icon swap between modes */
.fs-toggle .label-exit, .fs-toggle .icon-exit, .fs-toggle .kbd { display: none; }
.cov-stage.is-fullscreen .fs-toggle .label-fs,
.cov-stage.is-fullscreen .fs-toggle .icon-fs { display: none; }
.cov-stage.is-fullscreen .fs-toggle .label-exit,
.cov-stage.is-fullscreen .fs-toggle .icon-exit,
.cov-stage.is-fullscreen .fs-toggle .kbd { display: inline-flex; }
.cov-stage.is-fullscreen .fs-toggle {
  color: var(--sev-critical);
  border-color: var(--cov-gap-3);
  background: var(--sev-critical-bg);
}
.cov-stage.is-fullscreen .fs-toggle:hover {
  border-color: var(--sev-critical);
  color: var(--sev-critical);
}
.cov-stage.is-fullscreen .fs-toggle .kbd {
  color: var(--sev-critical);
  border-color: var(--cov-gap-3);
  background: var(--cov-gap-1);
}

/* The takeover. Background drops a half-tone behind the matrix so the
   indigo heat scale reads sharper. Animation runs on entry; on exit, the
   stage flicks back to normal flow without animation.

   `opacity: 1` is explicit because the article uses `class="reveal"` from
   base.html, whose `.reveal > * { opacity: 0; animation: rise ... forwards }`
   wins when no animation is running here. `forwards` on `fs-enter` keeps
   the final keyframe state once the entry animation ends. */
.cov-stage.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 90;
  background:
    radial-gradient(80% 60% at 50% 0%, var(--cov-stage-tint), transparent 70%),
    var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.9rem 1.25rem 1.25rem;
  overflow: hidden;
  opacity: 1;
  animation: fs-enter 280ms cubic-bezier(.2,.7,.2,1) forwards;
}
/* Server-rendered: skip the entry animation when the page loads with fs=1. */
.cov-stage.is-fullscreen.is-initial { animation: none; }

@keyframes fs-enter {
  from { opacity: 0; transform: scale(0.985); filter: blur(2px); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

.cov-stage.is-fullscreen .cov-bar {
  margin: 0;
  flex: 0 0 auto;
}
.cov-stage.is-fullscreen .cov-matrix-wrap {
  flex: 1;
  min-height: 0;
  margin: 0;
}

/* corner brackets — industrial / command-center accent, only when fs */
.fs-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease 120ms;
}
.cov-stage.is-fullscreen .fs-corner { opacity: 0.55; }
.fs-corner.tl { top: 10px;    left: 10px;    border-right: 0;  border-bottom: 0; }
.fs-corner.tr { top: 10px;    right: 10px;   border-left: 0;   border-bottom: 0; }
.fs-corner.bl { bottom: 10px; left: 10px;    border-right: 0;  border-top: 0; }
.fs-corner.br { bottom: 10px; right: 10px;   border-left: 0;   border-top: 0; }

/* lock body scroll while fullscreen is on */
body.cov-fs-on { overflow: hidden; }
