/**
 * mobile.css — Red Square theme mobile UX improvements
 * Feature 3: mobile-first enhancements, lightbox, gallery scroll, touch CTAs
 */

/* ─── Lightbox ─────────────────────────────────────────── */
/* Fade-анимация: лайтбокс не появляется резко */
.rs-lightbox {
  display: flex;               /* всегда flex — управляем через opacity+pointer-events */
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.rs-lightbox--active {
  opacity: 1;
  pointer-events: auto;
}
.rs-lightbox__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}
/* Изображение: скрыто (opacity 0) пока не загружено — нет broken-icon */
.rs-lightbox__img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 2px;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.rs-lightbox__img.is-loaded {
  opacity: 1;
}
/* Счётчик изображений: "2 / 5" */
.rs-lightbox__counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0.08em;
  pointer-events: none;
}
/* Кнопки: повышенный контраст (WCAG AA) */
.rs-lightbox__close,
.rs-lightbox__prev,
.rs-lightbox__next {
  position: absolute;
  z-index: 2;
  background: rgba(0, 0, 0, 0.45);        /* dark bg — читаемо на любом фото */
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rs-lightbox__close:hover,
.rs-lightbox__prev:hover,
.rs-lightbox__next:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.5);
}
.rs-lightbox__close {
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 18px;
  border-radius: 50%;
}
.rs-lightbox__prev,
.rs-lightbox__next {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 64px;
  font-size: 36px;
  border-radius: 4px;
}
.rs-lightbox__prev { left: 12px; }
.rs-lightbox__next { right: 12px; }

@media (max-width: 590px) {
  .rs-lightbox__prev,
  .rs-lightbox__next {
    width: 40px;
    height: 52px;
    font-size: 28px;
  }
  .rs-lightbox__prev { left: 4px; }
  .rs-lightbox__next { right: 4px; }
}

/* ─── Gallery — mobile horizontal scroll ──────────────── */
@media (max-width: 768px) {
  .gallery {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
  }
  .gallery::-webkit-scrollbar { height: 4px; }
  .gallery::-webkit-scrollbar-track { background: transparent; }
  .gallery::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }
  .gallery__item {
    flex: 0 0 75vw;
    scroll-snap-align: start;
    display: block;
  }
  .gallery__item img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 2px;
  }
}
@media (max-width: 400px) {
  .gallery__item { flex: 0 0 85vw; }
  .gallery__item img { height: 180px; }
}

/* ─── Product cards — flexible height ─────────────────── */
@media (max-width: 590px) {
  .catalog-item {
    height: auto;
    min-height: 300px;
  }
  .catalog-item__img {
    height: 180px;
    flex-shrink: 0;
  }
}
@media (max-width: 400px) {
  .catalog-item-wrap {
    width: 100% !important;
    padding: 0 10px !important;
  }
  .catalog-item { min-height: 260px; }
}

/* ─── Product hero — mobile ────────────────────────────── */

/* Desktop: hide the mobile-only info block */
.product-mobile-info { display: none; }

@media (max-width: 768px) {
  /* Hero: full-height background image, all overlaid content removed */
  .product-general {
    background-attachment: scroll !important; /* fix iOS fixed bg bug */
    min-height: 100svh;
    min-height: 100vh; /* fallback */
  }

  /* Hide all overlaid content inside the hero */
  .product-general .breadcrumbs--hero,
  .product-general__left,
  .product-scroll { display: none !important; }

  /* ── Block below hero: breadcrumbs + name + "Где купить?" ── */
  .product-mobile-info {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 16px;
    background: #111;
  }

  /* Breadcrumb row */
  .product-mobile-info__breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 13px;
  }
  .product-mobile-info__breadcrumbs .breadcrumbs__link {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
  }
  .product-mobile-info__breadcrumbs .breadcrumbs__link:hover {
    color: #fff;
  }
  .product-mobile-info__breadcrumbs .breadcrumbs__sep {
    color: rgba(255,255,255,0.25);
    margin: 0 2px;
  }

  /* Product name */
  .product-mobile-info__name {
    font-size: clamp(1.4rem, 7vw, 2.2rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* "Где купить?" button */
  .product-mobile-info .product-where-buy {
    align-self: flex-start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* ─── Touch-friendly buttons ───────────────────────────── */
@media (max-width: 768px) {
  .red-btn-double,
  .product-where-buy {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 14px;
  }
  .product-general__bottom {
    gap: 12px;
  }
}

/* ─── Mobile/Desktop gallery visibility ────────────────── */
/* Bug fix: compound-селектор (оба класса на одном элементе, не вложенность) */
.gallery--mobile { display: none; }
.gallery--desktop { display: flex; flex-wrap: wrap; }

@media (max-width: 768px) {
  .gallery--desktop.gallery--has-mobile { display: none; }   /* скрыть desktop-галерею */
  .gallery--mobile { display: flex; }                        /* показать мобильную */
}

/* ─── Navigation — mobile UX polish ────────────────────── */
@media (max-width: 768px) {
  .navigation__category {
    min-height: 52px;
    display: flex;
    align-items: center;
  }
}

/* ─── Home category — desktop sidebar item size ──────────────────────────── */
.home-category {
    position: relative;
    display: block;
    width: 52%;
    height: 48px;
    margin: 10px 0;
}

/* ─── Home categories — hidden on mobile (hamburger nav only) ──────────── */
@media (max-width: 768px) {
  .home-categories { display: none !important; }
}

/* ─── Home slider — desktop: hide mobile-only elements ─────────────────── */
.home-slide__mobile-img  { display: none; }   /* shown only inside @media below */
.home-slider__caption    { display: none; }   /* shown only inside @media below */

/* ─── Home slider — mobile stacked layout ───────────────────────────────
 * Изображение сверху (mobile-img), тайтл + кнопка снизу (caption).
 * Контент внутри слайда скрыт. Навигация полностью скрыта.
 * ────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Main: stack slider and caption vertically */
  .home {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100svh;
    min-height: 100vh;
  }

  /* Slider: back in normal flow, fixed height to contain absolutely-positioned slides */
  .home-slider {
    position: relative !important;
    height: 56vw !important;
    max-height: 320px !important;
    width: 100% !important;
    flex-shrink: 0;
  }

  /* Slides: stack on top of each other inside the slider for cross-fade */
  .home-slide {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    background-image: none !important;
    min-height: 0 !important;
  }

  /* Mobile image: fill the slide area */
  .home-slide__mobile-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    flex-shrink: 0;
  }

  /* Content inside each slide: hidden — title/button live in .home-slider__caption */
  .home-slide__content-wrap { display: none !important; }

  /* Caption: title + button below the slider */
  .home-slider__caption {
    display: block;
    padding: 20px 16px 24px;
    background: #111;
  }
  .home-slider__caption-title {
    font-size: clamp(1.2rem, 6vw, 1.8rem);
    color: #fff;
    margin-bottom: 16px;
    line-height: 1.25;
  }

  /* Hide all navigation: prev/next buttons, dots, slide counter */
  .js-slider-prev,
  .js-slider-next,
  .slick-dots,
  .home-slider-count { display: none !important; }
}

/* ─── Price list — password lock screen ────────────────────────────────── */
.price-list-lock {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;
  padding: 0 16px;
}
.price-list-lock__icon {
  font-size: 48px;
  margin-bottom: 16px;
  line-height: 1;
}
.price-list-lock__title {
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: #fff;
}
.price-list-lock__hint {
  color: rgba(255,255,255,0.55);
  margin-bottom: 24px;
  font-size: 14px;
}
/* WordPress default password form */
.price-list-lock .post-password-form label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-align: left;
}
.price-list-lock .post-password-form input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 15px;
  border-radius: 2px;
  margin-bottom: 12px;
  box-sizing: border-box;
}
.price-list-lock .post-password-form input[type="submit"] {
  width: 100%;
  padding: 11px 20px;
  background: #c00;
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s;
}
.price-list-lock .post-password-form input[type="submit"]:hover {
  background: #e00;
}

/* ─── Price list — table ─────────────────────────────────────────────────── */
.price-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
}
.price-list-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  font-weight: 400;
}
.price-list-table__row {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.15s;
}
.price-list-table__row:hover {
  background: rgba(255,255,255,0.04);
}
.price-list-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

/* Image cell */
.price-list-table__col-img {
  width: 56px;
  padding: 6px 8px 6px 0;
}
.price-list-table__img {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
  min-width: 48px;
  object-fit: cover !important;
  border-radius: 2px;
  display: block;
}

/* Name cell */
.price-list-table__col-name { width: auto; }

/* Category cell */
.price-list-table__col-cat {
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  white-space: nowrap;
}
.price-list-table__link {
  color: #fff !important;
  text-decoration: none !important;
  font-size: 14px;
  line-height: 1.3;
}
.price-list-table__link:hover { color: #c00 !important; }

/* Price cell */
.price-list-table__col-price { white-space: nowrap; text-align: right; }
.price-list-price {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.price-list-price--empty { color: rgba(255,255,255,0.2); }

/* ─── Price list — mobile responsive ────────────────────────────────────── */
@media (max-width: 590px) {
  /* Make the price table scrollable horizontally instead of overflowing */
  .main--price-list .container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .price-list-table {
    min-width: 480px; /* ensure table columns don't collapse below usable width */
  }

  .price-list-table__col-cat,
  .price-list-table thead th:nth-child(3) { display: none; }
  .price-list-table td { padding: 6px 8px 6px 0; }
  .price-list-table__col-img { width: 40px; padding: 4px 6px 4px 0; }
  .price-list-table__img {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    min-width: 36px;
  }
  .price-list-table__link { font-size: 12px; }
  .price-list-price { font-size: 13px; }
  .price-list-table thead th { font-size: 10px; padding: 6px 8px 6px 0; }
}

/* ─── 2K / high-DPR phone screens (Samsung S24 Ultra, etc.) ─────────────
 * Viewport ≈ 360–480px CSS at 3x–4x device pixel ratio.
 * Keep containers fluid, ensure page title and summary block scale well.
 * ────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 3),
       (max-width: 768px) and (min-resolution: 3dppx) {
  /* Prevent any fixed-width container from clipping on ultra-wide/HiDPI phones */
  .container,
  .container--wide {
    max-width: 100% !important;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }

  /* Slightly larger touch targets for high-DPR screens */
  .pl-qty-dec,
  .pl-qty-inc {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }
  .pl-qty-input {
    height: 34px;
    width: 56px;
  }

  /* Ensure the order summary stretches full width on narrow HiDPI */
  .pl-summary {
    max-width: 100%;
  }

  /* Page title — scale down slightly so it doesn't overflow on 360px viewports */
  .page-title {
    font-size: clamp(1.4rem, 6vw, 2rem);
  }
}
