/* ==========================================================================
   External Email Warning in Outlook: blog post styles
   Reading-first: serif body, sans headings, one calm accent colour.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Surfaces and text */
  color-scheme: light;

  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #14202b;
  --muted: #4f5e6c;
  --rule: #d8e0e7;

  /* Accent (links, markers, active states) */
  --accent: #1b5faa;
  --accent-ink: #134a86;
  --accent-wash: #e6eff8;

  /* Callouts */
  --check: #1f7a4d;
  --check-wash: #e7f5ec;
  --note: #a35f00;
  --note-wash: #fff5dd;

  /* Code */
  --code-bg: #f4f7fa;
  --code-bar: #e8eef4;
  --code-ink: #14202b;
  --code-muted: #4f5e6c;
  --code-line: #c4cfda;
  --inline-code-bg: #eaeff4;

  /* Type */
  --font-body: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --measure: 44rem;
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

strong {
  font-weight: 600;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  font: 500 0.95rem var(--font-ui);
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

/* ---------- 3. Page layout ---------- */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1.1rem, 4vw, 1.5rem) 5rem;
}

@media (min-width: 1100px) {
  .shell {
    max-width: none;
    grid-template-columns: 15rem minmax(0, var(--measure));
    grid-template-areas:
      "toc header"
      "toc article";
    column-gap: 4.5rem;
    justify-content: center;
    padding-inline: 2rem;
  }

  .article-header { grid-area: header; }
  .toc            { grid-area: toc; }
  .article        { grid-area: article; }
}

/* ---------- 4. Header ---------- */
.article-header {
  margin-bottom: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

h1 {
  margin: 0 0 1.5rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: clamp(2rem, 1.4rem + 2.8vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 0;
  font: 400 0.95rem/1.4 var(--font-ui);
}

.meta div {
  display: flex;
  gap: 0.5rem;
}

.meta dt {
  color: var(--muted);
}

.meta dd {
  margin: 0;
  font-weight: 500;
}

/* ---------- 5. Table of contents ---------- */
.toc {
  margin-bottom: 2.25rem;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.4;
}

.toc details {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.toc summary {
  padding: 0.8rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.toc ol {
  margin: 0;
  padding: 0 1rem 0.9rem;
  list-style: none;
}

.toc li + li {
  margin-top: 0.15rem;
}

.toc a {
  display: block;
  padding: 0.35rem 0 0.35rem 0.75rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
  border-left-color: var(--muted);
}

.toc a[aria-current="true"] {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--accent);
}

@media (min-width: 1100px) {
  .toc {
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    margin-bottom: 0;
    overflow-y: auto;
  }

  .toc details {
    border: 0;
    background: none;
  }

  .toc summary {
    padding: 0 0 0.75rem;
    cursor: default;
    pointer-events: none;
    list-style: none;
  }

  .toc summary::-webkit-details-marker {
    display: none;
  }

  .toc ol {
    padding: 0;
  }
}

/* ---------- 6. Article text ---------- */
.article p,
.article ul,
.article ol {
  margin: 0 0 1.25rem;
}

.article h2 {
  margin: 3.5rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.25rem + 1vw, 1.85rem);
  line-height: 1.25;
  letter-spacing: -0.012em;
  text-wrap: balance;
  scroll-margin-top: 1.5rem;
}

.article h3 {
  margin: 2.25rem 0 0.6rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.35;
}

/* Bulleted and numbered lists */
.article ul {
  padding-left: 1.4rem;
}

.article ol {
  padding-left: 1.6rem;
}

.article li {
  margin-bottom: 0.5rem;
  padding-left: 0.2rem;
}

.article ul li::marker {
  color: var(--accent);
}

.article ol li::marker {
  color: var(--accent);
  font-family: var(--font-ui);
  font-weight: 600;
}

/* Procedure steps get a numbered marker because they are a real sequence */
.article ol.steps {
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.article ol.steps > li {
  position: relative;
  margin-bottom: 1.1rem;
  padding-left: 3rem;
  counter-increment: step;
}

.article ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-wash);
  color: var(--accent-ink);
  font: 600 0.9rem/2rem var(--font-ui);
  text-align: center;
}

/* ---------- 7. Quick answer and callouts ---------- */
.quick-answer {
  margin: 0 0 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--accent-wash);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 1.05rem;
  line-height: 1.65;
}

.article .quick-answer p {
  margin: 0;
}

.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--note-wash);
  border-left: 4px solid var(--note);
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.6;
}

.article .callout p {
  margin: 0;
}

.callout--check {
  background: var(--check-wash);
  border-left-color: var(--check);
}

/* ---------- 8. Inline code and code blocks ---------- */
code {
  padding: 0.12em 0.38em;
  background: var(--inline-code-bg);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.84em;
  overflow-wrap: anywhere;
}

.code {
  margin: 1.5rem 0;
  overflow: hidden;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.code figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  background: var(--code-bar);
  color: var(--code-muted);
  border-bottom: 1px solid var(--rule);
  font: 500 0.8rem/1.2 var(--font-ui);
}

.code pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font: 400 0.9rem/1.6 var(--font-mono);
  tab-size: 2;
}

.code code {
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  overflow-wrap: normal;
}

.copy-btn {
  padding: 0.3rem 0.7rem;
  background: var(--surface);
  color: var(--code-ink);
  border: 1px solid var(--code-line);
  border-radius: 5px;
  font: 500 0.8rem/1.2 var(--font-ui);
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--code-line);
}

/* ---------- 9. Tables ---------- */
.table-wrap {
  margin: 1.75rem 0;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.5;
}

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

thead th {
  background: var(--accent-wash);
  font-weight: 600;
}

tbody th {
  width: 27%;
  font-weight: 600;
}

table code {
  font-size: 0.88em;
}

@media (min-width: 721px) {
  tbody tr:last-child > * {
    border-bottom: 0;
  }
}

/* On phones, each row becomes a small card with labelled values */
@media (max-width: 720px) {
  .table-wrap {
    overflow: visible;
    background: none;
    border: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody tr {
    margin-bottom: 1rem;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
  }

  tbody th {
    width: auto;
    background: var(--accent-wash);
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
  }
}

/* ---------- 10. Print ---------- */
@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .toc,
  .copy-btn,
  .skip-link {
    display: none;
  }

  .shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .code {
    border: 1px solid #999;
    background: #fff;
    color: #000;
  }

  .code figcaption {
    background: #eee;
    color: #000;
  }

  a {
    color: inherit;
  }
}
