/**
 * Badi Beit – layout shell, overflow guards, Alpine cloak, RTL fixes
 */

[x-cloak] {
  display: none !important;
}

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

body {
  overflow-x: clip;
  max-width: 100%;
  min-height: 100dvh;
  min-height: 100vh;
}

/* Prevent flex/grid children from forcing horizontal scroll */
main,
header,
footer,
section,
.product-card,
#productsRoot,
#heroSlider,
#trusted-slider {
  max-width: 100%;
}

#heroSlider {
  width: 100%;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  max-height: 340px;
  contain: layout style paint;
}

@media (min-width: 640px) {
  #heroSlider {
    aspect-ratio: 16 / 10;
    min-height: 220px;
    max-height: 380px;
  }
}

@media (min-width: 768px) {
  #heroSlider {
    aspect-ratio: 16 / 9;
    min-height: 200px;
    max-height: 420px;
  }
}

@media (min-width: 1024px) {
  #heroSlider {
    max-height: 580px;
  }
}

#heroSlider [data-track] {
  width: 100%;
}

#heroSlider [data-slide] {
  flex: 0 0 100%;
  min-width: 100%;
  max-width: 100%;
}

#heroSlider img,
#heroSlider video {
  width: 100%;
  max-width: 100%;
}

/* Product grids – cards must shrink inside columns */
#grid-premium,
#grid-latest {
  width: 100%;
  min-width: 0;
}

#grid-premium > .product-card,
#grid-latest > .product-card {
  min-width: 0;
}

.bb-card-media img,
.bb-card-media video,
.bb-product-gallery__media.bb-preview-video,
video.bb-preview-video,
video.bb-card-video,
video.bb-show-video,
video.lazy-video {
  pointer-events: none !important;
  -webkit-user-drag: none;
  user-select: none;
  touch-action: none;
}

video.bb-preview-video {
  object-fit: cover;
}

video.bb-product-gallery__media.bb-preview-video {
  object-fit: contain;
}

/* Hide all native video controls / iOS play overlay on previews */
video.bb-preview-video::-webkit-media-controls,
video.bb-preview-video::-webkit-media-controls-enclosure,
video.bb-preview-video::-webkit-media-controls-panel,
video.bb-preview-video::-webkit-media-controls-play-button,
video.bb-preview-video::-webkit-media-controls-start-playback-button,
video.bb-preview-video::-webkit-media-controls-overlay-play-button {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0;
  pointer-events: none;
}

.bb-slide.is-active {
  display: block !important;
}

/* Brand color missing from compiled Tailwind */
.bg-primary-dark {
  background-color: #002654 !important;
}

.hover\:bg-primary-dark:hover {
  background-color: #002654 !important;
}

.overflow-x-hidden {
  overflow-x: hidden;
}

.overflow-x-clip {
  overflow-x: clip;
}

/* Match loaded Google Font (Cinzel) */
.font-brand {
  font-family: Cinzel, "Marcellus SC", Georgia, serif !important;
}

/* RTL: drawer from the right, no horizontal page shift */
[dir="rtl"] #sidebar {
  left: auto;
  right: 0;
  border-right: 0;
  border-left: 1px solid #e5e7eb;
}

[dir="rtl"] #sidebar.-translate-x-full {
  transform: translateX(100%);
}

[dir="rtl"] #sidebar:not(.-translate-x-full) {
  transform: translateX(0);
}

/* Safe area for notched phones (PWA / mobile browser) */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .bg-primary.text-white.text-sm.py-1.px-4 {
    padding-top: max(0.25rem, env(safe-area-inset-top));
  }
}

/* Product detail gallery — explicit sizing (Tailwind h-64 not in build) */
.bb-product-gallery {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 240px;
  max-height: 420px;
  background-color: #f3f4f6;
  overflow: hidden;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.bb-product-gallery__blur {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  filter: blur(24px);
  transform: scale(1.08);
  opacity: 0.45;
}

/* Slides use HTML hidden + Alpine x-bind:hidden (see show.blade.php) */
.bb-product-gallery__slide[hidden] {
  display: none !important;
}

.bb-product-gallery__slide:not([hidden]) {
  display: flex !important;
}

.bb-product-gallery__media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.75rem;
  cursor: pointer;
}

.bb-product-gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background-color: #00336c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}

.bb-product-gallery__nav:hover {
  background-color: #002654;
}

.bb-product-gallery__nav--prev { left: 0.5rem; }
.bb-product-gallery__nav--next { right: 0.5rem; }

@media (min-width: 640px) {
  .bb-product-gallery {
    min-height: 280px;
    max-height: 480px;
  }
}

/* Top bar – social icons always visible on portrait phones */
.bb-top-bar {
  overflow: visible;
  flex-wrap: nowrap;
}

.bb-sidebar-toggle {
  margin-left: 0.5rem;
  padding: 0.25rem 0.35rem;
}

@media (min-width: 640px) {
  .bb-sidebar-toggle {
    margin-left: 0.75rem;
  }
}

.bb-top-bar-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  overflow: visible;
}

.bb-top-bar-social {
  display: flex !important;
  flex-shrink: 0;
  align-items: center;
  overflow: visible;
}

.bb-social-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  flex-shrink: 0;
  color: #fff;
}

.bb-social-btn i {
  font-size: 0.875rem;
  line-height: 1;
}

@media (min-width: 640px) {
  .bb-social-btn {
    width: 2.25rem;
    height: 2.25rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
  }

  .bb-social-btn i {
    font-size: 1rem;
  }
}

/* Touch-friendly compact mobile layout */
@media (max-width: 639px) {
  .bb-mobile-compact-header .bb-post-ad-btn {
    font-size: 0.75rem;
    line-height: 1rem;
    padding: 0.375rem 0.625rem;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bb-mobile-compact-header .bb-brand-sub {
    display: none;
  }

  .bb-lang-select {
    font-size: 0.75rem;
  }
}

/* Skip link (accessibility) */
.bb-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: #00336c;
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 0.375rem 0;
}

.bb-skip-link:focus {
  left: 0;
}

/* Back to top */
.bb-back-to-top {
  position: fixed;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 60;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: none;
  background: #00336c;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 51, 108, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.92);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease, background 0.2s ease;
}

.bb-back-to-top:hover,
.bb-back-to-top:focus-visible {
  background: #002654;
  outline: 2px solid #a67c00;
  outline-offset: 2px;
}

.bb-back-to-top--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.bb-back-to-top i {
  animation: bb-bounce-up 1.6s ease-in-out infinite;
}

@keyframes bb-bounce-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
