/* ── Global Reset & Base Styles ───────────────────────────────────────── */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#main-content {
  flex: 1;
  outline: none;
}

/* ── Scroll Offset for Sticky Header ────────────────────────────────── */
:target,
[id] {
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

/* ── Typography ─────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--color-heading);
  line-height: var(--line-height-tight);
  font-weight: 700;
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
}

/* Base sizes — content.css overrides these inside .content-body */
h1 { font-size: clamp(var(--font-size-3xl), 4vw, var(--font-size-5xl)); margin-top: 0; }
h2 { font-size: clamp(var(--font-size-2xl), 3vw, var(--font-size-3xl)); }
h3 { font-size: clamp(var(--font-size-xl), 2.5vw, var(--font-size-2xl)); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.06em; }

p { margin: 0 0 var(--space-5); }

strong { font-weight: 700; color: var(--color-primary); }
em { font-style: italic; }

/* ── Links ──────────────────────────────────────────────────────────── */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}
a:hover, a:focus-visible {
  color: var(--color-link-hover);
  text-decoration-color: currentColor;
}
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── Inline Code ────────────────────────────────────────────────────── */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-code-bg);
  color: var(--color-primary-mid);
  padding: 0.15em 0.38em;
  border-radius: var(--radius-sm);
  border: none;
  word-break: break-word;
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-6) 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  white-space: nowrap;
}
thead {
  background: var(--color-primary);
  color: var(--color-white);
}
thead th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.03em;
}
tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}
tbody tr:nth-child(even) { background: var(--color-surface); }
tbody tr:hover { background: var(--color-surface-alt); }
tbody td {
  padding: var(--space-3) var(--space-5);
  vertical-align: top;
  white-space: normal;
}

/* ── Lists ──────────────────────────────────────────────────────────── */
/* Base reset only — content.css provides styled versions inside .content-body */
ul, ol {
  margin: 0 0 var(--space-5);
  padding-left: var(--space-8);
}
li { margin-bottom: var(--space-2); }

/* Task-list checkboxes */
li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: calc(-1 * var(--space-5));
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
li > input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--color-accent);
  cursor: pointer;
}
li.is-checked > * { text-decoration: line-through; opacity: 0.55; }
li.is-checked > input[type="checkbox"] { text-decoration: none; opacity: 1; }

/* ── Blockquote ─────────────────────────────────────────────────────── */
blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-muted);
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

/* ── Horizontal rule ───────────────────────────────��─────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-10) 0;
}

/* ── Images ─────────────────────────────────────────────────────────── */
img, svg { max-width: 100%; height: auto; }

/* ── Layout wrapper ─────────────────────────────────────────────────── */
.page-layout {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

@media (max-width: 768px) {
  .page-layout { padding: var(--space-5) var(--space-4); }
}

/* ── Section heading ─────────────────────────────────────────────────── */
.section-heading {
  font-size: clamp(var(--font-size-xl), 2.5vw, var(--font-size-2xl));
  color: var(--color-primary);
  margin-top: var(--space-12);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-surface-alt);
}

/* ── Back link ───────────────────────────────────────────────────────── */
.back-link-wrap {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}
.back-link {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-primary-mid);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.back-link:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  text-decoration: none;
}

/* ── Skip link ───────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-primary);
  color: var(--color-white);
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 0; }

