/*
 * base.css — modern reset, element defaults, and foundational a11y utilities.
 * Consumes tokens.css; introduces no arbitrary values (D-08, D-26). Includes the
 * print stylesheet and the prefers-reduced-motion block (D-30, D-15).
 */

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

* {
  margin: 0;
}

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

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* ---- Element defaults -------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-4xl);
  font-weight: var(--weight-display);
}
h2 {
  font-size: var(--text-3xl);
}
h3 {
  font-size: var(--text-2xl);
}
h4 {
  font-size: var(--text-xl);
}
h5 {
  font-size: var(--text-lg);
}
h6 {
  font-size: var(--text-base);
}

p {
  text-wrap: pretty;
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
  transition: color var(--motion-fast) var(--ease-standard);
}

a:hover {
  color: var(--color-accent-hover);
}

ul,
ol {
  padding-inline-start: var(--space-md);
}

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

code {
  background-color: var(--color-surface-2);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
}

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

/* ---- Focus (D-29; refined in components) ------------------------------- */
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* The skip-link target is a focusable container, not a widget — no focus ring. */
#main:focus {
  outline: none;
}

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

/* Skip-to-content link: off-screen until focused (D-29) */
.skip-link {
  position: absolute;
  left: var(--space-sm);
  top: -4rem;
  z-index: var(--z-overlay);
  padding: var(--space-2xs) var(--space-sm);
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: top var(--motion-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-sm);
}

/* ---- Reduced motion (D-15 — hard requirement) -------------------------- */
@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;
  }
}

/* ---- Print (D-30 — recruiters print/PDF portfolios) -------------------- */
@media print {
  :root {
    color-scheme: light;
  }

  body {
    background: #fff;
    color: #000;
  }

  /* Elements marked .no-print (nav, theme toggle) are screen-only */
  .no-print {
    display: none !important;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Expand external URLs so a printed page stays useful */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  .section {
    padding-block: var(--space-lg);
    break-inside: avoid;
  }
}
