/**
 * Base Styles
 * Includes: CSS reset, typography, utility classes, and pixel grid utilities
 */

/* ===== CSS RESET / NORMALIZE ===== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100vh;
}

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

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

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

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

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

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

h5, h6 {
  font-size: var(--text-base);
}

p {
  margin-bottom: var(--space-md);
  color: var(--color-text-secondary);
}

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

a {
  color: var(--color-accent-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-sage-dark);
  text-decoration: underline;
}

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

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

ul, ol {
  list-style: none;
}

ul.styled-list,
ol.styled-list {
  list-style-position: inside;
  padding-left: var(--space-md);
}

ul.styled-list {
  list-style-type: square;
}

/* ===== IMAGES ===== */

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

img[loading="lazy"] {
  content-visibility: auto;
}

/* ===== FORMS ===== */

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

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

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

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  z-index: 1000;
  font-weight: var(--weight-bold);
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* Focus styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

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

/* ===== PIXEL UTILITIES ===== */

/* Pixel border utility */
.px-border {
  border: var(--border-width-md) solid var(--color-border);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Pixel corners using layered box-shadows */
.px-corners {
  position: relative;
}

.px-corners::before,
.px-corners::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--color-border);
}

.px-corners::before {
  top: -2px;
  left: -2px;
}

.px-corners::after {
  top: -2px;
  right: -2px;
}

/* Pixel shadows */
.px-shadow-sm {
  box-shadow: var(--shadow-sm);
}

.px-shadow-md {
  box-shadow: var(--shadow-md);
}

.px-shadow-lg {
  box-shadow: var(--shadow-lg);
}

/* Pixel grid helper for 8px snapping */
.px-grid {
  background-image: 
    linear-gradient(to right, rgba(122, 173, 125, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(122, 173, 125, 0.1) 1px, transparent 1px);
  background-size: 8px 8px;
}

/* ===== UTILITY CLASSES ===== */

/* Spacing utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

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

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }

.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

.font-bold { font-weight: var(--weight-bold); }
.font-semibold { font-weight: var(--weight-semibold); }

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

/* Flexbox utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Width utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.max-w-full { max-width: 100%; }

/* Container */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--section-padding-x);
  padding-right: var(--section-padding-x);
}

/* Responsive show/hide */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .show-mobile { display: none !important; }
}

/* ===== ANIMATIONS ===== */

@keyframes blink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0.3;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Animation utility classes */
.animate-blink {
  animation: blink 2s infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-fade-in {
  animation: fadeIn var(--duration-base) var(--ease-out);
}

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

@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  a {
    text-decoration: underline;
  }
  
  .px-shadow-sm,
  .px-shadow-md,
  .px-shadow-lg {
    box-shadow: none;
  }
}