/* ============================================================
   FATAPLUS DESIGN SYSTEM — BASE
   Atoms: Reset, fluid typography, accessibility defaults
   Verified: MDN Responsive Design + clamp() best practices
   ============================================================ */

/* Reset — MDN recommended modern reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;

  /* Fluid root font-size: scales viewport without media queries */
  font-size: clamp(16px, 0.5vw + 14px, 18px);
}

body {
  font-family: var(--font-family-body);
  font-size: var(--font-body);
  line-height: var(--font-body-lh);
  background-color: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;

  /* Premium grain overlay — subtle, on substrate not content */
  position: relative;
}

/* Grain texture — opacity 3%, MDN SVG inline data URI pattern */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-base);
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Headings — BIZ UDPMincho, fluid via clamp() */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-display);
  font-weight: var(--weight-normal);  /* UDPMincho is expressive at normal */
  line-height: 1.2;
  text-wrap: balance;  /* MDN: text-wrap balance, Baseline 2023 */
}

h1 {
  font-size: var(--font-display);
  line-height: var(--font-display-lh);
  letter-spacing: var(--font-display-ls);
}

h2 {
  font-size: var(--font-h1);
  line-height: var(--font-h1-lh);
  letter-spacing: var(--font-h1-ls);
}

/* Section-level H2 */
h2.section-heading {
  font-size: var(--font-h2);
  line-height: var(--font-h2-lh);
  letter-spacing: var(--font-h2-ls);
}

h3 {
  font-size: var(--font-h3);
  line-height: var(--font-h3-lh);
  letter-spacing: var(--font-h3-ls);
}

h4 {
  font-size: var(--font-h4);
  line-height: var(--font-h4-lh);
}

/* Links — MDN semantic, no underline-fill animation (anti-slop) */
a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

a:hover {
  color: var(--brand);
}

/* Buttons reset */
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

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

/* Focus visible — MDN accessibility, WCAG 2.4.7 */
:focus-visible {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Selection */
::selection {
  background: var(--brand);
  color: var(--white);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--neutral-400);
  border-radius: var(--radius-full);
}

/* ============================================================
   ACCESSIBILITY — MDN prefers-reduced-motion
   ============================================================ */

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