/* Merch storefront styles. Relies on the CSS custom properties defined
 * in merch.html's <head> (--cream, --navy, --green-d, --orange, …),
 * matching the rest of the site's espresso/green theme. */

/* ── Cart button in nav ── */
.merch-cart-wrap { position: relative; flex-shrink: 0; }
.merch-cart-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--green-d); color: var(--white);
  border: none; border-radius: 6px; cursor: pointer;
  padding: 0.45rem 0.7rem; font: inherit; font-weight: 700;
  font-size: 0.85rem;
}
.merch-cart-btn svg { width: 18px; height: 18px; fill: currentColor; }
.merch-cart-btn:hover { background: var(--green); }
.merch-cart-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--orange); color: #2d2010;
  border-radius: 9px; font-size: 0.7rem; font-weight: 800;
  display: none; align-items: center; justify-content: center;
}

/* ── Grid ── */
.merch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.5rem;
}
.merch-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform 0.12s, box-shadow 0.12s;
}
.merch-card:hover, .merch-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.12);
  outline: none;
}
.merch-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
}
/* contain (not cover) so the whole product image is visible, never cropped.
   1:1 is a standard ecommerce ratio (Shopify/Amazon default); a neutral
   backdrop + small padding makes mixed aspect ratios look intentional. */
.merch-card-media img { width: 100%; height: 100%; object-fit: contain; padding: 0.5rem; }
.merch-card-noimg { font-size: 2.5rem; opacity: 0.5; }
.merch-badge {
  position: absolute; top: 0.6rem; left: 0.6rem;
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.2rem 0.5rem; border-radius: 4px;
}
.merch-badge-pre { background: var(--orange); color: #2d2010; }
.merch-badge-out { background: #8a8275; color: var(--white); }
.merch-card-body { padding: 0.9rem 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.merch-card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem; font-weight: 700; line-height: 1.25; color: var(--text);
}
.merch-card-summary { font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.merch-card-sub { font-weight: 700; color: var(--green-d); margin-top: 0.2rem; }
.merch-sat-hint { font-weight: 400; font-size: 0.8rem; color: var(--muted); }

/* ── Loading / empty / error ── */
.merch-state { text-align: center; padding: 3rem 0; color: var(--muted); font-style: italic; }
.merch-coming-soon {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: normal; font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  color: var(--green-d); padding: 5rem 1rem;
}
.merch-spinner {
  display: inline-block; width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--green-d);
  border-radius: 50%; animation: merch-spin 0.8s linear infinite; margin-bottom: 1rem;
}
@keyframes merch-spin { to { transform: rotate(360deg); } }

/* ── Modal overlay ── */
.merch-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20,15,8,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 1rem; overflow-y: auto;
}
.merch-modal {
  position: relative;
  background: var(--cream);
  border-radius: 14px;
  width: 100%; max-width: 640px;
  padding: 1.75rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.merch-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.06); cursor: pointer;
  font-size: 1rem; color: var(--text); line-height: 1;
}
.merch-close:hover { background: rgba(0,0,0,0.12); }
.merch-modal-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem; margin-bottom: 1rem; color: var(--text);
}

/* ── Product detail ── */
.merch-modal-detail { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.merch-detail-media { display: block; }
.merch-detail-featured img, .merch-detail-featured .merch-card-noimg {
  width: 100%; aspect-ratio: 1/1; object-fit: contain; border-radius: 10px;
  background: var(--white); padding: 0.5rem;
  display: flex; align-items: center; justify-content: center;
}
.merch-detail-thumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.merch-thumb {
  width: 56px; height: 56px; object-fit: contain; border-radius: 6px;
  background: var(--white); cursor: pointer; opacity: 0.65; border: 2px solid transparent;
}
.merch-thumb:hover { opacity: 1; }
.merch-thumb.active { opacity: 1; border-color: var(--green-d); }
.merch-detail-info { display: flex; flex-direction: column; gap: 0.6rem; }
.merch-detail-title { font-family: 'Playfair Display', Georgia, serif; font-size: 1.4rem; color: var(--text); }
.merch-detail-price { font-size: 1.25rem; font-weight: 800; color: var(--green-d); }
.merch-stock { font-size: 0.85rem; color: var(--muted); }
.merch-detail-desc { white-space: pre-wrap; font-size: 0.92rem; line-height: 1.55; color: var(--text); }
.merch-specs { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.merch-specs th, .merch-specs td { text-align: left; padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--border); }
.merch-specs th { color: var(--muted); font-weight: 600; width: 40%; }
.merch-detail-ship { font-size: 0.85rem; color: var(--muted); }
.merch-detail-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }
.merch-qty-label { font-size: 0.85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.3rem; }
.merch-qty { width: 64px; padding: 0.4rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }

/* ── Buttons ── */
.merch-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  border: none; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 700; padding: 0.6rem 1.1rem;
}
.merch-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.merch-btn-primary { background: var(--orange); color: #fff; }
.merch-btn-primary:hover:not(:disabled) { background: var(--orange-d); }
.merch-btn-ghost { background: transparent; color: var(--green-d); border: 1px solid var(--green-d); }
.merch-btn-ghost:hover:not(:disabled) { background: rgba(94,125,58,0.12); }
.merch-bolt svg { width: 16px; height: 16px; fill: #fff; }
.merch-btn-ghost .merch-bolt svg { fill: var(--green-d); }

/* ── Cart ── */
.merch-cart-lines { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.merch-cart-empty { color: var(--muted); font-style: italic; }
.merch-cart-line { display: flex; align-items: center; gap: 0.75rem; }
.merch-cart-thumb { width: 56px; height: 56px; object-fit: contain; background: var(--white); border-radius: 8px; flex-shrink: 0; }
.merch-cart-line-info { flex: 1; min-width: 0; }
.merch-cart-line-title { font-weight: 700; font-size: 0.95rem; }
.merch-cart-line-price { font-size: 0.82rem; color: var(--muted); }
.merch-line-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.merch-cart-total, .merch-sum-total {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); padding-top: 0.75rem; font-size: 1.05rem;
}
.merch-cart-checkout { width: 100%; margin-top: 1rem; }

/* ── Checkout ── */
.merch-checkout-as { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
.merch-checkout-summary { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.merch-sum-line { display: flex; justify-content: space-between; font-size: 0.9rem; }
.merch-sum-total { font-weight: 800; }
.merch-checkout-fields { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.merch-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.merch-field-row { display: flex; gap: 0.6rem; }
.merch-field-row .merch-field { flex: 1; }
.merch-input { padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 7px; font: inherit; color: var(--text); background: var(--white); }
.merch-checkout-status { font-size: 0.9rem; margin: 0.5rem 0; min-height: 1.2em; }
.merch-status-working { color: var(--green-d); }
.merch-status-error { color: #b4451f; }
.merch-fineprint { font-size: 0.75rem; color: var(--muted); margin-top: 0.6rem; }
.merch-warn { color: #b4451f; font-size: 0.85rem; margin-top: 0.5rem; }
.merch-modal-checkout .merch-btn-primary { width: 100%; }

/* ── Success ── */
.merch-modal-success { text-align: center; max-width: 460px; }
.merch-success-check {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  border-radius: 50%; background: var(--green-d); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.merch-order-id { font-size: 0.8rem; color: var(--muted); margin: 1rem 0; }
.merch-diag { text-align: left; margin: 0.75rem 0; font-size: 0.8rem; }
.merch-diag > summary { cursor: pointer; color: var(--green-d); font-weight: 600; }
.merch-diag-body { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.merch-diag-row { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.6rem; background: var(--white); }
.merch-diag-label { font-weight: 700; color: var(--text); }
.merch-diag-meta { color: var(--muted); }
.merch-diag-relays { color: var(--green-d); word-break: break-all; }
.merch-diag-fail { color: #b4451f; word-break: break-all; }
.merch-order-id code { background: rgba(0,0,0,0.06); padding: 0.15rem 0.4rem; border-radius: 4px; word-break: break-all; }
.merch-modal-success .merch-btn { margin-top: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .merch-modal-detail { grid-template-columns: 1fr; }
  .merch-modal { padding: 1.25rem; }
}
