/* ============================================================
   KLEDJE STORE — STOREFRONT STYLES
   Layered on design-system.css
   ============================================================ */

/* Flash Messages */
.flash-message {
  margin: 0 var(--content-pad) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-xs);
  background: #e7f7ed;
  color: #1b6540;
  font-weight: var(--fw-medium);
  font-size: var(--fs-2xs);
  border: 1px solid #bce5cb;
  animation: flash-slide-in var(--dur-base) var(--ease-out-back);
}

.flash-message--error,
.form-alert {
  background: #fff0f0;
  color: #a52a2a;
  border-color: #f4c2c2;
}

.form-alert {
  margin: 0 var(--content-pad) var(--space-2);
  padding: var(--space-2);
  border: 1px solid;
  border-radius: var(--r-xs);
}

.flash-message.is-hiding {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity var(--dur-base) var(--ease-out-expo),
              transform var(--dur-base) var(--ease-out-expo);
}

@keyframes flash-slide-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page Header */
.page-head {
  padding: var(--space-3) var(--content-pad) var(--space-4);
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  line-height: 1.2;
  margin: 4px 0 2px;
}

.page-head h1 em {
  color: var(--color-primary);
  font-style: italic;
}

.page-head p {
  color: var(--color-text-soft);
  margin: 0;
  font-size: var(--fs-2xs);
}

.back-link {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--color-primary);
}

.result-count {
  display: inline-flex;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--fs-2xs);
}

/* Sort Bar */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 var(--content-pad) 8px;
  font-size: var(--fs-2xs);
}

.sort-bar select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-xs);
  background: var(--color-surface);
  font-size: var(--fs-2xs);
}

/* Products Grid */
.products--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  padding: 0 var(--content-pad);
}

.products--scroll {
  display: flex;
  overflow-x: auto;
  gap: var(--space-2);
  padding: 0 var(--content-pad) var(--space-2);
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--content-pad);
  scrollbar-width: none;
}

.products--scroll::-webkit-scrollbar { display: none; }

.products--scroll > .product-card:last-child {
  margin-inline-end: var(--content-pad);
}

.products--scroll .product-card {
  width: 160px;
  min-width: 160px;
  scroll-snap-align: start;
}

/* Product Card Overrides */
.product-card__body {
  padding: var(--space-2);
}

.product-card__rating {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--color-accent);
  font-size: var(--fs-xs);
  margin: 3px 0;
}

.product-card__rating small {
  color: var(--color-text-muted);
}

.product-card__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3px;
}

.product-card__prices {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px;
}

.product-card__price {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.product-card__old-price {
  font-size: var(--fs-2xs);
}

.quick-add-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  background: var(--color-primary);
  color: white;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: transform var(--dur-quick) var(--ease-spring),
              background var(--dur-quick) var(--ease-out-expo);
}

.quick-add-btn:active {
  transform: scale(.85);
  background: var(--color-primary-deep);
}

.product-card__badge--bundle {
  inset-inline-start: auto;
  inset-inline-end: 6px;
  background: var(--color-primary);
}

.stock-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(26, 26, 46, 0.5);
  color: white;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: var(--space-4);
}

.pagination a {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: var(--fs-2xs);
  transition: all var(--dur-quick) var(--ease-out-expo);
}

.pagination a:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.pagination a.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Trust Grid */
.trust-grid {
  margin: 0 var(--content-pad) var(--space-6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.trust-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  padding: var(--space-2);
  border-radius: var(--r-xs);
  border: 1px solid var(--color-border);
  transition: transform var(--dur-base) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-out-expo);
}

.trust-item:active { transform: scale(.97); }

.trust-item > b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 14px;
  flex-shrink: 0;
}

.trust-item span {
  display: flex;
  flex-direction: column;
}

.trust-item strong {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

.trust-item small {
  font-size: var(--fs-2xs);
  color: var(--color-text-muted);
}

/* ============================================================
   PRODUCT DETAIL PAGE
   ============================================================ */
.product-detail__media {
  position: relative;
  background: var(--color-primary-soft);
  min-height: 300px;
  padding: var(--space-3);
}

.product-detail__media img {
  width: 100%;
  height: 280px;
  object-fit: contain;
}

.detail-badge {
  position: absolute;
  top: 40px;
  inset-inline-end: 12px;
  background: var(--color-accent);
  color: white;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
}

.product-detail__body {
  padding: var(--space-4) var(--content-pad);
}

.product-detail__category {
  color: var(--color-primary);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

.product-detail h1 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  line-height: 1.2;
  margin: 4px 0;
}

.product-detail__en {
  color: var(--color-text-muted);
  margin: 0 0 5px;
  font-size: var(--fs-2xs);
}

.detail-prices {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.detail-prices strong {
  font-size: var(--fs-sm);
  color: var(--color-primary);
  font-weight: var(--fw-bold);
}

.detail-prices del {
  color: var(--color-text-muted);
  font-size: var(--fs-2xs);
}

.stock-message {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-xs);
  font-size: var(--fs-2xs);
  background: #fff3df;
  color: #9a5b00;
}

.stock-message--in {
  background: #e7f7ed;
  color: #1b6540;
}

.stock-message--out {
  background: #fff0f0;
  color: #a52a2a;
}

.product-description,
.bundle-list {
  margin: var(--space-3) 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.product-description h2,
.bundle-list h2 {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

.product-description p {
  font-size: var(--fs-2xs);
  line-height: 1.6;
  color: var(--color-text-soft);
  max-height: 160px;
  overflow: auto;
}

.bundle-list li {
  font-size: var(--fs-2xs);
  margin: 4px 0;
}

.add-to-cart {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.quantity-control {
  display: flex;
  width: 110px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-xs);
  overflow: hidden;
}

.quantity-control button {
  width: 32px;
  background: var(--color-primary-soft);
  font-size: 14px;
  transition: background var(--dur-quick) var(--ease-out-expo);
}

.quantity-control button:hover {
  background: var(--color-primary);
  color: white;
}

.quantity-control input {
  flex: 1;
  text-align: center;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.related-products {
  padding-top: var(--space-2);
}

/* ============================================================
   CART & CHECKOUT
   ============================================================ */
.cart-form,
.order-summary,
.form-card {
  margin: 0 var(--content-pad) var(--space-3);
}

.cart-lines {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.cart-line {
  display: flex;
  gap: var(--space-2);
  position: relative;
  background: var(--color-surface);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--r-sm);
}

.cart-line img {
  width: 72px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--r-xs);
  flex-shrink: 0;
}

.cart-line__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cart-line h2 {
  font-size: var(--fs-2xs);
  margin: 0;
  font-weight: var(--fw-medium);
}

.cart-line strong {
  font-size: var(--fs-2xs);
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

.cart-line label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-2xs);
  margin-top: 4px;
  color: var(--color-text-muted);
}

.cart-line input {
  width: 44px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-xs);
  text-align: center;
  font-size: var(--fs-2xs);
}

.remove-btn {
  position: absolute;
  inset-inline-end: var(--space-2);
  top: var(--space-1);
  font-size: 16px;
  color: var(--color-text-muted);
  transition: color var(--dur-quick) var(--ease-out-expo);
}

.remove-btn:hover {
  color: var(--color-error, #c0392b);
}

.order-summary,
.form-card {
  background: var(--color-surface);
  padding: var(--space-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.order-summary h2,
.form-card h2 {
  font-size: var(--fs-2xs);
  margin: 0 0 var(--space-3);
  font-weight: var(--fw-semibold);
}

.order-summary dl {
  margin: 0 0 var(--space-3);
}

.order-summary dl div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: var(--fs-2xs);
}

.summary-total {
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
  padding-top: var(--space-2);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
}

.shipping-note {
  font-size: var(--fs-2xs);
  color: var(--color-primary);
  background: var(--color-primary-soft);
  padding: var(--space-2);
  border-radius: var(--r-xs);
  text-align: center;
}

/* Checkout Form */
.checkout-form {
  padding-bottom: var(--space-3);
}

.field {
  display: grid;
  gap: 3px;
  margin-bottom: var(--space-3);
}

.field label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

.field input,
.field textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--r-xs);
  background: var(--color-bg);
  outline: 0;
  font-size: var(--fs-sm);
  transition: all var(--dur-base) var(--ease-out-expo);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.field-error {
  color: var(--color-error, #c0392b);
  font-size: var(--fs-2xs);
}

.payment-option {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.payment-option span {
  display: flex;
  flex-direction: column;
}

.payment-option small {
  color: var(--color-text-muted);
}

.checkout-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--fs-2xs);
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
}

.checkout-consent {
  display: block;
  text-align: center;
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  font-size: var(--fs-2xs);
}

/* ============================================================
   SUCCESS & EMPTY PAGES
   ============================================================ */
.success-page {
  padding: var(--space-7) var(--content-pad);
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: #e7f7ed;
  color: #1b6540;
  font-size: 32px;
}

.success-eyebrow {
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
}

.success-page h1 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin: var(--space-2) 0;
}

.success-page > p {
  color: var(--color-text-soft);
  font-size: var(--fs-2xs);
}

.order-number {
  display: flex;
  flex-direction: column;
  background: var(--color-primary-soft);
  padding: var(--space-3);
  border-radius: var(--r-xs);
  margin: var(--space-3) 0;
}

.order-number strong {
  font-size: var(--fs-sm);
  color: var(--color-primary);
}

.success-summary {
  text-align: start;
  margin: var(--space-3) 0;
}

.success-page > .btn {
  margin-bottom: var(--space-2);
}

.empty-state {
  text-align: center;
  padding: var(--space-9) var(--content-pad);
}

.empty-state > span {
  font-size: 40px;
  color: var(--color-primary);
}

.empty-state h2,
.empty-state h1 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
}

.empty-state p {
  color: var(--color-text-muted);
  font-size: var(--fs-2xs);
}

.not-found > span {
  font-size: 48px;
  font-weight: var(--fw-black);
}

.page-products {
  padding-bottom: var(--space-5);
}

/* ============================================================
   RESPONSIVE — Tablet (600px+)
   ============================================================ */
@media (min-width: 600px) {
  .products--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .trust-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .page-head h1 {
    font-size: var(--fs-lg);
  }
}

/* ============================================================
   RESPONSIVE — Desktop (1024px+)
   ============================================================ */
@media (min-width: 1024px) {
  .products--grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }

  .page-head {
    padding: var(--space-4) var(--space-6) var(--space-5);
  }

  .page-head h1 {
    font-size: var(--fs-xl);
  }

  .sort-bar {
    padding: 0 var(--space-6) var(--space-3);
  }

  .products--grid {
    padding: 0 var(--space-6);
  }

  .trust-grid {
    margin: 0 var(--space-6) var(--space-7);
    gap: var(--space-3);
  }

  .trust-item {
    padding: var(--space-3);
  }

  .cart-form,
  .order-summary,
  .form-card {
    max-width: 640px;
    margin-inline: auto;
  }

  .success-page {
    max-width: 640px;
    margin-inline: auto;
  }

  .product-detail__media img {
    height: 400px;
  }

  .product-detail__body {
    max-width: 640px;
    margin-inline: auto;
  }
}

/* ============================================================
   RESPONSIVE — Large desktop (1200px+)
   ============================================================ */
@media (min-width: 1200px) {
  .products--grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .flash-message {
    animation: none;
  }
}

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
  background: #1a1a2e;
  color: #ccc;
  padding: 48px 24px 24px;
  margin-top: 48px;
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.site-footer__brand {
  max-width: 320px;
}

.site-footer__logo {
  max-height: 48px;
  margin-bottom: 12px;
  filter: brightness(0) invert(1);
}

.site-footer__tagline {
  font-size: 14px;
  line-height: 1.6;
  color: #aaa;
  margin-bottom: 16px;
}

.site-footer__social {
  display: flex;
  gap: 12px;
}

.site-footer__social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  transition: background .2s ease;
}

.site-footer__social a:hover {
  background: var(--color-primary);
}

.site-footer__social svg {
  width: 18px;
  height: 18px;
}

.site-footer__links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.site-footer__links a {
  color: #aaa;
  font-size: 14px;
  transition: color .2s ease;
}

.site-footer__links a:hover {
  color: #fff;
}

.site-footer__bottom {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 13px;
  color: #888;
}

@media (max-width: 640px) {
  .site-footer {
    padding: 32px 16px 16px;
  }
  .site-footer__inner {
    flex-direction: column;
    gap: 24px;
  }
  .site-footer__brand {
    max-width: 100%;
  }
}
