/**
 * LNC Alpine Store - Minimal Styles
 * Clean, modern, performance-focused
 */

/* === GLOBAL UTILITIES === */
/* Prevent layout shift when scrollbars appear/disappear */
html { scrollbar-gutter: stable; }

/* Lock page scroll when sidecart or another modal is open */
html.lnc-scroll-lock { overflow: hidden; }

/* === RESET & BASE === */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f9fafb;
}

a {
  color: #2563eb;
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #1d4ed8;
}

/* === HEADER === */
#site-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.c-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111;
}

#site-navigation {
  flex: 1;
}

.c-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem;
}

.c-menu a {
  color: #6b7280;
  font-weight: 500;
  transition: color 0.2s;
}

.c-menu a:hover,
.c-menu .current-menu-item a {
  color: #111;
}

/* === CART BADGE === */
.c-cart-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  transition: all 0.2s;
  cursor: pointer;
}

.c-cart-link:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

.c-cart-link.has-items {
  background: #059669;
}

.c-cart-link.has-items:hover {
  background: #047857;
}

.c-cart-link svg {
  width: 20px;
  height: 20px;
}

.c-cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 5px;
  border: 2px solid #fff;
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* === MAIN CONTENT === */
#main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.woocommerce-products-header {
  margin-bottom: 2rem;
}

.woocommerce-products-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #111;
  margin: 0 0 0.5rem;
}

/* === PRODUCTS GRID === */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  list-style: none; /* Still needed for backward compat */
  margin: 0;
  padding: 0;
}

/* Product card */
.product {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
}

.product:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

/* Product image container */
.product-image {
  margin: 0;
  padding: 0;
}

.product-image a {
  display: block;
}

.product-image img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* Product content area */
.product-content {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Product title */
.product-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: #111;
}

.product-title a {
  color: inherit;
  text-decoration: none;
}

/* Product price */
.product-price {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: #2563eb;
  margin: 0 0 1rem;
}

/* Product button */
.product .button {
  display: block;
  width: 100%;
  margin-top: auto; /* Push to bottom */
  padding: 0.75rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  text-decoration: none;
}

.product .button:hover {
  background: #1d4ed8;
}

/* Load more section */
.load-more {
  margin-top: 2rem;
  text-align: center;
}

.load-more button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.load-more button:hover {
  background: #1d4ed8;
}

.load-more p {
  margin-top: 1rem;
  color: #6b7280;
}

/* === SINGLE PRODUCT PAGE === */
.product {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Product images */
.product-images {
  margin: 0;
  padding: 0;
}

/* Product summary */
.product-summary {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.product-summary .product-title {
  font-size: 2rem;
  margin: 0;
}

.product-summary .product-price {
  font-size: 1.5rem;
}

/* Variation form */
.variations-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.variation-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.variation-selector label {
  font-weight: 600;
  color: #111;
}

.variation-selector select {
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
}

.variation-selector select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Stock status */
.stock {
  font-weight: 600;
  margin: 0;
}

/* Product meta */
.product-meta {
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.875rem;
  color: #6b7280;
}

/* Add to cart button (single product) */
.single-add-to-cart-button {
  padding: 1rem 2rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.single-add-to-cart-button:hover:not(:disabled) {
  background: #1d4ed8;
}

.single-add-to-cart-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .product {
    grid-template-columns: 1fr;
  }
}

/* === SIDE CART === */
.lnc-sidecart {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  /* Prevent scroll chaining behind the panel on touch devices */
  overscroll-behavior: contain;
}

.lnc-sidecart__overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.lnc-sidecart__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.lnc-sidecart__header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lnc-sidecart__header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.lnc-sidecart__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  color: #6b7280;
  transition: color 0.2s;
  /* Prevent double-tap zoom and accidental selection on mobile */
  touch-action: manipulation;
  user-select: none;
}

.lnc-sidecart__close:hover {
  color: #111;
}

.lnc-sidecart__body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  /* iOS momentum scrolling + prevent scroll chaining */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.lnc-sidecart__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lnc-sidecart__item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lnc-sidecart__item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.lnc-sidecart__meta {
  flex: 1;
}

.lnc-sidecart__name {
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: #111;
}

.lnc-sidecart__qty {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.lnc-sidecart__remove {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #dc2626;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s;
  /* Prevent double-tap zoom and accidental selection on mobile */
  touch-action: manipulation;
  user-select: none;
}

.lnc-sidecart__remove:hover {
  transform: scale(1.2);
}

/* Ensure all actionable elements within the cart behave well on touch */
.lnc-sidecart button,
.lnc-sidecart__actions a {
  touch-action: manipulation;
  user-select: none;
}

/* Side cart – per-item removing state */
.lnc-sidecart__item.removing {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Disabled remove button affordance */
.lnc-sidecart__remove:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .lnc-sidecart__panel {
    animation: none;
    transition: none;
  }

  .lnc-sidecart__item.removing {
    transition: none;
  }
}

.lnc-sidecart__footer {
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.lnc-sidecart__row {
  display: flex;
  justify-content: space-between;
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.lnc-sidecart__actions {
  display: flex;
  gap: 0.75rem;
}

.lnc-sidecart__view-cart,
.lnc-sidecart__checkout {
  flex: 1;
  padding: 0.75rem;
  text-align: center;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s;
}

.lnc-sidecart__view-cart {
  background: #fff;
  border: 2px solid #2563eb;
  color: #2563eb;
}

.lnc-sidecart__view-cart:hover {
  background: #eff6ff;
}

.lnc-sidecart__checkout {
  background: #2563eb;
  color: #fff;
  border: 2px solid #2563eb;
}

.lnc-sidecart__checkout:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* === LOAD MORE === */
button {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === FOOTER === */
#site-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 2rem 1rem;
  margin-top: 4rem;
  text-align: center;
  color: #6b7280;
}

/* === UTILITIES === */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .c-header-inner {
    flex-wrap: wrap;
  }

  .c-menu {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .products {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

  .lnc-sidecart__panel {
    width: 100%;
  }
}

/* Alpine.js utility - prevents text flicker on page load */
[x-cloak] { display: none !important; }
