/* ============================================================
   clinical-data.org — Design System
   Light, professional palette inspired by clinical aesthetics
   ============================================================ */

:root {
  /* Palette */
  --color-primary: #0f766e;          /* deep teal */
  --color-primary-dark: #0b5a54;
  --color-primary-soft: #ccfbf1;
  --color-accent: #ef6c57;           /* soft coral */
  --color-accent-soft: #ffe4dc;
  --color-secondary: #4f46e5;        /* muted indigo */
  --color-secondary-soft: #e0e7ff;
  --color-success: #16a34a;
  --color-warning: #d97706;

  /* Surfaces & text */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-2: #eef2f5;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-soft: #64748b;
  --color-heading: #0b3a37;

  --color-code-bg: #f5f7fa;
  --color-code-text: #0f172a;
  --color-inline-code-bg: #eaf6f4;
  --color-inline-code-text: #0b5a54;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);

  /* Layout */
  --header-height: 64px;
  --container-narrow: 880px;
  --container: 1280px;
  --container-wide: 1600px;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ============================================================
   Reset / Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

a:hover,
a:focus-visible {
  color: var(--color-primary-dark);
  border-bottom-color: currentColor;
}

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

/* Anchor offset for sticky header */
:target,
h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id] {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 1000;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
  color: #fff;
  border-bottom-color: transparent;
}

/* ============================================================
   Typography
   ============================================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  color: var(--color-heading);
  font-weight: 700;
  line-height: 1.25;
  margin: 2.5em 0 0.6em;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.6rem, 1.1rem + 2.2vw, 3rem);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 70%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-top: 0;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.5rem, 1.15rem + 1.2vw, 1.9rem);
  color: var(--color-heading);
  border-bottom: 2px solid var(--color-primary-soft);
  padding-bottom: 0.35em;
  position: relative;
}

h2::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 56px;
  height: 2px;
  background: var(--color-primary);
}

h3 {
  font-size: clamp(1.2rem, 1rem + 0.6vw, 1.4rem);
  color: var(--color-primary-dark);
}

h4 {
  font-size: 1.1rem;
  color: var(--color-text);
}

p {
  margin: 0 0 1.1em;
}

strong {
  color: var(--color-heading);
  font-weight: 700;
}

em {
  font-style: italic;
}

hr {
  border: 0;
  height: 1px;
  background: var(--color-border);
  margin: 2.5rem 0;
}

/* ============================================================
   Lists (article body)
   ============================================================ */

/* Default body lists outside of the article get conservative styling */
ul,
ol {
  padding-left: 1.4em;
  margin: 0 0 1.1em;
}

li {
  margin-bottom: 0.4em;
}

/* Styled lists inside the article / markdown body */
.markdown ul,
.markdown ol,
article > ul,
article > ol {
  list-style: none;
  padding-left: 0;
  margin: 1em 0 1.4em;
  display: grid;
  gap: 0.55em;
}

/* Allow nested lists to keep their own spacing */
.markdown li > ul,
.markdown li > ol,
article li > ul,
article li > ol {
  margin: 0.55em 0 0.2em;
  padding-left: 0.5em;
}

/* Unordered list items: custom teal marker + soft hover lift */
.markdown ul > li,
article > ul > li,
.markdown li > ul > li,
article li > ul > li {
  position: relative;
  padding: 0.05em 0 0.05em 1.7em;
  margin: 0;
  line-height: 1.65;
}

.markdown ul > li::before,
article > ul > li::before,
.markdown li > ul > li::before,
article li > ul > li::before {
  content: "";
  position: absolute;
  left: 0.35em;
  top: 0.65em;
  width: 0.55em;
  height: 0.55em;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.markdown ul > li:hover::before,
article > ul > li:hover::before {
  transform: rotate(135deg) scale(1.15);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

/* Nested unordered list: smaller, coral accent */
.markdown li > ul > li::before,
article li > ul > li::before {
  background: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(239, 108, 87, 0.1);
  width: 0.45em;
  height: 0.45em;
  top: 0.72em;
}

/* Deeper nesting: indigo dot */
.markdown li > ul > li > ul > li::before,
article li > ul > li > ul > li::before {
  background: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  border-radius: 50%;
  transform: none;
}

.markdown li > ul > li > ul > li:hover::before,
article li > ul > li > ul > li:hover::before {
  transform: scale(1.2);
}

/* Ordered lists: custom counter with teal pill */
.markdown ol,
article > ol {
  counter-reset: cd-counter;
}

.markdown ol > li,
article > ol > li,
.markdown li > ol > li,
article li > ol > li {
  position: relative;
  padding: 0.1em 0 0.1em 2.6em;
  margin: 0;
  line-height: 1.65;
  counter-increment: cd-counter;
}

.markdown ol > li::before,
article > ol > li::before,
.markdown li > ol > li::before,
article li > ol > li::before {
  content: counter(cd-counter);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 1.9em;
  height: 1.9em;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.78em;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 50%;
  line-height: 1;
  transition: all 0.2s var(--ease);
}

.markdown ol > li:hover::before,
article > ol > li:hover::before {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.22);
}

/* Nested ordered list: indigo accent */
.markdown li > ol > li::before,
article li > ol > li::before {
  background: var(--color-secondary-soft);
  color: var(--color-secondary);
  border-color: rgba(79, 70, 229, 0.2);
  font-size: 0.7em;
  width: 1.7em;
  height: 1.7em;
  top: 0.15em;
}

/* When a list item starts with strong (definition-list pattern), give it a colored label */
.markdown ul > li > strong:first-child,
article > ul > li > strong:first-child,
.markdown ol > li > strong:first-child,
article > ol > li > strong:first-child {
  color: var(--color-primary-dark);
}

/* Footer & site-nav lists: keep them clean (no markers) */
.site-footer ul,
.site-nav,
.cta-grid,
.section-intro__sublist,
.related-grid,
.page__rail ul,
.breadcrumbs {
  list-style: none;
}

.site-footer ul,
.page__rail ul {
  padding-left: 0;
  display: block;
}

.site-footer ul > li::before,
.page__rail ul > li::before {
  display: none;
}

.site-footer ul > li,
.page__rail ul > li {
  padding-left: 0;
  margin: 0 0 0.5em;
}

/* Section-intro sublist: keep the arrow marker we already defined */
.section-intro__sublist > li {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.section-intro__sublist > li::before {
  display: none;
}

/* Definition-style list — paragraphs that follow a bold lead-in look cleaner */
.markdown ul > li > p,
article > ul > li > p,
.markdown ol > li > p,
article > ol > li > p {
  margin: 0.3em 0;
}

blockquote {
  margin: 1.5em 0;
  padding: 1em 1.25em;
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-soft);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-heading);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Inline code & code blocks
   ============================================================ */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

:not(pre) > code {
  background: var(--color-inline-code-bg);
  color: var(--color-inline-code-text);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-weight: 500;
  white-space: nowrap;
  border: none;
}

pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  border-radius: var(--radius-md);
  padding: 1.1em 1.2em;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.55;
  border: 1px solid var(--color-border);
  margin: 1.25em 0;
  position: relative;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
  font-size: inherit;
  white-space: pre;
}

/* Copy button on code blocks */
.codeblock {
  position: relative;
}

.codeblock pre {
  padding-top: 2.4em;
}

.copy-btn {
  position: absolute;
  top: 0.6em;
  right: 0.6em;
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.25em 0.7em;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  z-index: 2;
}

.copy-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.copy-btn.copied {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}

/* Prism token overrides for light theme */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6b7280;
  font-style: italic;
}
.token.punctuation { color: #475569; }
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted { color: #b45309; }
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted { color: #047857; }
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string { color: var(--color-secondary); }
.token.atrule,
.token.attr-value,
.token.keyword { color: var(--color-primary-dark); font-weight: 600; }
.token.function,
.token.class-name { color: var(--color-secondary); }
.token.regex,
.token.important,
.token.variable { color: var(--color-accent); }

/* Mermaid container */
.mermaid {
  margin: 1.5em 0;
  text-align: center;
  background: var(--color-surface);
  padding: 1.25em;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow-x: auto;
}

/* ============================================================
   Tables (responsive scroll)
   ============================================================ */
.markdown table,
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.93em;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: block;
  overflow-x: auto;
  white-space: normal;
}

.markdown table thead,
article table thead {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
}

.markdown table th,
article table th {
  text-align: left;
  padding: 0.85em 1em;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 0;
}

.markdown table td,
article table td {
  padding: 0.75em 1em;
  border-top: 1px solid var(--color-border);
  vertical-align: top;
}

.markdown table tbody tr:nth-child(even),
article table tbody tr:nth-child(even) {
  background: var(--color-bg);
}

.markdown table tbody tr:hover,
article table tbody tr:hover {
  background: var(--color-primary-soft);
}

/* ============================================================
   Task lists
   ============================================================ */
.markdown ul li.task-list-item,
article ul li.task-list-item,
li.task-list-item {
  list-style: none;
  margin-left: -1.4em;
  padding-left: 0;
}

li.task-list-item input.task-list-item-checkbox,
li.task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid var(--color-border-strong);
  border-radius: 4px;
  vertical-align: -2px;
  margin-right: 0.55em;
  cursor: pointer;
  background: var(--color-surface);
  transition: all 0.2s var(--ease);
  display: inline-block;
  position: relative;
}

li.task-list-item input[type="checkbox"]:hover {
  border-color: var(--color-primary);
}

li.task-list-item input[type="checkbox"]:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

li.task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: -1px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

li.task-list-item:has(input[type="checkbox"]:checked) {
  color: var(--color-text-soft);
  text-decoration: line-through;
}

/* Hide leading bullet dot on any li that contains a checkbox */
li:has(> input[type="checkbox"]:first-child),
li.task-list-item {
  list-style: none;
}

/* ============================================================
   Layout primitives
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.container--wide {
  max-width: var(--container-wide);
}

.container--narrow {
  max-width: var(--container-narrow);
}

main {
  min-height: 60vh;
  padding: var(--space-7) 0 var(--space-9);
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-heading);
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 0;
  letter-spacing: -0.01em;
}

.site-brand:hover {
  color: var(--color-primary);
  border-bottom-color: transparent;
}

.site-brand__logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.site-brand__name {
  display: inline-block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  border-bottom: 0;
  transition: all 0.2s var(--ease);
}

.site-nav__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.site-nav__link:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  border-bottom-color: transparent;
}

.site-nav__link.is-current {
  background: var(--color-primary);
  color: #fff;
}

.site-nav__link.is-current:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

@media (max-width: 720px) {
  .site-nav__link span.label {
    display: none;
  }
  .site-nav__link {
    padding: 0.45rem;
  }
  .site-brand__name {
    display: none;
  }
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: var(--color-heading);
  color: #cbd5e1;
  padding: var(--space-7) 0 var(--space-6);
  margin-top: var(--space-8);
}

.site-footer__grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1.4fr 1fr 1fr;
}

@media (max-width: 720px) {
  .site-footer__grid {
    grid-template-columns: 1fr;
  }
}

.site-footer h4,
.site-footer__label {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 var(--space-3);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer li {
  margin-bottom: 0.5em;
}

.site-footer a {
  color: #cbd5e1;
  border-bottom: 0;
}

.site-footer a:hover {
  color: #fff;
  border-bottom-color: transparent;
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: var(--space-3);
}

.site-footer__brand svg {
  width: 36px;
  height: 36px;
}

.site-footer__tagline {
  color: #94a3b8;
  font-size: 0.92rem;
  max-width: 38ch;
}

.site-footer__copy {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: var(--space-4);
  margin-top: var(--space-5);
  color: #94a3b8;
  font-size: 0.85rem;
  text-align: center;
}

/* ============================================================
   Hero (homepage)
   ============================================================ */
.hero {
  text-align: center;
  padding: var(--space-6) 0 var(--space-7);
}

.hero__logo {
  margin: 0 auto var(--space-5);
  width: clamp(120px, 18vw, 200px);
  height: auto;
  filter: drop-shadow(0 10px 20px rgba(15, 118, 110, 0.18));
}

.hero h1 {
  margin: 0 auto var(--space-4);
  max-width: 22ch;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.hero__lead {
  font-size: clamp(1rem, 0.92rem + 0.5vw, 1.2rem);
  color: var(--color-text-muted);
  max-width: 70ch;
  margin: 0 auto var(--space-4);
  line-height: 1.7;
}

.cta-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin: var(--space-6) auto 0;
  max-width: 1000px;
}

.cta-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--color-heading);
  font-weight: 600;
  text-align: left;
  border-bottom: 0;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.cta-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  color: var(--color-primary-dark);
  border-color: var(--color-primary-soft);
  border-bottom-color: var(--color-primary-soft);
}

.cta-card__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
}

.cta-card__icon svg {
  width: 28px;
  height: 28px;
}

.cta-card__icon.icon-teal { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.cta-card__icon.icon-coral { background: var(--color-accent-soft); color: var(--color-accent); }
.cta-card__icon.icon-indigo { background: var(--color-secondary-soft); color: var(--color-secondary); }
.cta-card__icon.icon-sun { background: #fef3c7; color: var(--color-warning); }

.cta-card__title {
  font-size: 1rem;
  margin: 0 0 0.1em;
  line-height: 1.3;
}

.cta-card__sub {
  font-size: 0.85rem;
  color: var(--color-text-soft);
  font-weight: 500;
  line-height: 1.4;
}

/* Section intro cards on home */
.section-intros {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin: var(--space-7) 0;
}

.section-intro {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.section-intro:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.section-intro h3 {
  margin-top: 0;
}

.section-intro h3 a {
  color: var(--color-primary-dark);
  border-bottom: 0;
}

.section-intro h3 a:hover {
  color: var(--color-primary);
}

.section-intro__sublist {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 0;
  display: grid;
  gap: 0.4em;
}

.section-intro__sublist a {
  display: inline-block;
  font-size: 0.92rem;
  padding: 0.15em 0;
  border-bottom: 0;
  color: var(--color-text-muted);
}

.section-intro__sublist a::before {
  content: "→ ";
  color: var(--color-primary);
  font-weight: 700;
}

.section-intro__sublist a:hover {
  color: var(--color-primary-dark);
}

/* ============================================================
   Content layout (article pages)
   ============================================================ */
.page {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1100px) {
  .page--with-rail {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: var(--space-7);
  }
}

.page__main {
  min-width: 0;
}

.page__rail {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  align-self: start;
  font-size: 0.92rem;
}

.page__rail h4 {
  color: var(--color-text-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 var(--space-3);
}

.page__rail ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--color-border);
}

.page__rail li {
  margin: 0;
}

.page__rail a {
  display: block;
  padding: 0.35em 0 0.35em 0.75em;
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--color-text-muted);
  border-bottom: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.page__rail a:hover {
  color: var(--color-primary-dark);
  border-left-color: var(--color-primary);
  border-bottom: 0;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.88rem;
  color: var(--color-text-soft);
  margin: 0 0 var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
  align-items: center;
}

.breadcrumbs a {
  color: var(--color-text-muted);
  border-bottom: 0;
}

.breadcrumbs a:hover {
  color: var(--color-primary-dark);
}

.breadcrumbs__sep {
  color: var(--color-border-strong);
  font-weight: 700;
}

.breadcrumbs__current {
  color: var(--color-heading);
  font-weight: 500;
}

/* Article body */
.markdown {
  font-size: 1.02rem;
}

.markdown > *:first-child {
  margin-top: 0;
}

/* Related pages */
.related {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 2px solid var(--color-primary-soft);
}

.related h2 {
  font-size: 1.25rem;
  border-bottom: 0;
  margin: 0 0 var(--space-4);
  padding-bottom: 0;
}

.related h2::before {
  display: none;
}

.related-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.related-card {
  display: block;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-primary);
  border-bottom: 0;
  color: var(--color-heading);
  font-weight: 600;
  transition: all 0.2s var(--ease);
}

.related-card:hover {
  transform: translateX(2px);
  border-color: var(--color-primary);
  border-left-color: var(--color-accent);
  background: var(--color-primary-soft);
  border-bottom: 0;
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
}

.related-card__sub {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-soft);
  font-weight: 500;
  margin-top: 0.25em;
}

/* FAQ accordion (styled <details>) */
details.faq,
.markdown details,
article details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin: 0.6em 0;
  overflow: hidden;
  transition: box-shadow 0.2s var(--ease);
}

details[open] {
  box-shadow: var(--shadow-sm);
}

details > summary {
  cursor: pointer;
  padding: 0.85em 1em;
  font-weight: 600;
  color: var(--color-heading);
  list-style: none;
  position: relative;
  padding-right: 2.5em;
  user-select: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::after {
  content: "+";
  position: absolute;
  right: 1em;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

details[open] > summary::after {
  content: "−";
  background: var(--color-primary);
  color: #fff;
}

details[open] > summary {
  border-bottom: 1px solid var(--color-border);
}

details > *:not(summary) {
  padding: 0 1em;
}

details > p:first-of-type {
  padding-top: 0.85em;
}

details > *:last-child {
  padding-bottom: 0.85em;
}

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

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Wide desktop refinements */
@media (min-width: 1400px) {
  body {
    font-size: 17px;
  }
}
