/* =========================================
   12. RESPONSIVE DESIGN (Tablets & Mobile)
   ========================================= */
@media (max-width: 900px) {
  .products {
    grid-template-columns: repeat(3, 1fr);
  }
  .categories {
    grid-auto-columns: calc(50% - 9px);
  }
  .navlinks {
    display: none;
  }
}
@media (max-width: 560px) {
  nav,
  .shell {
    padding-left: 18px;
    padding-right: 18px;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-visual {
    height: 260px;
  }
  .hero-visual img {
    height: 240px;
  }
  .products {
    grid-template-columns: repeat(2, 1fr);
  }
  .categories {
    grid-auto-columns: calc(85% - 9px);
    gap: 10px;
  }
  .card img {
    height: 135px;
  }

  .category {
    padding: 12px;
  }
  .trust {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .icons {
    gap: 10px;
  }
  .brand {
    min-width: 0;
    font-size: 18px;
    letter-spacing: 2px;
  }
  .brand-text::after { display: none; }
}

/* =========================================
   16. RESPONSIVE DESIGN (Media Queries)
   ========================================= */

/* Responsive typography is scoped to primary page headings. Global h/p/li
   sizing caused labels and card copy to jump when the final CSS loaded. */
.page-hero > div > h1,
.hero > div > h1 { font-size: clamp(32px, 5vw, 76px); }
.section-title > h2 { font-size: clamp(22px, 3vw, 30px); }
.hero h1 { font-size: clamp(36px, 8vw, 76px); line-height: 1.1; }
.hero p { font-size: clamp(16px, 3vw, 18px); }

/* Ensure interactive elements have min 44x44px touch target */
button, 
a.primary, 
.tab-btn, 
.category, 
.icon-link, 
.hamburger-menu {
  min-height: 44px;
}

/* Ensure images are responsive */
img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.card img {
  object-fit: cover;
}
.hero-visual img { object-fit: contain; }

/* Base Hamburger Menu Styles (Hidden on Desktop) */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 101;
  margin-left: 2px;
  flex: 0 0 44px;
  border-radius: 10px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}
.hamburger-line {
  width: 24px;
  height: 2px;
  background-color: var(--text);
  transition: all 0.3s linear;
  position: relative;
  transform-origin: 1px;
}
.hamburger-menu.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg);
}
.hamburger-menu.active .hamburger-line:nth-child(2) {
  opacity: 0;
}
.hamburger-menu.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg);
}
.hamburger-menu:hover,
.hamburger-menu:focus-visible,
.hamburger-menu.active {
  background: rgba(217, 156, 46, 0.1);
  box-shadow: 0 0 16px rgba(217, 156, 46, 0.38), inset 0 0 10px rgba(217, 156, 46, 0.08);
}
.hamburger-menu.active { animation: menuButtonPulse 1.8s ease-in-out infinite alternate; }
.hamburger-menu.active .hamburger-line {
  background-color: var(--gold);
  box-shadow: 0 0 8px rgba(234, 182, 85, 0.75);
}

@keyframes menuButtonPulse {
  from { box-shadow: 0 0 8px rgba(217, 156, 46, 0.25); }
  to { box-shadow: 0 0 20px rgba(234, 182, 85, 0.58); }
}

/* Make tables scrollable */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}
table {
  width: 100%;
  min-width: 600px; /* Forces scroll on small screens */
}

/* --- Breakpoint: Laptop & Tablet (max-width: 1024px) --- */
@media screen and (max-width: 1024px) {
  .shell, nav {
    padding: 0 24px;
  }
  .navlinks {
    gap: 20px;
  }
  .hero {
    grid-template-columns: 1fr 1fr;
    padding: 40px 0;
  }
  .products {
    grid-template-columns: repeat(4, 1fr);
  }
  .about-container {
    padding: 40px 30px;
  }
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
  }
}

/* --- Breakpoint: Tablet & Mobile navigation (max-width: 1180px) --- */
@media screen and (min-width: 1181px) and (max-width: 1400px) {
  nav { padding-inline: 24px; }
  .brand { flex: 0 0 auto; font-size: 23px; letter-spacing: 4px; }
  .brand img { width: 36px; height: 36px; margin-right: 8px; }
  .navlinks { gap: clamp(14px, 1.35vw, 19px); font-size: 13px; }
  .icons { flex: 0 0 auto; gap: 12px; }
  .account-user-name { max-width: 85px; }
  .icons > .dropdown, .icons > .dropdown.account-identity { width: 128px; flex-basis: 128px; }
  .icons > .dropdown > .cursor-pointer { min-width: 128px; }
  .dropdown-right .dropdown-content { right: 0; }
}

@media screen and (max-width: 1180px) {
  /* Navigation */
  nav {
    justify-content: flex-start;
    gap: 8px;
  }
  nav > .brand { margin-right: auto; }
  nav > .icons { margin-left: 0; }
  .icons > .dropdown, .icons > .dropdown.account-identity {
    width: 36px;
    flex: 0 0 36px;
  }
  .icons > .dropdown > .cursor-pointer {
    width: 36px;
    min-width: 36px;
    justify-content: center;
  }
  .account-user-name { display: none; }
  .hamburger-menu {
    display: flex;
    margin-left: 0;
  }
  .navlinks {
    display: flex;
    visibility: hidden;
    position: fixed;
    top: 76px;
    right: -100%;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - 76px);
    background: var(--panel);
    flex-direction: column;
    align-items: flex-start;
    padding: 40px 24px;
    gap: 24px;
    transition: right 0.3s ease-in-out;
    z-index: 600;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    isolation: isolate;
  }
  .navlinks::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 90% 8%, rgba(217, 156, 46, 0.18), transparent 38%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
  }
  .navlinks.active {
    right: 0;
    visibility: visible;
    animation: mobileMenuGlow 2.6s ease-in-out infinite alternate;
  }
  .navlinks.active::before {
    opacity: 1;
  }
  .navlinks a {
    font-size: 18px;
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateX(18px);
  }
  .mobile-account-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 10px;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid #4a3b25;
  }
  .mobile-account-links > span {
    grid-column: 1 / -1;
    color: #f0d39a;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
  .mobile-account-links a {
    display: grid;
    place-items: center;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid #604923;
    border-radius: 9px;
    color: #f1d499;
    font-size: 15px;
    text-align: center;
  }
  .mobile-account-links a[hidden] { display: none; }
  .mobile-account-links a:last-child { grid-column: 1 / -1; }
  .navlinks.active a {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.25s ease;
  }
  .navlinks.active a:nth-child(2) { transition-delay: 0.04s; }
  .navlinks.active a:nth-child(3) { transition-delay: 0.08s; }
  .navlinks.active a:nth-child(4) { transition-delay: 0.12s; }
  .navlinks.active a:nth-child(5) { transition-delay: 0.16s; }
  .navlinks.active a:nth-child(6) { transition-delay: 0.2s; }
  .navlinks.active a:nth-child(7) { transition-delay: 0.24s; }
  .navlinks.active a:nth-child(8) { transition-delay: 0.28s; }
  .navlinks > a.active {
    border-bottom: 1px solid var(--gold);
    padding-bottom: 10px;
  }
  
  /* Hero */
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 40px;
  }
  .hero h1 {
    letter-spacing: -1px;
  }
  .hero-visual {
    height: auto;
    min-height: 250px;
  }
  .hero-visual img {
    height: 250px;
    width: 100%;
    object-fit: contain;
  }
  .hero-visual:before {
    width: 250px;
    height: 200px;
  }
  .hero-lantern-logo {
    display: none; /* Hide complex floating elements on small screens */
  }

  /* Grids */
  .categories {
    grid-auto-columns: calc(50% - 9px);
  }
  .products {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .about-features-grid {
    grid-template-columns: 1fr;
  }
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer-social {
    justify-content: center;
  }
  .footer-newsletter form {
    flex-direction: column;
  }
  .footer-newsletter input, .footer-newsletter button {
    width: 100%;
    border-radius: 8px;
  }

  /* Auth / Forms */
  .auth-container, .about-container {
    padding: 30px 20px;
  }
  form input, form select, form textarea {
    width: 100%;
  }

  /* Search & Actions */
  .icons {
    gap: 10px;
  }

  #products .section-title {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  #products .product-tabs {
    width: 100%;
    min-width: 0;
    padding: 2px 0 10px;
  }
  #products .product-tabs::-webkit-scrollbar {
    height: 4px;
  }
  #products .product-tabs::-webkit-scrollbar-track {
    background: transparent;
  }
  #products .product-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }
  #products .view-all-btn {
    align-self: flex-end;
    min-height: 44px;
    padding: 8px 2px;
  }

  .chat {
    right: 14px;
    bottom: 14px;
    width: 58px;
    height: 58px;
  }
  .chat .bubble { display: none; }
  .chat-btn { width: 54px; height: 54px; }
}

/* Keep content grids spacious on landscape tablets while using the menu. */
@media screen and (min-width: 901px) and (max-width: 1180px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    text-align: left;
  }
  .products { grid-template-columns: repeat(4, 1fr); }
  .categories { grid-auto-columns: calc(25% - 13.5px); }
  .about-features-grid { grid-template-columns: repeat(2, 1fr); }
}

@keyframes mobileMenuGlow {
  from { box-shadow: -10px 0 28px rgba(0, 0, 0, 0.5), -2px 0 8px rgba(217, 156, 46, 0.08); }
  to { box-shadow: -12px 0 36px rgba(0, 0, 0, 0.62), -3px 0 18px rgba(217, 156, 46, 0.24); }
}

/* --- Breakpoint: Small Mobile (max-width: 480px) --- */
@media screen and (max-width: 480px) {
  .shell, nav {
    padding: 0 16px;
  }
  .brand {
    font-size: 20px;
    letter-spacing: 2px;
  }
  .brand img {
    width: 32px;
    height: 32px;
  }
  .brand-text { font-size: 16px; letter-spacing: 1.6px; white-space: nowrap; }
  .icons > .dropdown { display: none; }
  .icons > .icon-link:not(:last-child) { display: none; }
  .categories {
    grid-auto-columns: calc(85% - 10px);
    scroll-snap-type: x mandatory;
  }
  .category {
    scroll-snap-align: center;
  }
  .products {
    grid-template-columns: 1fr;
  }
  .card img {
    height: 200px;
  }
  .product-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
  }
  #products .section-title h2 { font-size: 24px; }
}

@media screen and (max-width: 360px) {
  nav { padding-inline: 12px; gap: 5px; }
  .brand img { width: 28px; height: 28px; margin-right: 6px; }
  .brand-text { font-size: 14px; letter-spacing: 1.2px; }
  .icons { gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
