/* 
 * DryAlle Design System - Modern CSS Reset
 * Based on modern-normalize + custom optimizations
 * 30-Year CSS Expert Implementation
 */

/* ================================
   MODERN CSS RESET - 2025 Edition
   ================================ */

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

/* Remove default margin and padding */
* {
  margin: 0;
  padding: 0;
}

/* ================================
   DOCUMENT & ROOT SETUP
   ================================ */

html {
  /* Prevent iOS font size adjust after orientation change */
  -webkit-text-size-adjust: 100%;
  /* Set default tab size */
  tab-size: 4;
  /* Enable smooth scrolling */
  scroll-behavior: smooth;
  /* Improve text rendering */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  /* Set default font stack */
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-gray-700);
  background-color: var(--color-bg-primary);
  /* Prevent horizontal scrolling */
  overflow-x: hidden;
  /* Improve text rendering on high-DPI displays */
  -webkit-font-feature-settings: "kern" 1;
  font-feature-settings: "kern" 1;
  font-kerning: normal;
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-gray-900);
  /* Prevent automatic font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

p {
  margin-bottom: var(--spacing-4);
  line-height: var(--line-height-relaxed);
}

/* ================================
   LIST NORMALIZATION
   ================================ */

ul, ol {
  list-style: none;
}

/* Restore semantic lists */
article ul,
article ol,
.content ul,
.content ol {
  list-style: revert;
  margin: var(--spacing-4) 0;
  padding-inline-start: var(--spacing-8);
}

/* ================================
   LINK NORMALIZATION
   ================================ */

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-base);
  /* Improve touch targets */
  touch-action: manipulation;
}

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

/* ================================
   FORM ELEMENT NORMALIZATION
   ================================ */

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: var(--line-height-normal);
  margin: 0;
  color: inherit;
}

button,
select {
  text-transform: none;
}

/* Remove default button styles */
button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
  background: transparent;
  border: none;
  cursor: pointer;
  /* Improve touch targets */
  touch-action: manipulation;
  /* Prevent double-tap zoom on iOS */
  -webkit-touch-callout: none;
}

/* Remove default focus outline, we'll add our own */
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

/* Custom focus styles */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ================================
   INPUT SPECIFIC NORMALIZATION
   ================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  padding: var(--spacing-3) var(--spacing-4);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--border-radius-input);
  background-color: var(--color-white);
  transition: var(--transition-base);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
select:hover,
textarea:hover {
  border-color: var(--color-gray-400);
}

/* Remove default appearance for search inputs */
input[type="search"] {
  -webkit-appearance: textfield;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/* ================================
   MEDIA ELEMENT NORMALIZATION
   ================================ */

img,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  /* Prevent layout shifts */
  font-style: italic;
  /* Improve image quality */
  image-rendering: high-quality;
}

/* SVG optimization */
svg {
  display: block;
  max-width: 100%;
  height: auto;
  fill: currentColor;
}

/* ================================
   TABLE NORMALIZATION
   ================================ */

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

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

th {
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-900);
}

/* ================================
   UTILITY CLASSES - CRITICAL
   ================================ */

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

/* Hide element while keeping it accessible */
.visually-hidden {
  position: absolute !important;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Skip links for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: var(--color-white);
  padding: var(--spacing-2) var(--spacing-4);
  border-radius: var(--border-radius-base);
  text-decoration: none;
  z-index: var(--z-index-tooltip);
  transition: var(--transition-base);
}

.skip-link:focus {
  top: 6px;
}

/* ================================
   MOTION PREFERENCES
   ================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

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

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

  img {
    page-break-inside: avoid;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }

  p {
    orphans: 3;
    widows: 3;
  }
}

/* ================================
   HIGH CONTRAST MODE SUPPORT
   ================================ */

@media (prefers-contrast: high) {
  :root {
    --color-gray-300: #000000;
    --color-gray-500: #000000;
    --color-gray-700: #000000;
  }
  
  button,
  input,
  select,
  textarea {
    border: 2px solid currentColor;
  }
}