/* KQL Hunting: ATT&CK Navigator ink over a white work surface. */

/* Self-hosted variable fonts, latin subset (SIL OFL 1.1, licences in assets/fonts/). */
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
}

:root {
  --shell: #14213d;
  --shell-ink: #ffffff;
  --shell-muted: #c3cde0;
  --shell-field: #22325a;
  --shell-line: #33466f;

  --bg: #ffffff;
  --surface: #f5f7fa;
  --ink: #14213d;
  --ink-2: #3f4b65;
  --ink-3: #59647c;
  --line: #dfe4ec;
  --line-strong: #c4ccd9;

  --r0: #f1f4f8; --r0-ink: #59647c;
  --r1: #6baed6; --r1-ink: #14213d;
  --r2: #3a6ea5; --r2-ink: #ffffff;
  --r3: #1f4e79; --r3-ink: #ffffff;
  --badge-dark: #2f6aa8;

  --accent: #e4572e;
  --accent-soft: rgba(228, 87, 46, .14);
  --accent-strong: #c2410c; /* accent dark enough for white text (5.2:1) */
  --pass: #1c7a4b;

  --code-bg: #0f1a30;
  --code-ink: #dbe4f3;
  --code-line: #22314f;
  --tk-op: #ffa07a;
  --tk-fn: #8fc3ff;
  --tk-str: #a8e0b4;
  --tk-num: #f2c66d;
  --tk-com: #8390aa;

  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 3px;
  --pad: 24px;
}

:root[data-theme="dark"] {
  --shell: #0a1326;
  --shell-field: #17233f;
  --shell-line: #26365a;
  --bg: #0d1628;
  --surface: #111c33;
  --ink: #e4eaf5;
  --ink-2: #b9c4d8;
  --ink-3: #95a2bb;
  --line: #213050;
  --line-strong: #2f4166;
  --r0: #131f38; --r0-ink: #95a2bb;
  --r1: #255181; --r1-ink: #ffffff;
  --r2: #4a8ccf; --r2-ink: #0d1628;
  --r3: #9cc7ee; --r3-ink: #0d1628;
  --accent-soft: rgba(228, 87, 46, .22);
  --pass: #5ccf8f;
  --code-bg: #08101f;
  --code-line: #1b2945;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shell: #0a1326;
    --shell-field: #17233f;
    --shell-line: #26365a;
    --bg: #0d1628;
    --surface: #111c33;
    --ink: #e4eaf5;
    --ink-2: #b9c4d8;
    --ink-3: #95a2bb;
    --line: #213050;
    --line-strong: #2f4166;
    --r0: #131f38; --r0-ink: #95a2bb;
    --r1: #255181; --r1-ink: #ffffff;
    --r2: #4a8ccf; --r2-ink: #0d1628;
    --r3: #9cc7ee; --r3-ink: #0d1628;
    --accent-soft: rgba(228, 87, 46, .22);
    --pass: #5ccf8f;
    --code-bg: #08101f;
    --code-line: #1b2945;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent-strong); color: #fff; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, button { font: inherit; color: inherit; caret-color: var(--accent); }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
code, kbd, pre { font-family: var(--mono); font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent-strong); color: #fff; padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-3); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  height: 56px; padding: 0 var(--pad);
  background: var(--shell); color: var(--shell-ink);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; }
.brand-mark .m1 { fill: #3a6ea5; } .brand-mark .m2 { fill: #9ec2e3; } .brand-mark .m3 { fill: var(--accent); }
.tabs { display: flex; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 14px; height: 100%;
  color: var(--shell-muted); font-weight: 600; text-decoration: none;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.tabs a:hover { color: var(--shell-ink); }
.tabs a[aria-current="page"] { color: var(--shell-ink); border-bottom-color: var(--accent); }
.search {
  position: relative; flex: 1; max-width: 560px;
  display: flex; align-items: center;
}
.search svg { position: absolute; left: 11px; width: 17px; height: 17px; fill: none; stroke: var(--shell-muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 36px 0 36px;
  background: var(--shell-field); border: 1px solid var(--shell-line); border-radius: var(--radius);
  color: var(--shell-ink);
}
.search input::placeholder { color: var(--shell-muted); opacity: 1; }
.search input:focus { outline: none; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { filter: invert(1); }
.search kbd {
  position: absolute; right: 9px; font-size: 12px; line-height: 18px; padding: 0 6px;
  border: 1px solid var(--shell-line); border-radius: 2px; color: var(--shell-muted);
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; background: none; border: 1px solid var(--shell-line); border-radius: var(--radius); color: var(--shell-muted); }
.icon-btn:hover { color: var(--shell-ink); border-color: var(--shell-muted); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; } :root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: block; } :root:not([data-theme="light"]) .i-moon { display: none; } }
.gh { color: var(--shell-muted); font-weight: 600; text-decoration: none; }
.gh:hover { color: var(--shell-ink); }

/* ---------- Matrix ---------- */
.matrix-panel { border-bottom: 1px solid var(--line); background: var(--bg); }
.matrix-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 18px var(--pad) 12px;
}
.matrix-head h1 { font-size: 17px; font-weight: 700; }
.matrix-head h1 .sub { font-weight: 400; color: var(--ink-3); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.select { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); }
.select select {
  height: 32px; padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2359647c' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center / 12px;
  color: var(--ink); appearance: none; -webkit-appearance: none; max-width: 220px;
}
.select select:hover { border-color: var(--ink-3); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--shell); }
:root[data-theme="dark"] .check input { accent-color: var(--badge-dark); }
.text-btn { background: none; border: 0; padding: 4px 2px; color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--ink); text-decoration-color: var(--accent); }

.matrix-scroll { overflow-x: auto; padding: 0 var(--pad) 4px; scroll-snap-type: x proximity; scroll-padding-inline: var(--pad); }
.matrix {
  display: grid; grid-template-columns: repeat(var(--cols, 14), minmax(94px, 1fr));
  gap: 0 3px; min-width: calc(var(--cols, 14) * 97px); width: 100%;
}
.tactic { display: flex; flex-direction: column; gap: 3px; scroll-snap-align: start; min-width: 0; }
.tactic-head { padding: 6px 2px 6px; border-bottom: 2px solid var(--ink); margin-bottom: 3px; }
.tactic-head b { display: block; font-size: 12px; font-weight: 700; letter-spacing: .01em; line-height: 1.2; min-height: 2.4em; }
.tactic-head span { font-size: 12px; color: var(--ink-3); }
.tactic.atlas .tactic-head { border-bottom-style: double; border-bottom-width: 3px; }
.cell {
  display: block; width: 100%; text-align: left; padding: 6px 7px 6px; border: 0; border-radius: 2px;
  background: var(--r0); color: var(--r0-ink); font-size: 12px; line-height: 1.25;
  transition: background-color 160ms ease-out, color 160ms ease-out;
  position: relative;
}
.cell .nm { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
.cell .meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 4px; margin-top: 3px; font: 500 11px/1.2 var(--mono); font-variant-ligatures: none; }
.cell .meta span { white-space: nowrap; letter-spacing: -.03em; }
.tactic.atlas .cell .meta { font-size: 10.5px; }
.cell[data-r="1"] { background: var(--r1); color: var(--r1-ink); }
.cell[data-r="2"] { background: var(--r2); color: var(--r2-ink); }
.cell[data-r="3"] { background: var(--r3); color: var(--r3-ink); }
.cell:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.cell[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 1px var(--accent); }
.cell[data-r="0"] .meta b { visibility: hidden; }
.legend { display: flex; align-items: center; gap: 6px; padding: 8px var(--pad) 14px; font-size: 12px; color: var(--ink-3); }
.legend span { margin-right: 4px; }
.legend i { width: 14px; height: 10px; border-radius: 1px; margin-left: 6px; }
.legend .r0 { background: var(--r0); box-shadow: inset 0 0 0 1px var(--line); } .legend .r1 { background: var(--r1); } .legend .r2 { background: var(--r2); } .legend .r3 { background: var(--r3); }

/* ---------- Results ---------- */
.results { display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; align-items: start; }
.list-wrap { border-right: 1px solid var(--line); min-height: 60vh; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px var(--pad) 10px; border-bottom: 1px solid var(--line); }
.list-head h2 { font-size: 15px; font-weight: 700; }
.list-head .muted { font-size: 13px; }
.qlist { list-style: none; margin: 0; padding: 0; }
.qrow {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 2px 12px; width: 100%;
  padding: 11px var(--pad); text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  position: relative;
}
.qrow:hover { background: var(--surface); }
.qrow[aria-current="true"] { background: var(--surface); }
.qrow[aria-current="true"] { box-shadow: inset 0 0 0 1px var(--accent); }
.qrow .id { font: 500 12.5px/1.6 var(--mono); color: var(--ink-3); grid-row: span 2; }
.qrow .t { font-weight: 600; line-height: 1.3; }
.qrow .sub { grid-column: 2; font-size: 13px; color: var(--ink-3); }
.qrow .sub code { font-size: 12px; }
.qrow .badge-wrap { grid-row: 1 / span 2; grid-column: 3; align-self: start; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; border-radius: 2px; white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.badge.tested { background: var(--shell); color: #fff; }
:root[data-theme="dark"] .badge.tested { background: var(--badge-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.tested { background: var(--badge-dark); } }
.badge.hunt { box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
.empty { padding: 32px var(--pad); color: var(--ink-2); }
.empty p { margin: 0 0 10px; }

/* ---------- Detail ---------- */
.detail { padding: 22px var(--pad) 48px; position: sticky; top: 56px; max-height: calc(100vh - 56px); overflow-y: auto; min-width: 0; }
.d-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 500 13px var(--mono); color: var(--ink-3); }
.detail h2 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 8px 0 12px; max-width: 30ch; text-wrap: balance; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 20px; margin: 0 0 18px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.facts dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.facts dd button { background: none; border: 0; padding: 0; text-align: left; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.facts dd button:hover { text-decoration-color: var(--accent); }
.facts dd code { font-size: 12.5px; }
.sev-high { font-weight: 700; }

.code { border-radius: var(--radius); background: var(--code-bg); color: var(--code-ink); overflow: hidden; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--code-line); font-size: 13px; color: #a7b3ca; }
.code-bar .actions { display: flex; gap: 6px; }
.code-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  background: #22314f; color: #fff; border: 0; border-radius: 2px; font-size: 13px; font-weight: 600; text-decoration: none;
}
.code-btn:hover { background: #2d4068; }
.code-btn.primary { background: var(--accent-strong); }
.code-btn.primary:hover { background: #a8380a; }
.code-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code pre { margin: 0; padding: 14px 16px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; tab-size: 4; scrollbar-color: #2d4068 transparent; }
.code pre::selection, .code pre *::selection { background: rgba(228, 87, 46, .45); color: #fff; }
.tk-op { color: var(--tk-op); } .tk-fn { color: var(--tk-fn); } .tk-str { color: var(--tk-str); } .tk-num { color: var(--tk-num); } .tk-com { color: var(--tk-com); font-style: italic; }

.d-sec { margin-top: 26px; max-width: 75ch; }
.d-sec h3 { font-size: 13px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.d-sec p { margin: 0; }
.d-sec ul, .d-sec ol { margin: 0; padding-left: 20px; }
.d-sec li { margin: 4px 0; }
.d-sec li::marker { color: var(--ink-3); }
.tuning { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.tuning dt { font: 500 13px/1.5 var(--mono); }
.tuning dd { margin: 0; }
.proof { border: 1px solid var(--line); border-radius: var(--radius); }
.proof-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.proof-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.proof-row:last-child { border-bottom: 0; }
.proof-row svg { width: 16px; height: 16px; margin-top: 2px; fill: none; stroke: var(--pass); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.proof-row .exp { font: 500 12.5px/1.6 var(--mono); color: var(--ink-2); white-space: nowrap; }
.proof-row small { display: block; color: var(--ink-3); font-size: 12.5px; }
.note { padding: 12px 14px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 14px; color: var(--ink-2); }
.refs a { overflow-wrap: anywhere; }

/* ---------- Cheat sheet ---------- */
#cheatsheet:not([hidden]) { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.cs-nav { position: sticky; top: 56px; padding: 24px var(--pad); max-height: calc(100vh - 56px); overflow-y: auto; }
.cs-nav h1 { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.cs-nav ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.cs-nav a { display: block; padding: 5px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.cs-nav a:hover { color: var(--ink); border-left-color: var(--line-strong); }
.cs-nav a[aria-current="true"] { color: var(--ink); font-weight: 600; border-left-color: var(--accent); }
.cs-body { padding: 8px var(--pad) 64px; border-left: 1px solid var(--line); min-width: 0; }
.cs-sec { padding-top: 26px; scroll-margin-top: 64px; }
.cs-sec h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.cs-sec > p { margin: 0 0 14px; color: var(--ink-2); max-width: 75ch; }
.cs-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cs-table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); padding: 8px 12px 8px 0; border-bottom: 2px solid var(--ink); }
.cs-table td { vertical-align: top; padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); }
.cs-table col.c1 { width: 27%; } .cs-table col.c2 { width: 35%; } .cs-table col.c3 { width: 38%; }
.cs-table .syn { font: 500 13px/1.5 var(--mono); overflow-wrap: anywhere; }
.cs-table td.ex { position: relative; padding-right: 0; }
.cs-table .ex pre { margin: 0; padding: 8px 34px 8px 10px; background: var(--code-bg); color: var(--code-ink); border-radius: 2px; font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.mini-copy { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; display: grid; place-items: center; background: transparent; border: 0; border-radius: 2px; color: #a7b3ca; }
.mini-copy:hover { background: #22314f; color: #fff; }
.mini-copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.see { display: block; margin-top: 6px; font-size: 13px; color: var(--ink-3); }
.see a { font-family: var(--mono); font-size: 12px; margin-right: 6px; }
mark { background: var(--accent-soft); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- Footer, toast ---------- */
.foot { border-top: 1px solid var(--line); padding: 20px var(--pad) 28px; font-size: 13.5px; color: var(--ink-3); }
.foot p { margin: 4px 0; max-width: 110ch; }
.foot strong { color: var(--ink-2); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  padding: 9px 14px; background: var(--shell); color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  box-shadow: 0 6px 20px rgba(10, 19, 38, .25);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar { gap: 16px; }
  .results { grid-template-columns: minmax(300px, 1fr) 1.3fr; }
}
@media (max-width: 860px) {
  :root { --pad: 16px; }
  .topbar { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; row-gap: 8px; position: static; }
  .tabs { height: 36px; order: 3; }
  .search { order: 4; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .top-actions { order: 2; }
  .matrix { grid-template-columns: repeat(var(--cols, 14), 150px); }
  .results { grid-template-columns: 1fr; }
  .list-wrap { border-right: 0; min-height: 0; }
  .detail { position: static; max-height: none; overflow: visible; border-top: 1px solid var(--line); }
  .detail h2 { font-size: 23px; }
  #cheatsheet:not([hidden]) { grid-template-columns: 1fr; }
  .cs-nav { position: static; max-height: none; padding-bottom: 8px; }
  .cs-nav ol { display: flex; flex-wrap: wrap; gap: 6px; border-left: 0; }
  .cs-nav a { border: 1px solid var(--line); border-radius: 2px; margin: 0; padding: 4px 10px; font-size: 13px; }
  .cs-nav a[aria-current="true"] { border-color: var(--accent); }
  .cs-body { border-left: 0; }
  .cs-table, .cs-table tbody, .cs-table tr, .cs-table td { display: block; width: 100%; }
  .cs-table colgroup, .cs-table thead { display: none; }
  .cs-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .cs-table td { border: 0; padding: 3px 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Mono labels set with the font shorthand: keep ligatures off so == and >= read literally. */
.cs-table .syn, .qrow .id, .d-top, .tuning dt, .proof-row .exp, .cell .meta, .see a, .facts dd code { font-variant-ligatures: none; }
