/**
 * CSS Reset & Base Styles
 * =======================
 * Modern CSS reset with sensible defaults.
 */

/* ===========================================
   BOX SIZING
   =========================================== */

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

/* ===========================================
   RESET MARGINS & PADDING
   =========================================== */

* {
  margin: 0;
  padding: 0;
}

/* ===========================================
   HTML & BODY
   =========================================== */

html {
  /* Smooth scrolling */
  scroll-behavior: smooth;

  /* Prevent font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* Better text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* Prevent horizontal scroll */
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);

  /* Minimum height */
  min-height: 100vh;
  min-height: 100dvh;

  /* Prevent horizontal scroll */
  overflow-x: hidden;
}

/* ===========================================
   TYPOGRAPHY DEFAULTS
   =========================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* ===========================================
   LINKS
   =========================================== */

a {
  color: inherit;
  text-decoration: none;
}

a:not([class]) {
  color: var(--color-accent);
  text-decoration-skip-ink: auto;
}

a:not([class]):hover {
  text-decoration: underline;
}

/* ===========================================
   LISTS
   =========================================== */

ul, ol {
  list-style: none;
}

/* ===========================================
   IMAGES & MEDIA
   =========================================== */

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

img {
  /* Remove border on linked images */
  border-style: none;
}

/* ===========================================
   FORM ELEMENTS
   =========================================== */

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

/* Remove default input styles */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ===========================================
   TABLES
   =========================================== */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ===========================================
   FOCUS STYLES
   =========================================== */

:focus {
  outline: none;
}

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

/* Focus visible for keyboard users only */
:focus:not(:focus-visible) {
  outline: none;
}

/* ===========================================
   SELECTION
   =========================================== */

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

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-muted);
}

/* ===========================================
   REDUCED MOTION
   =========================================== */

@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;
  }
}

/* ===========================================
   ACCESSIBILITY UTILITIES
   =========================================== */

/* Screen reader only */
.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;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-6);
  background: var(--color-accent);
  color: var(--color-text-primary);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  z-index: var(--z-tooltip);
  transition: top var(--transition-fast);
}

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

/* ===========================================
   PRINT STYLES
   =========================================== */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  img {
    max-width: 100% !important;
  }

  @page {
    margin: 2cm;
  }

  h2, h3 {
    page-break-after: avoid;
  }

  p {
    orphans: 3;
    widows: 3;
  }
}
