/* ═══════════════════════════════════════════════════════════
   NERF Security Report — Branded PDF Stylesheet
   Used by pandoc HTML→PDF pipeline (weasyprint/wkhtmltopdf)
   ═══════════════════════════════════════════════════════════ */

/* ─── Page Layout ─── */
@page {
  size: A4;
  margin: 2.5cm 2cm 3cm 2cm;

  @top-left {
    content: "NERF Security Report";
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 8pt;
    font-weight: 600;
    color: #e6edf3;
    background: #0d1117;
    padding: 4pt 10pt;
    border-bottom: 2px solid #58a6ff;
  }

  @top-right {
    content: "CONFIDENTIAL";
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 8pt;
    font-weight: 600;
    color: #f78166;
    background: #0d1117;
    padding: 4pt 10pt;
    border-bottom: 2px solid #58a6ff;
  }

  @bottom-left {
    content: "Generated by NERF";
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 8pt;
    color: #8b949e;
  }

  @bottom-center {
    content: counter(page) " / " counter(pages);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 8pt;
    color: #8b949e;
  }

  @bottom-right {
    content: string(report-date);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 8pt;
    color: #8b949e;
  }
}

@page :first {
  @top-left { content: none; }
  @top-right { content: none; }
  margin-top: 2cm;
}

/* ─── Base Typography ─── */
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 11pt;
  line-height: 1.65;
  color: #1f2328;
  max-width: 100%;
  orphans: 3;
  widows: 3;
}

/* Pull report date for footer via CSS string-set */
.report-date, #report-date {
  string-set: report-date content();
  display: none;
}

/* ─── Headings ─── */
h1 {
  font-size: 24pt;
  font-weight: 700;
  color: #0d1117;
  border-bottom: 3px solid #0969da;
  padding-bottom: 0.4em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  page-break-after: avoid;
}

h2 {
  font-size: 17pt;
  font-weight: 600;
  color: #0d1117;
  border-bottom: 1px solid #d0d7de;
  padding-bottom: 0.3em;
  margin-top: 1.6em;
  margin-bottom: 0.4em;
  page-break-after: avoid;
}

h3 {
  font-size: 13pt;
  font-weight: 600;
  color: #1f2328;
  margin-top: 1.2em;
  margin-bottom: 0.3em;
  page-break-after: avoid;
}

h4, h5, h6 {
  font-weight: 600;
  color: #1f2328;
  page-break-after: avoid;
}

/* ─── Severity Color Coding ─── */

/* Inline severity markers: backtick-wrapped severity words get colored.
   In pandoc output, `Critical` becomes <code>Critical</code>. Target via
   both class selectors (for custom pandoc filters) and the universal
   approach of coloring code elements whose text matches severity labels. */

.severity-critical,
.Critical { color: #FF0000; font-weight: 700; }

.severity-high,
.High { color: #FF6600; font-weight: 700; }

.severity-medium,
.Medium { color: #FFB300; font-weight: 600; }

.severity-low,
.Low { color: #0066CC; font-weight: 600; }

.severity-info,
.Info { color: #999999; font-weight: 400; }

/* Severity badge blocks: used in finding headers */
.finding-critical { border-left: 4px solid #FF0000; padding-left: 1em; }
.finding-high     { border-left: 4px solid #FF6600; padding-left: 1em; }
.finding-medium   { border-left: 4px solid #FFB300; padding-left: 1em; }
.finding-low      { border-left: 4px solid #0066CC; padding-left: 1em; }
.finding-info     { border-left: 4px solid #999999; padding-left: 1em; }

/* Severity table cell backgrounds */
td.severity-critical, th.severity-critical { background: #fff0f0; }
td.severity-high, th.severity-high         { background: #fff4ec; }
td.severity-medium, th.severity-medium     { background: #fff8e6; }
td.severity-low, th.severity-low           { background: #f0f6ff; }
td.severity-info, th.severity-info         { background: #f6f6f6; }

/* ─── Code Blocks (proof/evidence sections) ─── */
code {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.88em;
  background: #f6f8fa;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid #d0d7de;
  color: #1f2328;
}

pre {
  background: #0d1117;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1em 1.2em;
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.55;
  page-break-inside: avoid;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 1em;
}

/* Syntax-highlighted tokens (pandoc --highlight-style) */
pre .kw { color: #ff7b72; }  /* keywords */
pre .dt { color: #79c0ff; }  /* data types */
pre .st { color: #a5d6ff; }  /* strings */
pre .co { color: #8b949e; }  /* comments */
pre .fu { color: #d2a8ff; }  /* functions */
pre .dv { color: #79c0ff; }  /* decimal values */
pre .op { color: #e6edf3; }  /* operators */
pre .al { color: #f85149; font-weight: 700; }  /* alerts */
pre .er { color: #f85149; }  /* errors */

/* ─── Tables (findings summary, risk matrices) ─── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 0.92em;
  page-break-inside: avoid;
}

thead {
  background: #0d1117;
  color: #e6edf3;
}

th {
  font-weight: 600;
  text-align: left;
  padding: 0.6em 0.8em;
  border: 1px solid #30363d;
}

thead th {
  background: #0d1117;
  color: #e6edf3;
  border-color: #30363d;
}

td {
  padding: 0.5em 0.8em;
  border: 1px solid #d0d7de;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #f6f8fa;
}

tbody tr:hover {
  background: #eef2f7;
}

/* ─── Blockquotes (notes, recommendations) ─── */
blockquote {
  border-left: 4px solid #58a6ff;
  margin: 1em 0;
  padding: 0.6em 1em;
  color: #57606a;
  background: #f6f8fa;
  border-radius: 0 4px 4px 0;
  page-break-inside: avoid;
}

/* ─── Links ─── */
a {
  color: #0969da;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ─── Horizontal Rules ─── */
hr {
  border: none;
  border-top: 2px solid #d0d7de;
  margin: 2em 0;
}

/* ─── Lists ─── */
ul, ol {
  padding-left: 1.5em;
  margin: 0.8em 0;
}

li {
  margin-bottom: 0.3em;
}

li > ul, li > ol {
  margin: 0.2em 0;
}

/* ─── Cover Page Elements ─── */
.cover-title {
  font-size: 32pt;
  font-weight: 700;
  color: #0d1117;
  text-align: center;
  margin-top: 4cm;
  margin-bottom: 0.5em;
}

.cover-subtitle {
  font-size: 14pt;
  color: #57606a;
  text-align: center;
  margin-bottom: 3cm;
}

.cover-meta {
  font-size: 11pt;
  color: #1f2328;
  text-align: center;
  line-height: 2;
}

.cover-logo {
  text-align: center;
  margin-bottom: 2cm;
}

.cover-logo img {
  max-width: 200px;
}

/* ─── Finding Card Layout ─── */
.finding {
  border: 1px solid #d0d7de;
  border-radius: 6px;
  margin: 1.5em 0;
  padding: 1em 1.2em;
  page-break-inside: avoid;
}

.finding-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5em;
}

.finding-id {
  font-weight: 700;
  font-size: 1.1em;
  color: #0d1117;
}

.finding-severity {
  font-weight: 700;
  padding: 0.2em 0.6em;
  border-radius: 3px;
  font-size: 0.85em;
  text-transform: uppercase;
}

.finding-severity.critical { background: #FF0000; color: #fff; }
.finding-severity.high     { background: #FF6600; color: #fff; }
.finding-severity.medium   { background: #FFB300; color: #1f2328; }
.finding-severity.low      { background: #0066CC; color: #fff; }
.finding-severity.info     { background: #999999; color: #fff; }

/* ─── Executive Summary Box ─── */
.executive-summary {
  background: #f6f8fa;
  border: 2px solid #0969da;
  border-radius: 8px;
  padding: 1.5em;
  margin: 1.5em 0;
  page-break-inside: avoid;
}

.executive-summary h2 {
  border-bottom: none;
  color: #0969da;
  margin-top: 0;
}

/* ─── Risk Matrix ─── */
.risk-matrix {
  text-align: center;
}

.risk-matrix td {
  width: 3em;
  height: 3em;
  text-align: center;
  vertical-align: middle;
  font-weight: 600;
}

/* ─── CVSS Score Display ─── */
.cvss-score {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-size: 0.9em;
}

.cvss-critical { background: #FF0000; color: #fff; }
.cvss-high     { background: #FF6600; color: #fff; }
.cvss-medium   { background: #FFB300; color: #1f2328; }
.cvss-low      { background: #0066CC; color: #fff; }
.cvss-none     { background: #999999; color: #fff; }

/* ─── TOC Styling ─── */
nav#TOC {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 1em 1.5em;
  margin: 1em 0 2em 0;
  page-break-after: always;
}

nav#TOC > ul {
  list-style: none;
  padding-left: 0;
}

nav#TOC a {
  color: #1f2328;
  text-decoration: none;
}

nav#TOC a:hover {
  color: #0969da;
}

/* ─── Print Overrides ─── */
@media print {
  body {
    font-size: 10pt;
  }

  h1 { font-size: 20pt; }
  h2 { font-size: 14pt; }
  h3 { font-size: 12pt; }

  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #8b949e;
  }

  a[href^="#"]:after,
  a[href^="javascript"]:after {
    content: "";
  }
}
