/* Mobile layout fixes for ~400px and small screens */
html, body {
  overflow-x: hidden;
}

/* CLS / LCP: layout + image box before Tailwind CDN applies utility classes */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f1f5f9;
}

/*
 * Full product in frame: absolute centering inside a fixed aspect box.
 * Flex + img fails in many browsers: flex items get min-height:auto from the
 * image’s intrinsic size, so the bitmap can’t shrink and overflow:hidden clips
 * (looks like object-fit:cover). Positioned img avoids that.
 */
.product-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background-color: rgb(226 232 240);
  overflow: hidden;
}

.product-card-media img.product-card-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  box-sizing: border-box;
  object-fit: contain;
  object-position: center;
}

/* Basket line thumbnails: same “fit in box” behavior */
.basket-item-thumb {
  position: relative;
  overflow: hidden;
}

.basket-item-thumb img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

#home-main-product-area {
  position: relative;
  min-height: min(60vh, 720px);
}

#products-page-main {
  position: relative;
  min-height: min(50vh, 640px);
}

/* CLS: orders list area swaps loading / empty / list — reserve space */
#orders-page-main {
  min-height: min(40vh, 480px);
}

/*
 * CLS: match logged-in/out nav before applyLanguage (token in localStorage).
 * Specificity must beat #header-nav .hidden on narrow screens.
 */
html.auth #header-nav #nav-login,
html.auth #header-nav #go-account {
  display: none !important;
}
html.auth #header-nav #nav-logout {
  display: inline-flex !important;
  align-items: center;
}
html.auth #header-nav #nav-orders,
html.auth #header-nav #nav-profile {
  display: inline-flex !important;
  align-items: center;
}

@media (max-width: 639px) {
  #header-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    gap: 0.25rem;
  }
  #header-nav.mobile-open {
    display: flex !important;
  }
  #header-nav a,
  #header-nav button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    border-radius: 0.375rem;
  }

  /* Tailwind `hidden` must win on mobile.
     Otherwise `#header-nav a,#header-nav button { display:inline-flex }`
     will show both Login and Logout even when JS toggles `.hidden`. */
  #header-nav .hidden {
    display: none !important;
  }

  /* Basket in header bar (outside hamburger) — touch-friendly */
  #nav-basket-mobile {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* Profile: delete account button — explicit colors so it stays visible if Tailwind build omits bg-red-700 */
#btn-delete-account {
  background-color: #b91c1c;
  color: #ffffff;
  border: 1px solid #991b1b;
}
#btn-delete-account:hover {
  background-color: #991b1b;
  color: #ffffff;
}
#btn-delete-account:focus-visible {
  outline: 2px solid #7f1d1d;
  outline-offset: 2px;
}
