/**
 * BIOSEN CHEMICAL INDUSTRIES — BASE STYLES
 * Phase 01: Static Website Foundation
 * 
 * Provides CSS reset, accessible typography base, language font switching,
 * focus visible management, and accessibility primitives.
 */

/* 1. Box Sizing & Document Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%; /* 16px default */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

/* 2. Language-Specific Typography Base */
html[lang="ar"],
body[lang="ar"] {
  font-family: var(--font-family-arabic);
  line-height: var(--line-height-loose);
  letter-spacing: var(--letter-spacing-normal);
}

html[lang="en"],
body[lang="en"] {
  font-family: var(--font-family-latin);
  line-height: var(--line-height-relaxed);
  letter-spacing: var(--letter-spacing-normal);
}

body {
  min-height: 100vh;
  background-color: var(--color-bg-body);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  display: flex;
  flex-direction: column;
}

/* 3. Typography Elements */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  text-wrap: balance;
}

h1 {
  font-size: clamp(var(--font-size-2xl), 5vw, var(--font-size-4xl));
  margin-block-end: var(--space-4);
  letter-spacing: var(--letter-spacing-tight);
}

h2 {
  font-size: clamp(var(--font-size-xl), 3.5vw, var(--font-size-3xl));
  margin-block-end: var(--space-4);
}

h3 {
  font-size: clamp(var(--font-size-lg), 2.5vw, var(--font-size-2xl));
  margin-block-end: var(--space-3);
}

h4 {
  font-size: var(--font-size-xl);
  margin-block-end: var(--space-2);
}

h5 {
  font-size: var(--font-size-lg);
  margin-block-end: var(--space-2);
}

h6 {
  font-size: var(--font-size-base);
  margin-block-end: var(--space-2);
}

p {
  margin-block-end: var(--space-4);
  color: var(--color-text-secondary);
}

p:last-child {
  margin-block-end: 0;
}

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

/* 4. Media Elements */
img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

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

a:hover {
  color: var(--color-primary-800);
}

/* 6. Form Elements & Buttons Base */
button,
input,
optgroup,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

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

/* 8. Accessibility Focus System */
:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Skip to Main Content Link */
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: var(--space-4);
  background: var(--color-primary-700);
  color: var(--color-neutral-0);
  padding: var(--space-3) var(--space-5);
  font-weight: var(--font-weight-semibold);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-skip-link);
  transition: top var(--transition-fast);
  text-decoration: none;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 0;
  outline: var(--focus-ring-width) solid var(--color-accent-500);
  outline-offset: 2px;
}

/* Screen-Reader Only Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* 9. 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;
  }
}
