/**
 * Base Styles
 * 
 * Foundation styles including:
 * - CSS Reset
 * - Box model normalization
 * - Typography defaults
 * - Global element styles
 */

/* ===== CSS RESET & NORMALIZATION ===== */

/**
 * Modern CSS Reset
 * Based on Josh Comeau's Custom CSS Reset
 */

/* Use a more intuitive box-sizing model */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Remove default margin and padding from common elements */
body,
h1, h2, h3, h4, h5, h6,
p,
figure,
blockquote,
dl, dd {
  margin: 0;
}

/* Remove list styles on ul, ol elements with a list role */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Set core root defaults */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--navbar-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  overflow-x: hidden;
  text-rendering: optimizeSpeed;
}

/* Make images easier to work with */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove default button styles */
button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

/* Remove default link styles */
a {
  color: inherit;
  text-decoration: none;
}

/* Remove all animations and transitions for people who prefer not to see them */
@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;
  }
}

/* ===== TYPOGRAPHY ===== */

/**
 * Fluid Typography
 * Scales naturally between breakpoints
 */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-text-primary);
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: var(--space-md);
}

h4 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-sm);
}

h5 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-sm);
}

h6 {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-sm);
}

p {
  margin-bottom: var(--space-md);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

/* Last paragraph in a container shouldn't have margin */
p:last-child {
  margin-bottom: 0;
}

/* Strong and emphasis */
strong,
b {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

em,
i {
  font-style: italic;
}

/* Small text */
small {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Code and preformatted text */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.125rem 0.375rem;
  background-color: var(--color-bg-tertiary);
  border-radius: var(--border-radius-sm);
  color: var(--color-primary-light);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  padding: var(--space-md);
  background-color: var(--color-bg-secondary);
  border-radius: var(--border-radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

pre code {
  padding: 0;
  background: none;
}

/* ===== LINKS ===== */

a {
  color: var(--color-primary);
  transition: color var(--transition-base);
}

a:hover {
  color: var(--color-primary-light);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

/* ===== LISTS ===== */

ul,
ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

li {
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

/* ===== HORIZONTAL RULE ===== */

hr {
  height: 1px;
  background-color: var(--color-border);
  border: none;
  margin: var(--space-2xl) 0;
}

/* ===== SELECTION ===== */

::selection {
  background-color: var(--color-primary);
  color: white;
}

::-moz-selection {
  background-color: var(--color-primary);
  color: white;
}

/* ===== SCROLLBAR STYLING ===== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-tertiary);
  border-radius: var(--border-radius-full);
  border: 2px solid var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-bg-tertiary) var(--color-bg-secondary);
}

/* ===== FOCUS STYLES ===== */

/**
 * Focus styles for keyboard navigation
 * Important for accessibility
 */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== UTILITY CLASSES ===== */

/* Screen reader only text (for accessibility) */
.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;
}

/* Skip to main content link (for accessibility) */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--space-md);
  z-index: 100;
  transition: top var(--transition-base);
}

.skip-to-main:focus {
  top: 0;
}

/* Gradient text utility */
.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Text alignment utilities */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

/* Display utilities */
.hidden {
  display: none;
}

.visible {
  display: block;
}

/* Flexbox utilities */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Container utility */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-xl);
  padding-right: var(--space-xl);
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}