/* Compify Design System - Base Styles */
/* CSS Reset and foundational styles */

/* === CSS RESET === */

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

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

/* === ROOT ELEMENTS === */

html {
  /* Improve text rendering */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  
  /* Set base font size for rem calculations */
  font-size: 16px;
  
  /* Smooth scrolling */
  scroll-behavior: smooth;
}

/* Respect user's motion preferences */
@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;
  }
}

body {
  /* Typography */
  font-family: var(--font-family-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-normal);
  
  /* Colors */
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  
  /* Layout */
  min-height: 100vh;
  
  /* Improve text rendering */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === TYPOGRAPHY === */

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

h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
}

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);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

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

a:hover {
  color: var(--color-text-link-hover);
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 0.125em;
}

a:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  border-radius: var(--radius-sm);
}

/* Remove default link styles for buttons and logo */
a.btn,
a[class*="logo"],
a[class*="brand"] {
  text-decoration: none;
}

a.btn:hover,
a[class*="logo"]:hover,
a[class*="brand"]:hover {
  text-decoration: none;
}

/* Lists */
ul, ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-1);
}

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

nav li {
  margin-bottom: 0;
}

/* Text formatting */
strong, b {
  font-weight: var(--font-weight-semibold);
}

em, i {
  font-style: italic;
}

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

code {
  font-family: var(--font-family-mono);
  font-size: 0.875em;
  background-color: var(--color-bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
}

pre {
  font-family: var(--font-family-mono);
  background-color: var(--color-bg-tertiary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  border-left: 4px solid var(--color-border-secondary);
  padding-left: var(--space-4);
  margin: var(--space-4) 0;
  font-style: italic;
  color: var(--color-text-secondary);
}

/* === FORM ELEMENTS === */

/* Form controls base styles */
input,
textarea,
select,
button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Remove default button styles */
button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

/* Form inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
  appearance: none;
  background-color: var(--color-bg-primary);
  border: var(--border-width-1) solid var(--color-border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}

/* Placeholder styles */
input::placeholder,
textarea::placeholder {
  color: var(--color-text-tertiary);
  opacity: 1;
}

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

/* === MEDIA ELEMENTS === */

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

img {
  border-style: none;
}

svg {
  fill: currentColor;
}

/* === TABLE ELEMENTS === */

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

th,
td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: var(--border-width-1) solid var(--color-border-primary);
}

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

/* === 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: 0;
}

/* Skip links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  z-index: var(--z-index-skipLink);
  box-shadow: var(--shadow-lg);
  transition: top var(--transition-fast);
}

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

/* Focus visible for better keyboard navigation */
:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* === 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;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
  
  abbr[title]::after {
    content: " (" attr(title) ")";
  }
  
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
  
  pre {
    white-space: pre-wrap !important;
  }
  
  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;
  }
}

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

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

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