/**
 * CSS Reset & Base Styles
 * Normalize browser differences and establish base element styles
 */

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

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

/* ========================================
   DOCUMENT & BODY
   ======================================== */

html {
  font-size: 16px;
  line-height: var(--line-height-normal);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-background);
}

/* ========================================
   HEADINGS
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
}

h1 {
  font-size: var(--font-size-xxxl);
  margin-bottom: var(--spacing-lg);
}

h2 {
  font-size: var(--font-size-xxl);
  margin-bottom: var(--spacing-lg);
}

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

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

h5 {
  font-size: var(--font-size-md);
}

h6 {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

/* ========================================
   TEXT ELEMENTS
   ======================================== */

p {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

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

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

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

strong, b {
  font-weight: var(--font-weight-bold);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

mark {
  background-color: #fff3cd;
  padding: 0.1em 0.2em;
}

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

ul, ol {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  padding-left: var(--spacing-lg);
}

li {
  margin-bottom: var(--spacing-xs);
}

ul ul,
ul ol,
ol ul,
ol ol {
  margin-bottom: 0;
}

/* Remove default list styling for navigation */
nav ul,
nav ol {
  list-style: none;
  padding-left: 0;
}

/* ========================================
   CODE & PREFORMATTED TEXT
   ======================================== */

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 0.1em 0.3em;
  background-color: var(--color-background-code);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
}

pre {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-md);
  background-color: var(--color-background-code);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--line-height-relaxed);
}

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

/* ========================================
   BLOCKQUOTES
   ======================================== */

blockquote {
  margin: 0 0 var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  border-left: 4px solid var(--color-border);
  background-color: var(--color-background-alt);
  font-style: italic;
}

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

/* ========================================
   HORIZONTAL RULE
   ======================================== */

hr {
  margin: var(--spacing-lg) 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: 0 0 var(--spacing-md);
}

figcaption {
  margin-top: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

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

table {
  width: 100%;
  margin-bottom: var(--spacing-md);
  border-collapse: collapse;
}

th, td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: var(--font-weight-bold);
  background-color: var(--color-background-alt);
}

tr:hover {
  background-color: var(--color-background-alt);
}

/* ========================================
   FORMS & INPUTS
   Note: Most form elements will be removed in Phase 3B
   These styles preserved for display-only elements
   ======================================== */

button,
input,
optgroup,
select,
textarea {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

button {
  cursor: pointer;
}

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

/* Remove default focus outline, replaced with custom in components */
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

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

/* Screen reader only content */
.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 */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
  z-index: var(--z-tooltip);
}

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

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

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

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

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

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

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

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

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

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

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