/* ==========================================================================
   GITLEAF DESIGN SYSTEM — 02. BASE
   Reset, document defaults, typography and accessibility primitives.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The sticky header must not cover anchor targets. */
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
  scroll-behavior: smooth;
  color-scheme: dark;
  /* Reserve the scrollbar so sections do not shift when the drawer locks. */
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-body);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Nothing in the design scrolls horizontally. */
  overflow-x: hidden;
}

/* The drawer sets this on <body> to stop background scrolling. */
body.is-locked {
  overflow: hidden;
}

/* --- Headings -------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-heading);
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-hero);
  font-weight: var(--fw-extrabold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-display);
}

h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
}

h3 {
  font-size: var(--fs-h3);
}

h4 {
  font-size: var(--fs-card);
}

h5 {
  font-size: var(--fs-h5);
}

h6 {
  font-size: var(--fs-small);
}

p {
  text-wrap: pretty;
}

/* --- Links ---------------------------------------------------------------- */
a {
  color: var(--color-link);
  text-decoration-color: var(--color-accent-45);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: var(--transition-colors), text-decoration-color var(--duration) var(--ease-out);
}

a:hover {
  text-decoration-color: currentcolor;
}

/* --- Lists ---------------------------------------------------------------- */
ul,
ol {
  padding-left: 1.3em;
}

li + li {
  margin-top: var(--space-2);
}

/* --- Media ---------------------------------------------------------------- */
img,
svg,
video,
canvas,
picture {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

svg {
  flex: none;
}

/* --- Forms ---------------------------------------------------------------- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

textarea {
  resize: vertical;
}

/* --- Tables --------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
}

/* --- Code ----------------------------------------------------------------- */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* --- Rules ---------------------------------------------------------------- */
hr {
  height: 1px;
  background-color: var(--color-border);
  border: 0;
}

/* --- Selection ------------------------------------------------------------ */
::selection {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

/* --- Focus ---------------------------------------------------------------- */
/* Pointer users do not see a ring; keyboard users always do. */
:focus {
  outline: none;
}

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

/* --- Accessibility helpers ------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  font-family: var(--font-heading);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(calc(-100% - var(--space-5)));
  transition: transform var(--duration) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-offset: 2px;
}

/* --- Reduced motion ------------------------------------------------------- */
/* Honour the OS setting: remove transitions, animations and smooth scrolling,
   and make every scroll-reveal element start in its final state. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* --- Print ---------------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .site-footer__base,
  .back-to-top,
  .cta-band,
  .nav-drawer {
    display: none !important;
  }

  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}
