/* ==============================================
   Base Styles & CSS Reset
   Global reset, box-sizing, and default styles
   ============================================== */

/* Reset and Box Model */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* HTML Element Resets */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Headings */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-dark);
}

h1 {
  font-size: var(--font-size-h1);
}

h2 {
  font-size: var(--font-size-h2);
}

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

h4, h5, h6 {
  font-size: var(--font-size-body);
}

/* Paragraphs and Text */
p {
  margin: 0 0 var(--spacing-md) 0;
}

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

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

a:hover {
  color: var(--color-accent-yellow);
  text-decoration: underline;
}

a:focus {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: 2px;
}

/* Lists */
ul, ol {
  list-style: none;
}

li {
  margin: 0;
  padding: 0;
}

/* Code Elements */
code, pre {
  font-family: 'Monaco', 'Courier New', monospace;
  background-color: var(--color-background-secondary);
  border-radius: var(--radius-button);
  padding: var(--spacing-xs) var(--spacing-sm);
}

pre {
  overflow-x: auto;
  padding: var(--spacing-md);
}

/* Form Elements Reset */
input,
textarea,
select,
button {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  border: none;
  background: transparent;
  color: inherit;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--color-primary-dark);
}

/* Disabled State */
button:disabled,
input:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

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

th {
  font-weight: var(--font-weight-semibold);
  background-color: var(--color-background-secondary);
}

/* HR Element */
hr {
  margin: var(--spacing-lg) 0;
  border: none;
  border-top: 1px solid var(--color-border-gray);
}

/* Semantic HTML Elements */
main {
  display: block;
}

nav {
  display: block;
}

header {
  display: block;
}

footer {
  display: block;
}

section {
  display: block;
}

article {
  display: block;
}

aside {
  display: block;
}

/* Focus Outline Reset for Custom Focus Styles */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
}

/* Selection Styling */
::selection {
  background-color: var(--color-accent-yellow);
  color: var(--color-primary-dark);
}

::-moz-selection {
  background-color: var(--color-accent-yellow);
  color: var(--color-primary-dark);
}

/* Scrollbar Styling (Chromium browsers) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border-gray);
  border-radius: 4px;
}

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

/* Reduced Motion - Disable all animations */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  body {
    background: var(--color-background);
  }

  a {
    text-decoration: underline;
  }

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

  button,
  .button {
    display: none;
  }
}
