/* Shared print-first style for all exam summaries.
   Future summaries should include:
   <link rel="stylesheet" href="../../assets/summary-style.css">
*/

@page {
  size: A4;
  margin: 16mm 14mm 18mm;
}

:root {
  --paper: #ffffff;
  --page-bg: #e9edf2;
  --text: #1f2933;
  --ink: var(--text);
  --muted: #5b6673;
  --line: #d7dde5;
  --rule: var(--line);
  --grid: var(--line);
  --soft: #f5f7fa;
  --accent: #176b73;
  --accent-strong: #123f46;
  --accent-soft: #e8f5f6;
  --exam: #eef7fb;
  --warn: #9a3412;
  --warn-soft: #fff4ed;
  --danger: #8f1d1d;
  --danger-soft: #fff3f3;
  --ok: #276749;
  --ok-soft: #eef8f0;
  --code-bg: #f4f6f8;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 15.2px;
  line-height: 1.52;
}

main,
body:not(:has(> main)) {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 34px 44px 52px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(31, 41, 51, 0.12);
}

h1,
h2,
h3,
h4 {
  color: #14212b;
  line-height: 1.22;
  letter-spacing: 0;
  break-after: avoid;
  page-break-after: avoid;
}

h1 {
  margin: 30px 0 10px;
  padding-top: 8px;
  border-top: 2px solid var(--accent-strong);
  font-size: 23px;
}

header h1,
.title {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  color: var(--accent-strong);
  font-size: 31px;
  font-weight: 750;
  line-height: 1.14;
  text-align: left;
}

.title {
  text-align: center;
  margin-bottom: 12px;
}

h2 {
  margin: 30px 0 10px;
  padding-top: 8px;
  border-top: 2px solid var(--accent-strong);
  font-size: 22px;
}

h3 {
  margin: 20px 0 7px;
  font-size: 18px;
}

h4 {
  margin: 16px 0 5px;
  font-size: 15.5px;
}

p,
li {
  orphans: 3;
  widows: 3;
}

p {
  margin: 0 0 9px;
}

ul,
ol {
  margin: 7px 0 12px 23px;
  padding: 0;
}

li {
  margin: 3px 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.subject-list,
.summary-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.subject-list li,
.summary-list li {
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.subject-list a,
.summary-list a {
  color: var(--accent-strong);
  font-weight: 700;
}

.item-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.empty {
  color: var(--muted);
}

code,
.code,
pre {
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
}

code {
  padding: 0.05em 0.24em;
  border-radius: 4px;
  background: var(--code-bg);
  font-size: 0.94em;
}

pre,
.code {
  margin: 9px 0 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  break-inside: avoid;
  page-break-inside: avoid;
}

pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

table {
  width: 100%;
  margin: 11px 0 16px;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  padding: 7px 8px;
  border: 1px solid var(--grid);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eaf0f4;
  color: #132f36;
  font-weight: 700;
}

thead {
  display: table-header-group;
}

tfoot {
  display: table-footer-group;
}

tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.keep,
.keep-table,
.short-table {
  break-inside: avoid;
  page-break-inside: avoid;
}

.long-table {
  break-inside: auto;
  page-break-inside: auto;
}

.coverage td:first-child {
  font-weight: 700;
  white-space: nowrap;
}

figure {
  margin: 13px 0 17px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  break-inside: avoid;
  page-break-inside: avoid;
}

figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 165mm;
  object-fit: contain;
  border: 1px solid #e4e8ee;
  border-radius: 4px;
  background: var(--paper);
}

figcaption,
.figure-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  break-before: avoid;
  page-break-before: avoid;
}

.figure-title {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-weight: 700;
  text-align: center;
}

.image-row,
.figure-pair,
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  break-inside: avoid;
  page-break-inside: avoid;
}

.figure-pair figure {
  margin: 8px 0 12px;
}

.subtitle,
.meta,
.chapter-meta,
.small,
.vars {
  color: var(--muted);
}

.subtitle {
  margin: 0 0 12px;
  font-size: 16px;
}

.meta {
  margin: 12px 0 16px;
}

.meta:has(> div) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.meta div {
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.meta strong {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toc {
  margin: 16px 0 24px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  break-inside: avoid;
  page-break-inside: avoid;
}

.toc ol,
ol.toc {
  columns: 2;
  column-gap: 32px;
  margin-bottom: 0;
}

.toc li {
  break-inside: avoid;
}

.toc a {
  color: var(--text);
  text-decoration: none;
}

.box,
.callout,
.pitfall,
.task,
.definition,
.formula-block,
.formula-box,
.exam,
.trap,
.check,
.print-note {
  margin: 11px 0 14px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  background: #fbfcfe;
  break-inside: avoid;
  page-break-inside: avoid;
}

.definition {
  background: var(--accent-soft);
}

.exam,
.callout {
  background: var(--exam);
}

.pitfall,
.trap,
.warn {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.task,
.ok,
.check {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.formula-block,
.formula-box {
  border-left-color: #5f6874;
  background: #fbfcfd;
}

.box > strong:first-child,
.formula-box > strong:first-child {
  display: block;
  margin-bottom: 4px;
}

.label {
  display: inline-block;
  margin-right: 4px;
  font-weight: 700;
}

.tag {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 2px 7px;
  border: 1px solid #b9dbe1;
  border-radius: 999px;
  background: #dff2f5;
  color: #14313a;
  font-size: 12px;
  font-weight: 700;
}

.math,
.formula,
.var-list dt,
.vec {
  font-family: "Cambria Math", Cambria, "STIX Two Math", "Times New Roman", serif;
}

.math,
.vec {
  font-style: italic;
}

.vec {
  font-weight: 700;
}

.math,
.nowrap {
  white-space: nowrap;
}

.formula {
  display: block;
  margin: 7px 0;
  padding: 8px 10px;
  border: 1px solid #dfe5eb;
  border-radius: 6px;
  background: var(--paper);
  font-size: 1.06em;
  text-align: center;
  overflow-wrap: anywhere;
}

.formula .line {
  display: block;
  margin: 2px 0;
}

.var-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 2px 12px;
  margin-top: 6px;
}

.var-list dt {
  font-weight: 700;
}

.var-list dd {
  margin: 0 0 3px;
}

.bullet {
  position: relative;
  margin-left: 1.1rem;
}

.bullet::before {
  position: absolute;
  left: -1rem;
  color: var(--accent);
  content: "\2022";
}

.page-break {
  break-before: page;
  page-break-before: always;
}

.section {
  break-inside: auto;
  page-break-inside: auto;
}

.small {
  font-size: 13px;
}

@media print {
  html,
  body {
    background: var(--paper);
  }

  body {
    font-size: 10.8pt;
    line-height: 1.45;
  }

  main,
  body:not(:has(> main)) {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  h1 {
    font-size: 18pt;
  }

  header h1,
  .title {
    font-size: 24pt;
  }

  h2 {
    margin-top: 20pt;
    font-size: 17pt;
  }

  h3 {
    font-size: 13.5pt;
  }

  figure,
  .box,
  .callout,
  .pitfall,
  .task,
  .definition,
  .formula,
  .formula-block,
  .formula-box,
  .exam,
  .trap,
  .check,
  .print-note,
  pre,
  .short-table,
  .keep-table,
  .toc {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table.long-table {
    break-inside: auto;
    page-break-inside: auto;
  }

  tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  figure img {
    max-height: 155mm;
  }

  .no-print {
    display: none !important;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  a[href]::after {
    content: "";
  }
}

@media (max-width: 760px) {
  main,
  body:not(:has(> main)) {
    padding: 18px;
    box-shadow: none;
  }

  header h1,
  .title {
    font-size: 27px;
  }

  .meta:has(> div),
  .image-row,
  .figure-pair,
  .two-col {
    display: block;
  }

  .toc ol,
  ol.toc {
    columns: 1;
  }

  .var-list {
    grid-template-columns: 1fr;
  }
}
