/* ============================================================
   Cyber Aura — Global Mobile Optimizations
   Підключається до всіх сторінок
   ============================================================ */

/* ── Header ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    height: 60px;
    gap: 12px;
    padding: 0 4px;
  }

  /* Логотип на мобільному — трохи менший */
  .logo-icon { width: 28px; height: 28px; }
  .logo-gaming { font-size: 10px; letter-spacing: 2px; }
  .logo-aura   { font-size: 16px; }

  /* Показати тільки пошук, кошик і бургер */
  .header-actions .header-action-btn { display: none; }
  .header-actions .header-action-btn.cart-btn { display: flex; }
  .burger-btn { display: flex; }
  .header-search { display: none; }
  .catalog-btn   { display: none; }
}

/* Було оголошено просто в @media, без селектора — рядок невалідний
   і браузер його відкидав. Шапка ставала 60px, а всі відступи
   продовжували рахуватись від 72px. */
@media (max-width: 768px) {
  :root { --header-height: 60px; }
}

/* ── Breadcrumbs ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .breadcrumbs {
    font-size: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex-wrap: nowrap;
  }
  .breadcrumbs span:not(:last-child):not(.breadcrumbs-sep) {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }
}

/* ── Page titles ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-content { min-height: auto; }
  h1 { font-size: clamp(20px, 6vw, 28px); }

  .section-title {
    font-size: 18px;
    letter-spacing: 1px;
  }
}

/* ── Product grid ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .product-card__name { font-size: 12px; }
  .product-card__price { font-size: 15px; }
  .product-card__body { padding: 10px; }
  .product-card__footer { padding: 0 10px 10px; }
  .product-card__footer .btn { font-size: 12px; padding: 8px 10px; }
}

@media (max-width: 480px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .product-card__image-wrap { aspect-ratio: 1; }
}

/* ── Catalog page ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .catalog-page { padding: 16px 0 40px; }

  .catalog-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  .toolbar-left { width: 100%; justify-content: space-between; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .sort-select { flex: 1; font-size: 13px; }

  /* Категорії в каталозі — горизонтальний скрол */
  .catalog-categories-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 8px;
  }
  .catalog-categories-bar::-webkit-scrollbar { display: none; }
  .catalog-cat-btn { flex-shrink: 0; }
}

/* ── Product page ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .product-layout {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  .product-gallery { position: static !important; }
  .product-gallery__main { aspect-ratio: 4/3; }
  .product-title { font-size: 20px !important; line-height: 1.3; }
  .product-price { font-size: 28px !important; }
  .product-buy-section {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    border-radius: 16px 16px 0 0;
    z-index: 100;
    margin: 0 -14px;
  }
  .product-buy-section .btn-lg { width: 100%; justify-content: center; font-size: 15px; }
  .product-specs { font-size: 13px; }
  .product-specs td { padding: 8px 6px; }
}

/* ── Cart page ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cart-layout {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .cart-item {
    flex-direction: row;
    gap: 12px;
  }
  .cart-item__image { width: 80px; height: 80px; flex-shrink: 0; }
  .cart-item__name { font-size: 13px; }
  .cart-item__price { font-size: 16px; }
  .cart-summary {
    position: sticky;
    bottom: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    padding: 16px;
    margin: 0 -14px;
    z-index: 50;
  }
}

/* ── Checkout page ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .checkout-layout {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .checkout-step-title { font-size: 16px; }
  .form-grid-2 { grid-template-columns: 1fr !important; }
}

/* ── Footer mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .footer { margin-top: 40px; }
  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 32px 0 24px;
  }
  .footer-brand { grid-column: 1 / -1; }
  .footer-brand p { font-size: 13px; max-width: 100%; }
  .footer-col h4 { font-size: 13px; margin-bottom: 10px; }
  .footer-links a { font-size: 13px; }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .footer-top { grid-template-columns: 1fr; gap: 20px; }
  .footer-socials { margin-top: 12px; }
}

/* ── Buttons — мінімальний розмір для touch ──────────────────── */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-height: 36px; min-width: 36px; }
}

/* ── Contacts / Delivery / Blog / Warranty pages ─────────────── */
@media (max-width: 768px) {
  .contacts-grid,
  .delivery-grid,
  .info-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .blog-grid { grid-template-columns: 1fr !important; }
  .blog-card__cover { aspect-ratio: 16/9; }
}

/* ── Section padding ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .section { padding: 28px 0; }
  .page-section { padding: 28px 0; }
}

@media (max-width: 480px) {
  :root { --container-padding: 0 14px; }
  .section { padding: 24px 0; }
}

/* ── Поля вводу: 16px, інакше iOS зумить сторінку ─────────────
   Safari на iPhone автоматично збільшує масштаб при фокусі на полі
   з розміром шрифту менше 16px. На чекауті це означало стрибок
   макета на кожному з десятка полів. */
@media (max-width: 768px) {
  .form-input, .form-select, .form-textarea,
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="search"], input[type="number"], input[type="password"],
  input[type="url"], input[type="date"], textarea, select {
    font-size: 16px;
  }
}

/* ── Безпечна зона iPhone ─────────────────────────────────────
   Липкі панелі впирались у жестову смугу — нижні 34px кнопки
   «Оформити» були недосяжні. */
@media (max-width: 768px) {
  .product-buy-section,
  .cart-summary {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-menu { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ── Тач-цілі ────────────────────────────────────────────────
   .qty-btn / .page-btn уже мають 44px через components.css —
   тут добираємо решту. */
@media (max-width: 768px) {
  .qty-input { height: 44px; }
  .burger-btn { min-width: 44px; min-height: 44px; align-items: center; }
  .mobile-nav-item { min-height: 48px; }
}

/* ── Кнопка пошуку в шапці (тільки мобільна) ─────────────────── */
.ca-msearch-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 44px;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
}
@media (max-width: 768px) {
  .header-actions .ca-msearch-btn { display: flex; }
}

/* Пункт «Пошук» у меню — це <button>, вирівнюємо під посилання */
.mobile-nav-item.mobile-nav-search {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

/* ── Накладка пошуку ─────────────────────────────────────────── */
.ca-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(9, 9, 15, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
}
.ca-search-overlay.open { display: flex; }

.ca-search-box {
  width: 100%;
  max-width: 560px;
  display: flex;
  gap: 8px;
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.ca-search-input {
  flex: 1;
  min-width: 0;
  font-size: 16px;            /* без зуму на iOS */
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-text-primary);
  outline: none;
}
.ca-search-input:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.ca-search-go {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--color-accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ca-search-close {
  flex-shrink: 0;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 16px;
  cursor: pointer;
}
@media (max-width: 480px) {
  .ca-search-overlay { padding: 64px 12px 12px; }
  .ca-search-go { padding: 0 14px; }
}

/* ── Висота екрана на iOS ────────────────────────────────────
   100vh не враховує адресний рядок Safari — низ сторінки
   опинявся під ним. */
@supports (height: 100dvh) {
  .dark-page { min-height: 100dvh; }
  .page-content { min-height: calc(100dvh - var(--header-height) - 280px); }
}

/* ── Scroll behavior ─────────────────────────────────────────── */
html { scroll-behavior: smooth; }
* { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; }
