/* ============================================================================
   CSS Reset & Normalize
   Remove default browser styles and establish consistent baseline
   ============================================================================ */

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

html {
  /* Prevent font size adjustments in landscape mode on iOS */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0;
  padding: 0;
}

p {
  margin: 0;
  padding: 0;
}

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

a:visited {
  color: var(--color-primary-dark);
}

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

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

/* Lists */
ul,
ol,
dl {
  margin: 0;
  padding: 0;
  list-style: none;
}

li {
  list-style: none;
}

/* Buttons */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

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

/* Form elements */
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

/* Ensure images don't exceed container */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* Remove borders from images inside links */
a img {
  border: none;
}

/* Table */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* HR */
hr {
  border: none;
  border-top: var(--border-width) solid var(--color-border);
  height: 0;
  overflow: visible;
  margin: var(--spacing-lg) 0;
}

/* Code & Pre */
code,
pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
}

pre {
  overflow: auto;
  background-color: var(--color-background-alt);
  padding: var(--spacing-md);
  border-radius: var(--border-radius-md);
  line-height: var(--line-height-relaxed);
}

/* Blockquote */
blockquote {
  margin: var(--spacing-md) 0;
  padding-left: var(--spacing-md);
  border-left: 4px solid var(--color-border);
  color: var(--color-text-light);
}

/* Hidden elements */
[hidden] {
  display: none !important;
}

/* Print styles */
@media print {
  body {
    background-color: white;
  }

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

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