/* ============================================
   Base Styles - Reset & Typography
   ============================================ */

/* ========== Modern CSS Reset ========== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  color: var(--color-text);
  background-color: var(--color-background);
}

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

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

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

#root,
#__next {
  isolation: isolate;
}

/* ========== Typography ========== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

h1 { 
  font-size: var(--text-5xl);
  margin-bottom: var(--space-6);
}

h2 { 
  font-size: var(--text-4xl);
  margin-bottom: var(--space-5);
}

h3 { 
  font-size: var(--text-3xl);
}

h4 { 
  font-size: var(--text-2xl);
}

h5 { 
  font-size: var(--text-xl);
}

h6 { 
  font-size: var(--text-lg);
}

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-colors);
}

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

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

code {
  font-family: var(--font-code);
  font-size: 0.9em;
  background-color: var(--color-surface);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--color-accent);
}

pre {
  background-color: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  background-color: transparent;
  padding: 0;
}

ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

li {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

strong {
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

em {
  font-style: italic;
}

blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: var(--space-4);
  margin: var(--space-6) 0;
  font-style: italic;
  color: var(--color-text-secondary);
}

hr {
  border: none;
  border-top: var(--border-width) solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ========== Utility Classes ========== */

/* Text Alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Text Colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-brand { color: var(--color-primary); }

/* Display Utilities */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

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

/* Spacing Utilities */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.mx-auto { 
  margin-left: auto;
  margin-right: auto;
}

/* Max Width */
.max-w-prose {
  max-width: 65ch;
}

.max-w-screen-sm { max-width: var(--container-sm); }
.max-w-screen-md { max-width: var(--container-md); }
.max-w-screen-lg { max-width: var(--container-lg); }
.max-w-screen-xl { max-width: var(--container-xl); }

/* ========== Accessibility ========== */

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Skip to Content Link */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 0;
  background-color: var(--color-primary);
  color: white;
  padding: var(--space-3) var(--space-6);
  text-decoration: none;
  z-index: var(--z-tooltip);
  border-radius: var(--radius-md);
}

.skip-to-content:focus {
  top: var(--space-4);
  left: var(--space-4);
}

/* 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;
  }
}

/* ========== Selection ========== */

::selection {
  background-color: var(--color-primary);
  color: white;
}

::-moz-selection {
  background-color: var(--color-primary);
  color: white;
}

/* ========== Scrollbar ========== */

::-webkit-scrollbar {
  width: 12px;
}

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

::-webkit-scrollbar-thumb {
  background-color: var(--color-surface);
  border-radius: var(--radius-full);
  border: 3px solid var(--color-background);
}

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