/* ==========================================================================
   Comprehensive Base CSS Reset & Defaults (No Colors)
   Targets all standard HTML elements
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Box Sizing & Document Setup
   -------------------------------------------------------------------------- */
/* Intuitive box-sizing for all elements and pseudo-elements */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent font size inflation on mobile devices */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   2. Universal Margin & Padding Reset
   -------------------------------------------------------------------------- */
/* Strip defaults from all elements that commonly have unpredictable margins/padding */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video, dialog {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* --------------------------------------------------------------------------
   3. HTML5 Block Elements
   -------------------------------------------------------------------------- */
/* Ensure older browsers render modern semantic elements correctly */
article, aside, details, figcaption, figure, 
footer, header, hgroup, main, menu, nav, section, summary {
  display: block;
}

/* --------------------------------------------------------------------------
   4. Body & Typography Defaults
   -------------------------------------------------------------------------- */
body {
  min-height: 100vh;
  line-height: 1.5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Prevent text overflows */
p, h1, h2, h3, h4, h5, h6, li, dd, dt, blockquote {
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Better typographic wrapping */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   5. Lists & Quotes
   -------------------------------------------------------------------------- */
/* Remove list styling by default */
ol, ul, menu {
  list-style: none;
}

/* Handle quotes properly */
blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

/* --------------------------------------------------------------------------
   6. Media & Embedded Elements
   -------------------------------------------------------------------------- */
/* Responsive behavior for all media types */
img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Ensure SVGs don't capture click events unless explicitly styled to */
svg {
  pointer-events: none;
}

svg[role="button"],
svg[role="link"] {
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   7. Tables
   -------------------------------------------------------------------------- */
/* Remove complex spacing and collapse borders for standard grid behavior */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* --------------------------------------------------------------------------
   8. Form Elements (Inputs, Buttons, Textareas, Selects)
   -------------------------------------------------------------------------- */
/* Force form elements to inherit typographic styles from their parents */
input, button, textarea, select, optgroup {
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

/* Improve button clickability and default styling */
button, 
[type="button"], 
[type="reset"], 
[type="submit"] {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* Disabled states */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

/* Textarea resizing */
textarea {
  resize: vertical; /* Prevent horizontal resizing which breaks layouts */
  min-height: 50px;
}

/* Remove default focus outlines in a safe way (replace with your own custom focus states later) */
:focus {
  outline: 2px solid transparent; /* Keeps accessibility active but invisible until customized */
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   9. Interactive & Miscellaneous Elements
   -------------------------------------------------------------------------- */
/* Better link readability */
a {
  text-decoration-skip-ink: auto;
  color: inherit; /* Inherits text color unless specified */
}

/* Keep dialogs above everything but reset their default complex styling */
dialog {
  background-color: transparent;
  border: none;
  padding: 0;
}

/* Address hidden attribute */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   10. Accessibility (A11y)
   -------------------------------------------------------------------------- */
/* Respect user preferences for reduced motion */
@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;
    scroll-behavior: auto !important;
  }
}

/* Visually hide elements but keep them available for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}