/* ============================================================
   K.W. Products — Base (reset + utilities)
   Loaded AFTER tokens.css, BEFORE style.css / admin.css
   ============================================================ */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings: fluid + tight */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3) 0;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-snug);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}
h1 { font-size: var(--fs-3xl); letter-spacing: var(--ls-tight); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }

p { margin: 0 0 var(--space-4) 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--color-primary-hover); }

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

ul, ol { padding-left: 1.25em; margin: 0 0 var(--space-4) 0; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

code, kbd, pre, samp { font-family: var(--font-mono); }

/* Keyboard focus — visible, never removed */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Selection */
::selection { background: var(--color-primary); color: #fff; }

/* ---------- Layout utilities ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left:  var(--container-pad);
  padding-right: var(--container-pad);
}

.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }

.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Accessibility utilities ---------- */
.sr-only, .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip-to-main link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-3);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: var(--z-toast);
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: var(--space-3); color: #fff; }

/* ---------- Image aspect ratio helpers (prevent CLS) ---------- */
.img-1x1 { aspect-ratio: 1 / 1; object-fit: cover; width: 100%; }
.img-4x3 { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.img-16x9 { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.img-21x9 { aspect-ratio: 21 / 9; object-fit: cover; width: 100%; }

/* ---------- Text utilities ---------- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-muted); }
.text-soft   { color: var(--color-text-soft); }
.text-primary{ color: var(--color-primary); }
.text-danger { color: var(--color-danger); }
.text-success{ color: var(--color-success); }
.text-sm     { font-size: var(--fs-sm); }
.text-xs     { font-size: var(--fs-xs); }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2     { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3     { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Touch target guarantee on mobile ---------- */
@media (max-width: 600px) {
  .btn, button:not(.unstyled), a.header-btn, a.btn, .tab, .qty-minus, .qty-plus, [type="submit"], [type="button"] {
    min-height: var(--touch-min);
  }
}

/* Prevent horizontal scroll surprises */
html, body { overflow-x: clip; }
