/* --- Reset & Base --- */
:root {
  --primary: #1a6fb5;
  --primary-light: #e8f4fd;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --danger: #c62828;
  --danger-bg: #ffebee;
  --muted: #6c757d;
  --border: #dee2e6;
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #212529;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  margin: 0;
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  background: var(--text);
  color: white;
  padding: 0.5rem 1rem;
}

header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

header nav a {
  color: white;
  text-decoration: none;
}

header nav a:hover {
  text-decoration: underline;
}

footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
}

main {
  padding: 2rem 1rem;
}

/* --- Typography --- */
h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; margin-top: 2rem; border-bottom: 2px solid var(--primary); padding-bottom: 0.3rem; }

hgroup p { margin-top: 0; color: var(--muted); }

a { color: var(--primary); }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-alt);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* --- Grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

/* --- Cards / Articles --- */
article {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.grid > article {
  text-align: center;
}

article > header {
  background: var(--bg-alt);
  color: var(--text);
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
}

article > .highlight {
  margin: 0;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

article > .highlight pre {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

th, td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-alt);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:hover { background: var(--primary-light); }

/* --- Explanation rows (threat mitigations) --- */
.explanation-row td {
  padding: 0 0.8rem 0.8rem;
  border-bottom: 2px solid var(--border);
}

.explanation-row:hover { background: transparent; }

.explanation {
  background: var(--bg-alt);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
}

/* --- Details / Accordion --- */
details {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

details > summary {
  padding: 0.75rem 1rem;
  background: var(--bg-alt);
  cursor: pointer;
  font-size: 1rem;
}

details > summary:hover { background: var(--primary-light); }

details > table {
  margin: 0;
}

/* --- Badges --- */
mark {
  background: var(--success-bg);
  color: var(--success);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.85em;
}

.not-applied {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.85em;
}

/* --- Pygments code highlighting (monokai-light inspired) --- */
.highlight { background: #f8f8f8; }
.highlight .hll { background-color: #ffffcc; }
.highlight .c { color: #8e908c; font-style: italic; }
.highlight .k { color: #8959a8; font-weight: bold; }
.highlight .o { color: #4d4d4c; }
.highlight .n { color: #4d4d4c; }
.highlight .p { color: #4d4d4c; }
.highlight .s { color: #718c00; }
.highlight .na { color: #c82829; }
.highlight .nb { color: #4271ae; }
.highlight .nc { color: #c82829; font-weight: bold; }
.highlight .nf { color: #4271ae; }
.highlight .nn { color: #4d4d4c; }
.highlight .nt { color: #c82829; }
.highlight .nv { color: #c82829; }
.highlight .m { color: #f5871f; }
.highlight .mi { color: #f5871f; }
.highlight .mf { color: #f5871f; }
.highlight .cm { color: #8e908c; font-style: italic; }
.highlight .c1 { color: #8e908c; font-style: italic; }
.highlight .cp { color: #8959a8; }
.highlight .cs { color: #8e908c; font-style: italic; }
.highlight .kc { color: #8959a8; font-weight: bold; }
.highlight .kd { color: #8959a8; font-weight: bold; }
.highlight .kn { color: #8959a8; font-weight: bold; }
.highlight .kp { color: #8959a8; }
.highlight .kr { color: #8959a8; font-weight: bold; }
.highlight .kt { color: #eab700; }
.highlight .sd { color: #718c00; }
.highlight .s1 { color: #718c00; }
.highlight .s2 { color: #718c00; }
.highlight .si { color: #f5871f; }
.highlight .sx { color: #718c00; }
.highlight .sr { color: #c82829; }
.highlight .ss { color: #718c00; }

/* --- Heatmap --- */
.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 2fr;
  gap: 1rem;
  margin: 1rem 0;
}

.heatmap-column-header {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.5rem;
  text-align: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}

.heatmap-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  min-height: 60px;
  align-content: flex-start;
  justify-content: center;
}

.heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 48px;
  border-radius: 4px;
  color: #fff;
  text-decoration: none;
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  cursor: default;
}

a.heatmap-cell {
  cursor: pointer;
}

a.heatmap-cell:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.heatmap-tid {
  font-weight: 700;
  font-size: 0.65rem;
  opacity: 0.9;
}

.heatmap-short {
  font-weight: 800;
  font-size: 0.85rem;
}
