@import 'tailwindcss';
@import './tokens.css';
@import './contrast-high.css';

@import '@fontsource/concert-one/index.css';

@font-face {
  font-family: 'Heebo Variable';
  font-style: normal;
  font-display: optional;
  font-weight: 100 900;
  src: url('/fonts/heebo-hebrew-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+FB1D-FB4F;
}

@font-face {
  font-family: 'Heebo Variable';
  font-style: normal;
  font-display: optional;
  font-weight: 100 900;
  src: url('/fonts/heebo-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+FEFF,
    U+FFFD;
}

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: optional;
  font-weight: 100 900;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA-02DC, U+2000-206F, U+20AC, U+2122,
    U+2191-2193, U+FEFF, U+FFFD;
}

/* ─── Base resets (built on top of Tailwind Preflight) ─── */
@layer base {
  :root {
    font-family: var(--font-sans);
    color-scheme: light;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* RTL-aware query-progress origin */
    --query-progress-origin: left;
  }

  [dir='rtl'] {
    --query-progress-origin: right;
  }

  html {
    background: var(--color-surface-base);
    color: var(--color-text-primary);
    overflow-x: clip;
    overscroll-behavior-x: none;
  }

  html[lang='en'] {
    font-family: var(--font-en);
  }

  body {
    min-height: 100dvh;
    overflow-x: clip;
    overscroll-behavior-y: contain;
  }

  * {
    -webkit-tap-highlight-color: transparent;
  }

  ::selection {
    background: var(--color-brand-primary-100);
    color: var(--color-brand-primary-900);
  }

  @media (hover: hover) and (pointer: fine) {
    * {
      scrollbar-width: thin;
      scrollbar-color: color-mix(in srgb, var(--color-neutral-400) 78%, transparent) transparent;
    }

    *::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    *::-webkit-scrollbar-track {
      background: transparent;
    }

    *::-webkit-scrollbar-thumb {
      background-color: color-mix(in srgb, var(--color-neutral-400) 78%, transparent);
      background-clip: content-box;
      border: 2px solid transparent;
      border-radius: 999px;
    }

    *::-webkit-scrollbar-thumb:hover {
      background-color: var(--color-neutral-500);
    }
  }

  /* 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;
    }
  }

  /* Focus ring - always visible */
  :focus-visible {
    outline: 2px solid var(--color-border-focus-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  [data-mode='vendor'] :focus-visible {
    outline-color: var(--color-border-focus-vendor);
  }

  /* Skip link - hidden until focused */
  .skip-link {
    position: absolute;
    inset-inline-start: var(--spacing-2);
    inset-block-start: var(--spacing-2);
    transform: translateY(-200%);
    background: var(--color-brand-primary-700);
    color: var(--color-brand-on-primary);
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-md);
    z-index: var(--z-a11y-trigger);
    transition: transform var(--duration-base) var(--ease-out);
  }

  .skip-link:focus-visible {
    transform: translateY(0);
  }

  :where(button, [role='button'], a, input, select, textarea, summary) {
    touch-action: manipulation;
  }
}

/* ─── AutoScrollRow marquee keyframe ─── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes multideal-auto-scroll {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(-50%);
    }
  }
}

/* ─── Radix popper wrapper z-index ─────────────────────────────────────────
 * data-radix-popper-content-wrapper has no z-index by default, so it renders
 * at z=auto (below any position:fixed element with explicit z-index like the
 * Drawer at z-modal=1300). Force it above modals so Select/Tooltip/DropdownMenu
 * inside Drawers and Dialogs are not hidden behind them.
 * ─────────────────────────────────────────────────────────────────────────── */
[data-radix-popper-content-wrapper] {
  z-index: var(--z-popover) !important;
}

/* ─── Drawer slide + overlay fade keyframes ─── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes drawer-slide-in-from-right {
    from {
      transform: translateX(100%);
    }
    to {
      transform: translateX(0);
    }
  }
  @keyframes drawer-slide-out-to-right {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(100%);
    }
  }
  @keyframes drawer-slide-in-from-left {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }
  @keyframes drawer-slide-out-to-left {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(-100%);
    }
  }
  @keyframes drawer-slide-in-from-bottom {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  @keyframes drawer-slide-out-to-bottom {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(100%);
    }
  }
  @keyframes overlay-fade-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  @keyframes overlay-fade-out {
    from {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }
}

/* ── Typography role classes (FDS type scale) ── */
.h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}
.h2 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}
.h3 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}
.h4 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}
.body-lg {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
}
.body-sm {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
}
.caption {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
}
.label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-snug);
}
.price {
  font-family: var(--font-en);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.price-strike {
  font-family: var(--font-en);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  font-variant-numeric: tabular-nums;
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* ─── Badge pulse dot keyframe ─── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes mdsp-badge-pulse {
    50% {
      opacity: 0.4;
      transform: scale(1.2);
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .mdsp-pulse-dot {
    animation: none !important;
  }
}

/* ─── Ticker strip animation ─── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes md-ticker-scroll {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(50%);
    }
  }
}

@layer utilities {
  @media (prefers-reduced-motion: no-preference) {
    .animate-ticker {
      animation: md-ticker-scroll 50s linear infinite;
    }
  }
}

/* ─── Windows High Contrast / forced-colors support (IS 5568 §3, F5) ─── */
@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid ButtonText;
    outline-offset: 2px;
  }
  .skip-link {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .animate-ticker {
    animation: none !important;
    overflow-x: auto;
  }
}

/* ─── QueryProgress top-bar animation ─── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes query-progress {
    0% {
      transform: scaleX(0);
      transform-origin: var(--query-progress-origin, left);
    }
    50% {
      transform: scaleX(0.7);
      transform-origin: var(--query-progress-origin, left);
    }
    100% {
      transform: scaleX(1);
      transform-origin: var(--query-progress-origin, left);
    }
  }
}

.motion-press-feedback {
  transition-property: transform, opacity;
  transition-duration: var(--motion-duration-press);
  transition-timing-function: var(--motion-ease-standard);
}

.motion-press-feedback:active {
  transform: scale(0.98);
}

.motion-stagger-1 {
  animation-delay: var(--motion-stagger-1);
}

.motion-stagger-2 {
  animation-delay: var(--motion-stagger-2);
}

.motion-stagger-3 {
  animation-delay: var(--motion-stagger-3);
}

@media (prefers-reduced-motion: reduce) {
  .motion-press-feedback {
    transition: none;
    transform: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes motion-overlay-enter {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @keyframes motion-overlay-exit {
    from {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }

  @keyframes motion-overlay-panel-enter {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @keyframes motion-overlay-panel-exit {
    from {
      opacity: 1;
    }
    to {
      opacity: 0;
      visibility: hidden;
    }
  }

  .motion-overlay-enter[data-state='open'] {
    animation: motion-overlay-enter var(--motion-duration-overlay-enter) var(--motion-ease-enter)
      both;
  }

  .motion-overlay-exit[data-state='closed'] {
    animation: motion-overlay-exit var(--motion-duration-overlay-exit) var(--motion-ease-exit) both;
  }

  .motion-overlay-panel-enter[data-state='open'] {
    animation: motion-overlay-panel-enter var(--motion-duration-base) var(--motion-ease-emphasized)
      both;
  }

  .motion-overlay-panel-exit[data-state='closed'] {
    animation: motion-overlay-panel-exit var(--motion-duration-overlay-exit) var(--motion-ease-exit)
      both;
    pointer-events: none;
  }
}

/* Hover-capable, fine-pointer device gate.
   Apply `.lg-hover-only` to elements that should disappear on touch / coarse-pointer
   devices (mobile, tablets without a mouse, iPad finger-only).
   The negated media query matches any device that LACKS either fine-pointer or hover capability. */
@media not all and (hover: hover) and (pointer: fine) {
  .lg-hover-only {
    display: none !important;
  }
}

/* ─── Skeleton content fade-in ─── */
/* Apply data-skeleton-ready on content that replaces a skeleton (client-side only). */
[data-skeleton-ready] {
  animation: skeleton-reveal 0.15s ease-out both;
}
@keyframes skeleton-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-skeleton-ready] {
    animation: none;
  }
}

/* Footer / bottom-nav clearance.
   The fixed mobile bottom nav reserves no layout space, so it overlaps the
   site footer. Reserve footer bottom space EQUAL to the nav's real occupied
   height (content box --bottom-nav-height + the --safe-area-bottom the nav
   pads itself by for the iOS home indicator).
   Gated two ways so it is exactly correct everywhere:
     - body:has([data-bottom-nav]) — only when a bottom nav is in the DOM
       (no dead space on nav-less pages, e.g. /referrals, /affiliate, error pages).
     - @media (width < 64rem) — only below Tailwind lg (--breakpoint-lg:64rem),
       where the nav is visible (it is lg:hidden at >= 64rem). No desktop gap. */
@media (width < 64rem) {
  body:has([data-bottom-nav]) [data-site-footer] {
    padding-block-end: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  }
}
