/*
 * Base Reset and Theme Application
 * Global styles that apply theme to body and html
 */

/* Apply theme to root elements */
html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--theme-bg);
  color: var(--theme-text-primary);
  font-family: var(--font-family-sans);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-body);
  line-height: 1.6;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Ensure all text elements inherit theme colors */
h1, h2, h3, h4, h5, h6 {
  color: var(--theme-text-primary);
  margin-top: 0;
}

p {
  color: var(--theme-text-primary);
}

a {
  color: var(--theme-accent);
  text-decoration: none;
  transition: color var(--transition-speed);
}

a:hover {
  color: var(--theme-highlight);
}

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

/* Visually-hidden content that remains available to screen readers. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global focus-visible fallback: every interactive element gets a
   discernible keyboard focus indicator unless a component overrides it.
   Pointer interaction does not trigger :focus-visible, so mouse users
   are unaffected. */
:focus-visible {
  outline: 2px solid var(--theme-text-primary);
  outline-offset: 2px;
}

/* Respect the user's reduced-motion preference. Components that rely on
   transitions/animations for presentation collapse them to near-instant
   so users with vestibular sensitivities are not affected (WCAG 2.3.3). */
@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;
  }
}

/* Apply theme colors to common elements */
input, textarea, select {
  background-color: var(--theme-surface);
  color: var(--theme-text-primary);
  border-color: var(--theme-border);
}

/* Main content areas should use theme background */
main, article, section {
  background-color: var(--theme-bg);
  color: var(--theme-text-primary);
}

/* Form elements */
fieldset {
  border-color: var(--theme-border);
}

legend {
  color: var(--theme-text-primary);
}

/* Table elements */
table {
  background-color: var(--theme-surface);
  color: var(--theme-text-primary);
}

th {
  background-color: var(--theme-bg);
  color: var(--theme-text-primary);
  border-color: var(--theme-border);
}

td {
  border-color: var(--theme-border);
}

/* Code blocks */
pre, code {
  background-color: var(--theme-surface);
  color: var(--theme-text-primary);
  border-color: var(--theme-border);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--theme-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--theme-border);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--theme-text-secondary);
}