/* ============================================================
   GLOBAL STYLES
   ============================================================ */

/* ── Reset & box model ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Accessibility: reduced 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;
  }
}

/* ── Scroll offset for sticky header ── */
html {
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
  scroll-behavior: smooth;
}

/* ── Base ── */
body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ── Page wrapper ── */
.page-wrapper {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

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

h1 { font-size: clamp(var(--font-size-3xl), 5vw, var(--font-size-5xl)); margin-top: 0; }
h2 { font-size: clamp(var(--font-size-2xl), 3.5vw, var(--font-size-3xl)); color: var(--color-primary-800); }
h3 { font-size: clamp(var(--font-size-xl), 2.5vw, var(--font-size-2xl));  color: var(--color-primary-700); }
h4 { font-size: var(--font-size-lg); color: var(--color-primary-700); }

/* Anchor links on headings — wraps the full heading text */
.header-anchor {
  color: inherit;
  text-decoration: none;
}
.header-anchor::after {
  content: ' #';
  font-size: 0.7em;
  font-weight: 400;
  opacity: 0;
  color: var(--color-primary-400);
  transition: opacity var(--duration-fast) var(--easing-standard);
}
h2:hover .header-anchor::after,
h3:hover .header-anchor::after,
h4:hover .header-anchor::after,
.header-anchor:focus-visible::after {
  opacity: 1;
}

/* ── Gradient text utility ── */
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Body text ── */
p {
  margin-bottom: var(--space-5);
  color: var(--color-text-body);
  line-height: var(--line-height-relaxed);
}

/* ── Links ── */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast) var(--easing-standard),
              text-decoration-color var(--duration-fast) var(--easing-standard);
}
a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-hover);
}
a:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── Inline code ── */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: rgba(124, 58, 237, 0.07);
  color: var(--color-primary-700);
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
  /* no border — blends with surrounding prose without creating boxes */
}

/* ── Lists ── */
ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-5);
}
li {
  margin-bottom: var(--space-2);
  color: var(--color-text-body);
  line-height: var(--line-height-relaxed);
}
li > ul, li > ol { margin-top: var(--space-2); margin-bottom: 0; }

/* ── Blockquotes ── */
blockquote {
  margin: var(--space-8) 0;
  padding: var(--space-4) var(--space-6);
  border-left: 4px solid var(--color-primary-400);
  background: var(--color-primary-50);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
blockquote p { color: var(--color-primary-800); margin-bottom: 0; }

/* ── Horizontal rule ── */
hr {
  border: none;
  height: 2px;
  background: var(--gradient-brand);
  margin: var(--space-10) 0;
  border-radius: var(--radius-full);
  opacity: 0.3;
}

/* ── Strong / emphasis ── */
strong { font-weight: var(--font-weight-semibold); color: var(--color-primary-900); }
em { font-style: italic; }

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-6) 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
thead th {
  background: var(--gradient-brand-soft);
  color: var(--color-primary-900);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 2px solid var(--color-border-accent);
}
tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-body);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background-color: var(--color-primary-50); }
tbody tr:hover { background-color: var(--color-primary-100); }

/* ── Images ── */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--color-primary-700);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition: top var(--duration-fast);
  z-index: calc(var(--z-sticky) + 1);
}
.skip-link:focus { top: var(--space-4); }

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

