/*
 * Ray BodyLab storefront overrides (loaded after the hashed bundle CSS by index.html).
 * The React source is not available, so these patch the built UI from the outside.
 * Selectors are structural where possible; a few Tailwind utility names (.text-stock-ok,
 * .product-card, [aria-busy]) come from assets/index-C_YsGv7I.css and the rendered DOM.
 * Re-check this file after any storefront rebuild. Owner notes: _dev/notes/storefront-ux-spec.md
 */

/* 1. Skip link (static <a class="skip-link"> in index.html, before #root). */
.skip-link {
  position: absolute;
  left: 12px;
  top: 0;
  z-index: 1000;
  transform: translateY(-120%);
  padding: 12px 18px;
  border-radius: 10px;
  background: #10151d;
  color: #fff;
  font: 600 15px/1.2 "Archivo Variable", Archivo, system-ui, sans-serif;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(12px); outline: 2px solid #2240e8; outline-offset: 2px; }
main[tabindex="-1"]:focus { outline: none; }

/* 2. Visible focus: 2px cobalt ring everywhere (beats the search box's focus:outline-none). */
html :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid #2240e8;
  outline-offset: 2px;
}
/* Inside clipping containers (product card, qty stepper) draw the ring inside. */
html :is(.product-card > a, .overflow-hidden > button):focus-visible { outline-offset: -3px; }
/* On dark surfaces (footer, hero) use white so the ring stays visible. */
html :is(footer, section.bg-iron) :is(a, button, input, [tabindex]):focus-visible { outline-color: #fff; }

/* 3. Stock pill contrast: 3.78:1 -> 5.2:1 (ok) and 4.3:1 -> 5.6:1 (out), same hues. */
.text-stock-ok { color: #17713d; }
.text-stock-no { color: #a8321f; }

/* 4. Layout stability (desktop CLS). */
/* 4a. Keep the footer below the fold while route data loads, and stop the first child's
       top margin collapsing through <main> (main used to jump 24px on the product page). */
#root main { min-height: 100vh; display: flow-root; }

/* 4b. Product-grid skeleton: the bundle nests the skeleton grid inside the product grid as
       ONE grid item (1 of 4 columns), so 8 tiny cards grow into full cards later. Span all
       columns, use the parent's gaps, and shape each skeleton like a real card
       (full-bleed 4/5 image + ~176px text/buttons area). */
.grid > .grid[aria-busy="true"] { grid-column: 1 / -1; column-gap: inherit; row-gap: inherit; }
.grid[aria-busy="true"] > div { padding: 0 0 94px; overflow: hidden; }
/* Phones: product names usually wrap to two lines on ~173px cards. */
@media (max-width: 639px) { .grid[aria-busy="true"] > div { padding-bottom: 115px; } }
.grid[aria-busy="true"] > div > :first-child { border-radius: 0; }
.grid[aria-busy="true"] > div > :not(:first-child) { margin-left: 16px; margin-right: 16px; }

/* 4c. Home hero: the placeholder shown while banners load is shorter than the carousel
       (420 -> ~640px on phones, 520 -> 560px on desktop). Reserve the carousel's height. */
main > section.bg-iron:first-child:not([aria-roledescription]),
main > section.bg-iron:first-child:not([aria-roledescription]) > .container-site {
  min-height: calc(372px + min(100vw - 2rem, 520px) * 0.75);
}
@media (min-width: 640px) {
  main > section.bg-iron:first-child:not([aria-roledescription]),
  main > section.bg-iron:first-child:not([aria-roledescription]) > .container-site {
    min-height: calc(372px + min(100vw - 3rem, 520px) * 0.75);
  }
}
@media (min-width: 1024px) {
  main > section.bg-iron:first-child:not([aria-roledescription]),
  main > section.bg-iron:first-child:not([aria-roledescription]) > .container-site { min-height: 560px; }
}

/* 5. Long unbroken text (e.g. a 300-char search) must wrap instead of widening the page. */
main :is(h1, h2, h3, p) { overflow-wrap: anywhere; }

/* 6. Respect reduced-motion for CSS animations/transitions (framer-motion handles its own). */
@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;
  }
}
