/* store.css — cart UI, header icons, product-detail page
   Loads AFTER main stylesheets; uses existing custom properties only. */

/* ============================================================
   HEADER ICONS
   ============================================================ */

.nav-icon {
  appearance: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  position: relative;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-icon:hover,
.nav-icon:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
  outline: none;
}

/* Cart badge */
.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
  pointer-events: none;
}
.cart-count[hidden] {
  display: none;
}

/* ============================================================
   CART OVERLAY
   ============================================================ */

.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.cart-overlay.open {
  opacity: 1;
}
.cart-overlay[hidden] {
  display: none;
}

/* ============================================================
   CART DRAWER
   ============================================================ */

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(400px, 92vw);
  z-index: 130;
  background: var(--canvas-2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.cart-drawer.open {
  transform: none;
}
.cart-drawer[hidden] {
  display: none;
}

/* Drawer header */
.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cart-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink);
}

.cart-close {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  padding: 0.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.cart-close:hover,
.cart-close:focus-visible {
  color: var(--ink);
  outline: none;
}

/* Items list */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cart-empty {
  color: var(--muted);
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* Individual cart row */
.cart-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.cart-row:last-child {
  border-bottom: none;
}
.cart-row img {
  width: 54px;
  height: 72px;
  object-fit: contain;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: block;
}

.cart-row-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.cart-row-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-row-price {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Qty controls */
.cart-qty {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.cart-qty button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s, color 0.15s;
}
.cart-qty button:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.cart-qty span {
  font-size: 0.85rem;
  min-width: 1.5ch;
  text-align: center;
  color: var(--ink);
}

/* Remove button */
.cart-rm {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--faint);
  padding: 0.2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  align-self: start;
  transition: color 0.15s;
}
.cart-rm:hover,
.cart-rm:focus-visible {
  color: var(--ink);
  outline: none;
}

/* Drawer footer */
.cart-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--canvas);
  flex-shrink: 0;
}

.cart-note {
  font-size: 0.8rem;
  color: var(--accent-text);
  margin-bottom: 0.75rem;
}

.cart-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.85rem;
}

.btn-block {
  width: 100%;
}

.cart-keep {
  appearance: none;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.6rem;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.cart-keep:hover,
.cart-keep:focus-visible {
  color: var(--ink);
  outline: none;
}

/* ============================================================
   PRODUCT PAGE
   ============================================================ */

.product-wrap {
  padding-top: clamp(1.5rem, 4vw, 3rem);
}

.product-breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.product-breadcrumb a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}
.product-breadcrumb a:hover {
  color: var(--accent-text);
}
.product-breadcrumb span {
  margin: 0 0.4em;
  opacity: 0.5;
}

/* Two-column layout for the product detail page only. Do not target the shared
   .product-grid class globally; the shop grid also uses that class. */
.product-detail .product-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 3rem);
  align-items: start;
}

/* Gallery column */
.product-gallery {
  align-self: start;
  position: sticky;
  top: calc(var(--header-h, 70px) + 1.5rem);
  display: grid;
  justify-items: center;
}

.product-main-img {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: clamp(8px, 1.25vw, 14px);
  background: var(--canvas-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  display: inline-grid;
  justify-self: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}
.product-main-img img {
  position: static;
  width: auto;
  height: auto;
  max-width: min(100%, 720px);
  max-height: min(84vh, 900px);
  object-fit: contain;
  padding: 0;
  display: block;
  box-sizing: border-box;
  border-radius: calc(var(--radius) - 8px);
}

.product-thumbs {
  display: block;
  margin-top: 0.75rem;
}
#pThumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 0.75rem;
}
.product-thumb-btn {
  appearance: none;
  width: fit-content;
  max-width: 156px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 7px;
  background: var(--canvas-2);
  overflow: visible;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.product-thumb-btn:hover,
.product-thumb-btn:focus-visible,
.product-thumb-btn.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(230, 169, 89, 0.24);
  outline: none;
}
.product-thumb-btn:hover {
  transform: translateY(-1px);
}
.product-thumbs img {
  width: auto;
  height: 132px;
  max-width: 142px;
  object-fit: contain;
  padding: 0;
  background: var(--canvas-2);
  box-sizing: border-box;
  display: block;
  border-radius: 8px;
}

/* Info column */
.product-info .eyebrow {
  /* reuse existing .eyebrow styles from main stylesheet */
}

.product-info h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  color: var(--ink);
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.15;
}

.product-price {
  font-family: var(--serif);
  font-size: 1.8rem;
  color: var(--ink);
  margin: 0.75rem 0;
}

.product-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block: 1.25rem;
}

.product-desc {
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.95rem;
}
.product-desc h2,
.product-desc h3,
.product-desc h4 {
  color: var(--ink);
  margin-top: 1.5em;
  margin-bottom: 0.4em;
  font-family: var(--serif);
}
.product-desc ul,
.product-desc ol {
  padding-left: 1.4rem;
}
.product-desc li {
  margin-bottom: 0.3em;
}
.product-desc img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}
.product-desc a {
  color: var(--accent-text);
  text-decoration: underline;
}

/* Loading / not-found states */
#productLoading,
#productNotFound {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  gap: 1rem;
}

#productLoading[hidden],
#productNotFound[hidden],
#productDetail[hidden],
#cartDrawer[hidden],
#cartOverlay[hidden],
#accountPanel[hidden],
#accountOverlay[hidden] {
  display: none !important;
}

/* ============================================================
   ACCOUNT PANEL
   ============================================================ */

.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.account-overlay.open { opacity: 1; }

.account-panel {
  position: fixed;
  top: 5.5rem;
  right: max(1rem, calc((100vw - 1200px) / 2));
  width: min(360px, calc(100vw - 2rem));
  z-index: 131;
  background: var(--canvas-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  transform: translateY(-8px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.account-panel.open { transform: none; opacity: 1; }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.account-head h3 { margin: 0; font-family: var(--serif); font-size: 1rem; color: var(--ink); }
.account-close { appearance: none; border: 0; background: var(--card); color: var(--muted); width: 30px; height: 30px; border-radius: 999px; cursor: pointer; font-size: 1.2rem; line-height: 1; }
.account-copy,
.account-note { color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.account-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.account-divider::before,
.account-divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.account-email label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 0.4rem; }
.account-email-row { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.account-email-row input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); padding: 0.8rem 0.9rem; font: inherit; }
.account-email-row button { border: 0; border-left: 1px solid var(--border); background: transparent; color: var(--muted); width: 44px; cursor: pointer; }
.account-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.9rem; }
.account-actions a { text-align: center; border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 0.86rem; }
.account-actions a:hover { border-color: var(--primary); }

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

@media (max-width: 860px) {
  .product-detail .product-grid {
    grid-template-columns: 1fr;
  }

  .product-gallery {
    position: static;
  }
}

@media (max-width: 520px) {
  .product-main-img {
    width: 100%;
    padding: 8px;
  }
  .product-main-img img {
    max-width: 100%;
    max-height: none;
  }
  .product-thumbs img {
    height: 104px;
    max-width: 116px;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .cart-overlay,
  .cart-drawer,
  .nav-icon,
  .cart-close,
  .cart-qty button,
  .cart-rm,
  .cart-keep,
  .product-thumbs img,
  .product-breadcrumb a {
    transition: none;
  }
}
