/* =========================================================
   BAARI SPORTS CENTER — style.css
   Design Tokens, Obsidian Dark + Electric Chartreuse theme,
   base layout, typography, and grid systems.
   ========================================================= */

/* -------------------- DESIGN TOKENS -------------------- */
:root {
  /* Colors */
  --ink: #0A0A0A;
  --surface: #141414;
  --surface-raised: #1C1C1C;
  --surface-border: #262626;
  --accent: #C8FF00;
  --accent-dim: #a3d400;
  --accent-ink: #0A0A0A;
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0A0;
  --text-muted: #6B6B6B;
  --danger: #FF4D4D;
  --success: #37D67A;
  --warning: #FFB020;

  /* Typography */
  --font-header: 'Syne', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  /* Fluid type scale */
  --fs-h1: clamp(2.25rem, 8vw + 1rem, 4.5rem);
  --fs-h2: clamp(1.6rem, 5vw + 0.5rem, 2.75rem);
  --fs-h3: clamp(1.15rem, 3vw + 0.4rem, 1.6rem);
  --fs-body: clamp(0.95rem, 1.2vw + 0.5rem, 1.05rem);
  --fs-sm: clamp(0.8rem, 1vw + 0.3rem, 0.9rem);
  --fs-xs: clamp(0.7rem, 0.8vw + 0.3rem, 0.78rem);

  /* Spacing scale */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Layout */
  --header-height: 64px;
  --sub-nav-height: 48px;
  --max-width: 1200px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 150ms;
  --dur-mid: 260ms;
  --dur-slow: 420ms;

  /* Elevation */
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-accent-glow: 0 0 24px rgba(200, 255, 0, 0.25);

  color-scheme: dark;
}

/* -------------------- RESET -------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  background: var(--ink);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

ul, ol {
  list-style: none;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Respect reduced motion preference */
@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;
  }
}

/* -------------------- SKIP LINK -------------------- */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-md);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-weight: 700;
  z-index: 999;
  transition: top var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-md);
}

/* -------------------- TYPOGRAPHY -------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-header);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-title { font-size: var(--fs-h1); }
.section-title { font-size: var(--fs-h2); }
.drawer-title, .kit-price-label { font-family: var(--font-header); font-weight: 800; }

.text-accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

/* -------------------- BUTTONS -------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--fs-sm);
  letter-spacing: 0.01em;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-accent:hover {
  box-shadow: var(--shadow-accent-glow);
}

.btn-accent:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.6rem 1.1rem;
  font-size: var(--fs-xs);
  min-height: 38px;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(10, 10, 10, 0.3);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -------------------- ICON BUTTONS -------------------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-primary);
  position: relative;
  transition: background var(--dur-fast) var(--ease-out);
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* -------------------- STICKY HEADER -------------------- */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--surface-border);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}

.site-header.is-scrolled {
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

.header-inner {
  height: var(--header-height);
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
}

.brand-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.brand-mark {
  font-family: var(--font-header);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 700;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cart-badge.is-pulsing {
  animation: cart-badge-pulse 0.4s var(--ease-out);
}

@keyframes cart-badge-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* Menu trigger (hamburger) */
.menu-trigger {
  flex-direction: column;
  gap: 4px;
}

.menu-trigger .bar {
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--dur-mid) var(--ease-in-out), opacity var(--dur-fast);
}

/* aria-expanded on the trigger button is the single source of truth
   for the X-morph. It's set exclusively by openDrawer()/closeDrawer()
   in app.js, in the same call that toggles .is-open on #mobileDrawer,
   so the two never drift apart. (Note: body.drawer-is-open is a
   shared scroll-lock class also used by search/cart/quick-view, so
   it must NOT drive this icon or it would morph on those too.) */
.menu-trigger[aria-expanded="true"] .bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.menu-trigger[aria-expanded="true"] .bar:nth-child(2) {
  opacity: 0;
}
.menu-trigger[aria-expanded="true"] .bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* -------------------- SUB-NAV (SCROLL-SPY CATEGORIES) -------------------- */
.sub-nav {
  height: var(--sub-nav-height);
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.sub-nav-track {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0 var(--space-md);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sub-nav-track::-webkit-scrollbar {
  display: none;
}

.sub-nav-item {
  flex-shrink: 0;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.sub-nav-item.is-active {
  color: var(--accent-ink);
  background: var(--accent);
}

/* -------------------- SEARCH OVERLAY -------------------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--ink);
  animation: fadeIn var(--dur-mid) var(--ease-out);
}

.search-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.search-overlay-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md);
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: var(--space-xs) 0;
}

#searchInput::placeholder {
  color: var(--text-muted);
}

.search-results {
  margin-top: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

/* -------------------- LAYOUT SECTIONS -------------------- */
main {
  max-width: var(--max-width);
  margin: 0 auto;
}

section {
  padding: var(--space-2xl) var(--space-md);
}

.section-head {
  margin-bottom: var(--space-lg);
}

.section-sub {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: var(--space-2xs);
}

/* -------------------- HERO -------------------- */
.hero {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.hero-content {
  max-width: 640px;
}

.hero-copy {
  color: var(--text-secondary);
  margin-top: var(--space-md);
  font-size: var(--fs-body);
  max-width: 50ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  border-top: 1px solid var(--surface-border);
  padding-top: var(--space-lg);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-family: var(--font-header);
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--accent);
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

/* -------------------- LIVE INVENTORY STRIP -------------------- */
.live-strip {
  background: var(--surface);
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid var(--surface-border);
  padding: var(--space-sm) var(--space-md);
  overflow: hidden;
}

.live-strip-track {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  max-width: var(--max-width);
  margin: 0 auto;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 rgba(55, 214, 122, 0.5);
  animation: livePulse 2s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(55, 214, 122, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(55, 214, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(55, 214, 122, 0); }
}

/* -------------------- FILTER CHIPS -------------------- */
.filter-chips {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: var(--space-2xs) var(--space-md);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-out);
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

/* -------------------- PRODUCT GRID (2-COL MOBILE, NO H-SCROLL) -------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

@media (min-width: 560px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }
}

@media (min-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.load-more {
  margin-top: var(--space-lg);
}

/* -------------------- CUSTOM KIT CALCULATOR -------------------- */
.custom-kits {
  background: var(--surface);
  border-radius: var(--radius-lg);
  margin: var(--space-md);
  border: 1px solid var(--surface-border);
}

.kit-calculator {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 480px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-row label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-row input,
.form-row select,
.form-row textarea {
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
  min-height: 48px;
}

.form-row textarea {
  min-height: 90px;
  resize: vertical;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--accent);
}

.kit-price-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-raised);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.kit-price-label {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.kit-price-value {
  font-family: var(--font-header);
  font-size: var(--fs-h3);
  color: var(--accent);
}

/* -------------------- ABOUT -------------------- */
.about-copy {
  color: var(--text-secondary);
  max-width: 65ch;
  font-size: var(--fs-body);
  line-height: 1.7;
}

/* -------------------- RESPONSIVE: DESKTOP HERO -------------------- */
@media (min-width: 860px) {
  .hero {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .hero-stats {
    grid-template-columns: 1fr;
    border-top: none;
    border-left: 1px solid var(--surface-border);
    padding-top: 0;
    padding-left: var(--space-xl);
    gap: var(--space-lg);
  }
}
