:root {
  --header-height: 64px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(15, 17, 21, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px !important;
  gap: 16px;
}

.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand__logo {
  height: auto;
  max-height: 44px;
  width: auto;
}

/* Navigation Toggle Button */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms ease;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.24) !important;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text) !important;
  border-radius: 1px;
  transition: all 300ms ease;
  transform-origin: center;
}

.nav-toggle span:nth-child(1) {
  width: 18px;
}

.nav-toggle span:nth-child(3) {
  width: 18px;
}

/* Toggle Animation - Active State */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translateY(8px);
  width: 20px;
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translateY(-8px);
  width: 20px;
}

/* Navigation Menu */
.nav {
  display: flex !important;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav__link {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--muted) !important;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 200ms ease;
  white-space: nowrap;
  display: inline-block;
}

.nav__link:hover,
.nav__link:focus {
  color: var(--text) !important;
  background: rgba(255, 255, 255, 0.06);
}

.nav__link.is-active {
  color: var(--accent) !important;
  background: rgba(196, 18, 26, 0.12);
}

/* Mobile: Navigation Off-Canvas */
@media (max-width: 991px) {
  /* Show Toggle Button */
  .nav-toggle {
    display: flex !important;
  }

  /* Hide Desktop Navigation */
  .nav {
    position: fixed !important;
    top: 0;
    right: -100%;
    bottom: 0;
    width: min(80vw, 320px);
    flex-direction: column !important;
    gap: 0 !important;
    padding: max(70px, calc(var(--header-height) + 6px)) 0 20px 0 !important;
    background: var(--bg) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    transition: right 400ms var(--ease);
    z-index: 1001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav[data-nav-open="true"] {
    right: 0;
  }

  .nav__link {
    width: 100%;
    display: block !important;
    padding: 14px 20px !important;
    border-radius: 0;
    font-size: 16px !important;
    line-height: 1.5 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 200ms ease;
    position: relative;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 44px !important;
  }

  .nav__link:hover,
  .nav__link:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text) !important;
  }

  .nav__link.is-active {
    background: rgba(196, 18, 26, 0.2) !important;
    border-left: 3px solid var(--accent) !important;
    padding-left: calc(20px - 3px) !important;
    color: var(--accent) !important;
  }

  /* Mobile Backdrop */
  .nav::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 400ms ease;
    z-index: 1000;
  }

  .nav[data-nav-open="true"]::before {
    opacity: 1;
    pointer-events: auto;
  }
}

/*========== ULTRA-SMALL SCREENS (< 320px) ==========*/

@media (max-width: 320px) {
  .header__inner {
    padding: 12px 16px !important;
    gap: 12px;
  }

  .brand__logo {
    max-height: 36px;
  }

  .nav-toggle {
    width: 36px !important;
    height: 36px !important;
    padding: 6px !important;
  }

  .nav-toggle span {
    width: 18px;
    height: 2px;
  }

  .nav-toggle span:nth-child(1),
  .nav-toggle span:nth-child(3) {
    width: 16px;
  }

  .nav {
    width: min(90vw, 280px) !important;
    padding: 60px 0 16px 0 !important;
  }

  .nav__link {
    padding: 12px 16px !important;
    font-size: 15px !important;
  }
}

/*========== MOBILE HEADER ENHANCEMENTS ==========*/

@media (max-width: 991px) {
  /* Ensure header always visible and properly sized */
  .site-header {
    min-height: 64px;
    display: flex;
    align-items: center;
  }

  .header__inner {
    width: 100%;
    height: 100%;
    min-height: 64px;
  }

  /* Better toggle button styling */
  .nav-toggle {
    transition: all 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-shrink: 0;
  }

  .nav-toggle:active {
    transform: scale(0.95);
  }

  .nav-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .nav-toggle.is-active {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
  }

  /* Navigation menu improvements */
  .nav__link::after {
    content: "" !important;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.04);
    display: block !important;
  }

  .nav__link.is-active::after {
    display: none !important;
  }

  /* Landscape orientation optimization */
  @media (orientation: landscape) and (max-height: 600px) {
    .header__inner {
      min-height: 56px;
      padding: 12px 16px !important;
      gap: 12px;
    }

    .brand__logo {
      max-height: 32px;
    }

    .nav-toggle {
      width: 36px !important;
      height: 36px !important;
      padding: 6px !important;
    }

    .nav {
      padding: 56px 0 16px 0 !important;
    }

    .nav__link {
      padding: 10px 16px !important;
      font-size: 15px !important;
    }
  }

  /* Prevent header from being covered by notch (safe area) */
  .site-header {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  /* Smooth menu open animation */
  .nav {
    will-change: right;
  }

  .nav[data-nav-open="true"] {
    animation: slideInMenu 400ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }

  @keyframes slideInMenu {
    from {
      right: -100%;
    }
    to {
      right: 0;
    }
  }
}

/*========== RESPONSIVE GRID ==========*/

@media (max-width: 991px) {
  .grid--3 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .grid--2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .bestsellers__grid {
    flex-direction: column;
  }

  .section__head {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* Card styling in grids */
  .grid--3 .card,
  .grid--2 .card {
    padding: 18px !important;
  }

  .card .media {
    height: clamp(180px, 40vw, 220px);
    margin-bottom: 12px;
  }

  .card .h3 {
    font-size: clamp(16px, 4vw, 18px) !important;
    margin: 8px 0 4px;
  }

  .card .sub,
  .card p {
    font-size: 13px !important;
    line-height: 1.5 !important;
    margin: 0;
  }
}

/*========== TOUCH-FRIENDLY BUTTONS ==========*/

@media (max-width: 991px) {
  .btn,
  a.btn,
  button.btn {
    padding: 14px 24px !important;
    font-size: 16px !important;
    min-height: 48px;
    border-radius: 10px !important;
    width: auto;
  }

  .btn:active,
  a.btn:active,
  button.btn:active {
    transform: scale(0.98);
  }

  /* CTA button improvements */
  .btn--primary {
    padding: 16px 28px !important;
    font-size: 16px !important;
    letter-spacing: 0 !important;
  }

  .btn--ghost {
    padding: 14px 24px !important;
    font-size: 15px !important;
  }

  /* Better button spacing */
  .btn + .btn {
    margin-left: 12px;
  }

  /* Full-width buttons in mobile when stacked */
  .split .btn,
  .actions .btn {
    width: 100%;
  }
}

/*========== HERO SECTION ==========*/

@media (max-width: 991px) {
  .hero {
    min-height: 480px;
  }

  .hero__inner {
    padding-block: 60px !important;
  }

  .h1 {
    font-size: 28px !important;
    line-height: 1.2 !important;
  }

  .lead {
    font-size: 16px !important;
  }

  .hero__panel {
    margin-top: 32px;
    padding: 20px !important;
  }

  /* Hero background improvements */
  .hero__bg {
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  /* Hero text contrast */
  .hero__inner > * {
    position: relative;
    z-index: 2;
  }
}

/*========== PRODUCT CARDS OPTIMIZATION ==========*/

@media (max-width: 991px) {
  .products {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px !important;
  }

  .product {
    padding: 16px !important;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 12px;
    align-items: flex-start;
  }

  .product__img {
    grid-column: 1;
    grid-row: 1 / -1;
    min-width: 100px;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
  }

  .product__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .product__meta {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .product__meta b {
    font-size: 15px !important;
    line-height: 1.3;
  }

  .product__meta span {
    font-size: 12px;
    color: var(--muted) !important;
    display: block;
  }

  .product .price {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent) !important;
    margin-top: 2px;
  }

  .product .small {
    font-size: 13px !important;
    line-height: 1.5 !important;
    display: block;
    margin-top: 8px;
    grid-column: 1 / -1;
    color: var(--muted) !important;
  }

  .product .small:first-of-type {
    margin-top: 0;
    order: -1;
  }

  .product .small b {
    color: var(--text) !important;
    font-weight: 600;
  }

  /* Emoji icons visibility */
  .product .small::before {
    margin-right: 6px;
    font-size: 16px;
  }
}

/*========== CARDS & SECTIONS ==========*/

@media (max-width: 991px) {
  .card {
    padding: 20px !important;
  }

  .media {
    height: 240px;
  }

  .bestsellers-slider-container {
    padding: 0 12px;
  }

  /* Improve image visibility on mobile */
  img,
  .media img,
  .product__img img {
    border-radius: 8px !important;
  }

  /* Text sizing improvements */
  .small {
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  .sub {
    font-size: 15px !important;
  }

  .h3,
  .h2 {
    font-size: clamp(20px, 5vw, 24px) !important;
  }

  /* Better spacing in sections */
  .section {
    padding-top: 80px !important;
    padding-bottom: 80px !important;
  }

  .section--tight {
    padding-top: 60px !important;
    padding-bottom: 60px !important;
  }

  /* Table styling for mobile */
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table thead {
    display: none;
  }

  .table tbody {
    display: block;
  }

  .table tr {
    display: block;
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
    padding: 12px 0;
    margin-bottom: 12px;
  }

  .table td {
    display: block;
    padding: 6px 0;
    text-align: left;
  }

  .table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    color: var(--accent);
    font-size: 12px;
    margin-bottom: 4px;
  }

  /* Container padding on mobile */
  .container {
    padding-inline: 20px !important;
  }

  /* Grid gap adjustment */
  .grid {
    gap: 20px !important;
  }

  /* FAQ & Accordion improvements */
  .faq-list {
    gap: 12px !important;
  }

  .faq-item {
    padding: 16px !important;
    border-radius: 10px;
  }

  .faq-question {
    font-size: 16px !important;
    margin-bottom: 0;
  }

  .faq-answer {
    font-size: 14px !important;
    line-height: 1.5;
    margin-top: 12px;
  }

  /* Notice/Info boxes */
  .notice {
    padding: 16px !important;
    font-size: 14px !important;
    line-height: 1.5;
    border-radius: 10px;
  }

  /* Split layouts on mobile */
  .split {
    flex-direction: column !important;
    gap: 20px !important;
  }

  .split > * {
    width: 100% !important;
  }

  /* Better spacing for content sections */
  .section__head {
    margin-bottom: 24px;
  }

  .kicker {
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
  }
}

/*========== FOOTER ==========*/

@media (max-width: 991px) {
  .footer__grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  .footer__brand img {
    max-height: 40px !important;
  }

  .footer__title {
    font-size: 16px !important;
    margin-bottom: 12px;
  }

  .footer__links,
  .footer__contact {
    font-size: 14px !important;
  }
}

/*========== INPUT & FORMS ==========*/

@media (max-width: 991px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
    min-height: 48px;
    border-radius: 8px !important;
    padding: 12px 16px !important;
  }

  textarea {
    min-height: 120px;
  }
}

/*========== TYPOGRAPHY MOBILE ==========*/

@media (max-width: 991px) {
  body {
    font-size: 16px;
  }

  .h2,
  h2 {
    font-size: 24px !important;
    line-height: 1.3 !important;
  }

  .h3,
  h3 {
    font-size: 20px !important;
  }

  .kicker {
    font-size: 12px !important;
    letter-spacing: 0.8px;
  }
}

/*========== IMAGE & MEDIA ==========*/

@media (max-width: 991px) {
  img {
    max-width: 100%;
    height: auto;
  }

  .bestsellers-slider-item {
    scroll-snap-align: start;
  }
}

/*========== ACCESSIBILITY MOBILE ==========*/

@media (max-width: 991px) {
  /* Larger touch zones */
  a,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Better focus visibility on mobile */
  *:focus-visible {
    outline-offset: 2px !important;
  }
}

/*========== SAFE ZONES (notches, etc) ==========*/

@supports (padding: max(0px)) {
  .site-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .container {
    padding-left: max(20px, env(safe-area-inset-left)) !important;
    padding-right: max(20px, env(safe-area-inset-right)) !important;
  }

  .nav {
    padding-right: env(safe-area-inset-right) !important;
  }

  footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/*========== PORTRAIT ORIENTATION ==========*/

@media (orientation: portrait) and (max-height: 600px) {
  .hero {
    min-height: 380px;
  }

  .section {
    padding-top: 60px !important;
    padding-bottom: 60px !important;
  }
}

/*========== FOOTER & GLOBAL IMPROVEMENTS ==========*/

@media (max-width: 991px) {
  .site-footer {
    padding: 60px 20px !important;
  }

  .footer__grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  .footer__title {
    font-size: 16px !important;
    margin-bottom: 12px;
  }

  .footer__links li {
    margin-bottom: 8px;
  }

  .footer__contact {
    font-size: 14px !important;
    line-height: 1.6;
  }

  /* Lists & Descriptions */
  ul,
  ol {
    margin-left: 20px;
  }

  li {
    margin-bottom: 8px;
    font-size: 14px !important;
  }

  /* Emphasis text */
  b,
  strong {
    color: var(--text) !important;
  }

  em,
  i {
    color: var(--muted) !important;
  }

  /* Better link styling on mobile */
  a {
    text-decoration: underline;
  }

  a.btn,
  a.nav__link {
    text-decoration: none;
  }

  /* Form elements */
  input,
  textarea,
  select {
    font-size: 16px !important;
    padding: 12px !important;
    min-height: 44px;
    border-radius: 8px;
  }

  /* Back-to-top button positioning */
  .back-to-top {
    right: 16px !important;
    bottom: 16px !important;
    width: 44px !important;
    height: 44px !important;
  }

  /* Prevent text selection on menu */
  .nav-toggle {
    user-select: none;
  }

  /* Improve focus visible for touch */
  button:focus-visible,
  a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/*========== LOW BANDWIDTH / SLOW CONNECTIONS ==========*/

@media (prefers-reduced-data: reduce) {
  * {
    background-attachment: scroll !important;
  }

  img {
    image-rendering: pixelated;
  }

  animation {
    animation: none !important;
    transition: none !important;
  }
}
