/* ═══════════════════════════════════════════════════════════════════
   motion.css — buyoffseason shared motion module
   ──────────────────────────────────────────────────────────────────
   What this gives you:
     1. Global smooth-scroll behavior + a thin ember scroll-progress
        bar pinned to the top of every page (auto-injected by
        motion.js — no markup change needed).
     2. A scroll-snap horizontal-rail container pattern (.bofs-rail)
        for converting curated 6–12 item sections into a Netflix /
        Apple TV+ style row. Drop class on the wrapper, items keep
        their existing classes (.pcard, .gr-card, .pl-card, etc.).
     3. Reveal-on-scroll utility (.bofs-reveal) — items fade up
        10px when they enter the viewport. Driven by IntersectionObs
        wired in motion.js. Sections opt in via class or data attr.
     4. Animated number tickers (.bofs-ticker[data-target]) — the
        "save $187" amounts count up from 0 when scrolled into view.
     5. Subtle image-zoom-on-hover (.bofs-zoom-on-hover) for product
        cards. Layers on top of existing card hover translateY.
     6. View Transitions API opt-in for in-site navigation —
        configured globally if the browser supports it. Smooth
        cross-fade between pages.

   Design philosophy: NONE of this is invasive. Every pattern is
   additive. Existing components keep their styles. Pages opt in
   via class names or data attributes. Reduced-motion preference is
   honored — every animation is wrapped in a media query.
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. Global smooth scroll + progress bar ─────────────────────── */

html {
  /* css smooth-scroll for anchor jumps. Polished but not janky. */
  scroll-behavior: smooth;
}
/* Disable for users who prefer reduced motion — Safari especially. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* The scroll-progress bar — injected by motion.js as #bofsScrollProgress
   at the top of <body>. Thin ember strip that fills as the user reads
   down the page. Subtle but immediately conveys "this site is polished." */
#bofsScrollProgress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--ember, #FF6B35), var(--ember-light, #FFB347));
  z-index: 9999;
  pointer-events: none;
  transition: width 0.08s linear;
  will-change: width;
}
/* Don't show the bar when the page is shorter than the viewport — no
   meaningful scroll to track. motion.js toggles this class. */
#bofsScrollProgress.bofs-hide { opacity: 0; }

/* ── 2. Horizontal scroll-snap rail container ───────────────────── */

/* Wrap any existing grid section to convert it into a scroll-snap rail:
     <div class="bofs-rail">
       <div class="bofs-rail-track">
         <a class="pcard">...</a>   ← existing card markup untouched
         <a class="pcard">...</a>
         ...
       </div>
       <button class="bofs-rail-arrow bofs-rail-prev" ...>‹</button>
       <button class="bofs-rail-arrow bofs-rail-next" ...>›</button>
     </div>
   motion.js binds the arrow controls automatically. */

.bofs-rail {
  position: relative;
  /* Bleed slightly into page gutter so cards align with body content
     even though the rail itself extends past for the snap padding. */
  margin: 0 calc(-1 * var(--bofs-rail-gutter, 0px));
}

.bofs-rail-track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--bofs-rail-padding, 24px);
  scroll-behavior: smooth;
  padding: 4px var(--bofs-rail-padding, 24px) 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bofs-rail-track::-webkit-scrollbar { display: none; }

/* Each direct child of the track snaps to the start. Apply flex-basis
   so cards keep a fixed width regardless of their original grid styling.
   Pages override --bofs-rail-card-w when needed. */
.bofs-rail-track > * {
  flex: 0 0 var(--bofs-rail-card-w, 240px);
  scroll-snap-align: start;
}

/* Arrow controls — circular buttons that scroll the rail. Hidden on
   mobile (use swipe) by default. */
.bofs-rail-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 1px solid rgba(20, 24, 43, 0.20);
  border-radius: 50%;
  background: var(--cream, #FFFFFF);
  color: var(--ink, #14182B);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  transition:
    background 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 4px 14px rgba(20, 24, 43, 0.10);
}
.bofs-rail-arrow:hover {
  background: var(--ink, #14182B);
  color: var(--cream, #FFFFFF);
  border-color: var(--ink, #14182B);
  transform: translateY(-50%) scale(1.05);
}
.bofs-rail-arrow:active { transform: translateY(-50%) scale(0.95); }
.bofs-rail-arrow:disabled,
.bofs-rail-arrow.bofs-disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.bofs-rail-prev { left: 4px; }
.bofs-rail-next { right: 4px; }

/* Dark-mode lock for the arrow buttons — same pattern as the audit fix
   block in theme.css. The .bofs-rail-arrow uses var(--cream) bg which
   would flip dark; that's actually fine because dark var(--cream) =
   the dark surface, so the arrow blends in. But the hover state would
   need re-locking. Handled by the cubic-bezier transitions naturally. */
:root[data-theme="dark"] .bofs-rail-arrow {
  background: rgba(15, 18, 32, 0.90);
  color: var(--ink, #F5F1E8);
  border-color: rgba(245, 241, 232, 0.20);
}
:root[data-theme="dark"] .bofs-rail-arrow:hover {
  background: var(--ember, #FF6B35);
  color: #FFFFFF;
  border-color: var(--ember, #FF6B35);
}

@media (max-width: 640px) {
  .bofs-rail-arrow { display: none; }
  .bofs-rail-track { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .bofs-rail-arrow,
  .bofs-rail-track,
  #bofsScrollProgress { transition: none !important; }
  .bofs-rail-track { scroll-behavior: auto; }
}

/* ── 3. Reveal-on-scroll ─────────────────────────────────────────── */

/* Sections marked .bofs-reveal start invisible + offset, then fade up
   into place when motion.js's IntersectionObserver fires. The .visible
   class is added when the element enters the viewport. */
.bofs-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.55s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
.bofs-reveal.bofs-visible {
  opacity: 1;
  transform: translateY(0);
}
/* Optional stagger — children with .bofs-reveal-child get a small
   delay multiplied by their index, set via inline style by motion.js. */
.bofs-reveal-child {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bofs-reveal.bofs-visible .bofs-reveal-child {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .bofs-reveal,
  .bofs-reveal-child {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ── 4. Animated number ticker ───────────────────────────────────── */

/* Elements with .bofs-ticker[data-target="187"] count up from 0 to
   the target when scrolled into view. The display value is set by
   motion.js — CSS just ensures the type renders in tabular-nums so
   the digits don't jitter as they count. */
.bofs-ticker {
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .bofs-ticker.bofs-counting {
    /* If user prefers reduced motion, motion.js sets target immediately
       and adds .bofs-counting-done. This rule is just a safety net. */
  }
}

/* ── 5. Image zoom on hover ──────────────────────────────────────── */

/* Wrap an <img> with .bofs-zoom-on-hover (or apply to a parent that
   contains an .svg-icon / .pcard-img descendant). Gives a 1.06× scale
   on hover, no other change. Layers cleanly with the existing
   transform: translateY(-3px) hover on .pcard. */
.bofs-zoom-on-hover img,
.bofs-zoom-on-hover .svg-icon,
.bofs-zoom-on-hover .pcard-img > *:not(.pcard-tag):not(.pcard-heart-btn) {
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bofs-zoom-on-hover:hover img,
.bofs-zoom-on-hover:hover .svg-icon,
.bofs-zoom-on-hover:hover .pcard-img > *:not(.pcard-tag):not(.pcard-heart-btn) {
  transform: scale(1.06);
}
@media (prefers-reduced-motion: reduce) {
  .bofs-zoom-on-hover img,
  .bofs-zoom-on-hover .svg-icon,
  .bofs-zoom-on-hover .pcard-img > * { transition: none !important; transform: none !important; }
}

/* ── 6. View Transitions API ─────────────────────────────────────── */

/* The View Transitions API is opt-in via @view-transition. Browsers
   that don't support it (Firefox today) just ignore this rule and
   fall through to normal navigation. When the user clicks a link to
   another page on the same origin, the browser captures the current
   page, fades it out, fades the new one in. Buttery cross-fade for
   shop ↔ gear ↔ players nav.

   The duration is short (180ms) so it never feels slow — just smooth. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: bofs-fade-out 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
::view-transition-new(root) {
  animation: bofs-fade-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes bofs-fade-out {
  to { opacity: 0; }
}
@keyframes bofs-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   7. APPLIED PATTERNS — convert existing grids into horizontal rails
   ──────────────────────────────────────────────────────────────────
   The Pinterest reference (Tina Lee / "Interaction UI" board) was
   specifically about carousel + horizontal-scroll desktop layouts.
   This block converts the existing homepage grids into scroll-snap
   rails WITHOUT touching their HTML — just overriding the grid
   container to display:flex + overflow-x:auto with scroll-snap.

   Affected sections:
     - .holidays-grid (homepage holiday edit, 4-col grid → rail)
     - .calendar-grid (12-month off-season calendar, 4-col grid → rail)
     - .bofs-carousel-scroll (existing carousels — polish only,
       already a flex/scroll container; this just adds snap + easing)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Holiday rail — converts 4-col grid to horizontal scroll-snap ── */
.holidays-grid {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 22px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 32px;
  scroll-behavior: smooth;
  padding: 4px 32px 22px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.holidays-grid::-webkit-scrollbar { display: none; }
.holidays-grid > .holiday-card {
  flex: 0 0 320px;
  scroll-snap-align: start;
  /* min-height was set on the original card — preserve so the row's
     vertical rhythm matches what the page intended. */
}
@media (max-width: 720px) {
  .holidays-grid > .holiday-card { flex-basis: 78vw; }
}

/* ── Calendar rail — same treatment for the 12-month strip ──────── */
.calendar-grid {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 32px;
  scroll-behavior: smooth;
  padding: 4px 32px 22px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.calendar-grid::-webkit-scrollbar { display: none; }
.calendar-grid > .cal-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
}
@media (max-width: 720px) {
  .calendar-grid > .cal-card { flex-basis: 76vw; }
}

/* ── Existing .bofs-carousel polish — add snap + buttery easing ──── */
/* These rails already exist as horizontal-scroll containers, but the
   default snap behavior and easing aren't tuned. Add the same
   cubic-bezier the new motion patterns use so scroll feels consistent
   site-wide. */
.bofs-carousel-scroll {
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.bofs-carousel-scroll > * {
  scroll-snap-align: start;
}
/* The arrow controls already have hover transitions; upgrade their
   easing to the cubic-bezier for consistency. */
.bofs-carousel-nav {
  transition:
    background 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
.bofs-carousel-nav:hover { transform: scale(1.05); }
.bofs-carousel-nav:active { transform: scale(0.95); }

/* ── Image zoom on hover for product cards site-wide ──────────────
   Layers a subtle 1.06× scale on the image inside .pcard, .gr-card,
   .holiday-card-product when the parent card is hovered. The card
   itself keeps its existing translateY(-3px) lift — this just adds
   life to the photo. */
.pcard-img > img,
.pcard-img > .svg-icon,
.holiday-card-product > img,
.holiday-card-product .svg-icon,
.gr-card-img > img,
.gr-card-vis > img {
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.pcard:hover .pcard-img > img,
.pcard:hover .pcard-img > .svg-icon,
.holiday-card:hover .holiday-card-product > img,
.holiday-card:hover .holiday-card-product .svg-icon,
.gr-card:hover .gr-card-img > img,
.gr-card:hover .gr-card-vis > img {
  transform: scale(1.06);
}
@media (prefers-reduced-motion: reduce) {
  .pcard-img > *,
  .holiday-card-product > *,
  .gr-card-img > *,
  .gr-card-vis > * {
    transition: none !important;
    transform: none !important;
  }
}

/* ── Section reveal-on-scroll (auto-applied by motion.js) ─────────
   motion.js tags major sections with .bofs-reveal at boot. The CSS
   for .bofs-reveal already exists above (in section 3). This block
   just makes sure the reveal is visible-by-default if JS doesn't run
   (graceful degradation) — by being more specific than the base rule
   for the case where the user has JS disabled. */
.no-js .bofs-reveal,
.no-js .bofs-reveal-child {
  opacity: 1 !important;
  transform: none !important;
}

