/* =======================================================
   Cart: remove product description
   ======================================================= */
.cart-desc {
  display: none !important;
}

:root{
  --background-color: #f6f6f6; /* TEMP just to test */
}


/* 
 * ========================================
 * Global & Base Vars
 * ========================================
 */
:root{
  --background-color: #ffffff;
  --ink:#111827;

  --radius: 12px;
  --box-border:#bbb;
  --box-border-hover:#888;
  --box-shadow:0 2px 6px rgba(0,0,0,.10);
  --box-shadow-hover:0 6px 14px rgba(0,0,0,.15);

  --ring: 2px;
  --ring-color: rgba(37, 99, 235, 0.13);
  --ring-offset: 2px;

  --maxw:1200px;

  --thumb-size:64px;

  /* Product description box (default clamp) */
  --comment-lines: 4;         /* was 3 */
  --comment-fs: 12px;
  --comment-lh: 1.25;
  --comment-h: calc(var(--comment-lines) * var(--comment-fs) * var(--comment-lh));
}

*,
*::before,
*::after{ box-sizing: border-box; }
html { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce){
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

.container { padding-top: 20px; padding-bottom: 40px; flex: 1; }

h1, h2, h3 {
  color: #111;
  margin-bottom: 18px;
  font-family: "Playfair Display", serif;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: var(--ring) solid var(--ring-color);
  outline-offset: var(--ring-offset);
  border-radius: calc(var(--radius) / 2);
}

/* 
 * ========================================
 * Header & Navigation
 * ========================================
 */
/* Show header (logo) ONLY on Welcome page */
body.page-welcome .site-header { display:block; }
body:not(.page-welcome) .site-header { display:none !important; }

.site-header {
  background-color: var(--background-color);
  color: #000;
  text-align: center;
  padding: 16px 10px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: bold;
  font-family: "Playfair Display", serif;
}
.header-logo { max-width: 100%; height: auto; max-height: 120px; object-fit: contain; }

.site-nav {
  text-align: center;
  padding: 10px 0;
  background-color: var(--background-color);
  position: sticky;
  top: 0; z-index: 50;
}
@supports (backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px)) {
  .site-nav { backdrop-filter: saturate(140%) blur(2px); -webkit-backdrop-filter: saturate(140%) blur(2px); will-change: backdrop-filter; }
}

.nav-button {
  background-color: #f6f6f6; color: #000000;
  padding: 10px 20px; margin: 8px 10px;
  border: 1px solid #cccccc; border-radius: 10px;
  text-decoration: none; font-weight: 700; font-size: 1.05rem;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
  transition: transform .15s, box-shadow .15s, background-color .15s;
  position: relative; touch-action: manipulation;
}
.nav-button:hover { transform: translateY(-2px); box-shadow: 4px 4px 8px rgba(0,0,0,0.28); background-color: #efefef; }
.nav-button:active{ transform: translateY(0); box-shadow: 2px 2px 5px rgba(0,0,0,0.22); }
.nav-button.active-nav-button { background-color: #e0e0e0; box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); }

.cart-counter {
  position: absolute; top: -6px; right: -10px;
  background-color: #f6f6f6; color: #000; font-size: 0.9rem; font-weight: bold;
  border-radius: 50%; min-width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  padding: 2px; line-height: 1; border: 1px solid #cccccc;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
  opacity: 0; transition: opacity .15s, transform .15s; /* smoother show/hide */
  will-change: transform;
}

/* 
 * ========================================
 * Enhanced Cart Counter Animations
 * ========================================
 */
@keyframes cartBounce { 
  0%{transform:scale(1) rotate(0deg)} 
  15%{transform:scale(1.4) rotate(5deg)} 
  35%{transform:scale(.85) rotate(-3deg)} 
  60%{transform:scale(1.15) rotate(2deg)} 
  85%{transform:scale(.95) rotate(-1deg)} 
  100%{transform:scale(1) rotate(0deg)} 
}

@keyframes cartPulse { 
  0%{transform:scale(1); box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(37,99,235,0.4);} 
  25%{transform:scale(1.05); box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(37,99,235,0.2);} 
  50%{transform:scale(1.08); box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 12px rgba(37,99,235,0.1);} 
  75%{transform:scale(1.05); box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(37,99,235,0.05);} 
  100%{transform:scale(1); box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(37,99,235,0);} 
}

.cart-counter.bounce { animation: cartBounce .7s cubic-bezier(.68,-0.55,.265,1.55) 1; transform-origin: center; }
.cart-counter.pulse { animation: cartPulse .9s ease-out 1; transform-origin: center; }

/* 
 * ========================================
 * Buttons & Forms
 * ========================================
 */
.button {
  display: inline-block; padding: 10px 16px; font-size: 1rem;
  cursor: pointer; text-decoration: none; border-radius: 10px; text-align: center;
  transition: transform .15s, box-shadow .15s, background-color .15s, color .15s;
  background-color: #f6f6f6; border: 1px solid #ccc; font-weight: 700; color: #000;
  box-shadow: var(--box-shadow); user-select: none; touch-action: manipulation;
}
.button:hover { transform: translateY(-2px); box-shadow: var(--box-shadow-hover); background-color: #efefef; }
.button:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.button:disabled{ opacity:.55; cursor:not-allowed; transform:none !important; box-shadow:none !important; }

/* Optional: emphasize primary/danger variants */
.button-primary { background:#2563eb; color:#fff; border-color:#1e40af; }
.button-primary:hover { background:#1d4ed8; }
.button-danger  { background:#ef4444; color:#fff; border-color:#b91c1c; }
.button-danger:hover { background:#dc2626; }

form label { display:block; margin-top: 12px; font-weight: 700; }
form input[type="text"], form input[type="email"], form textarea {
  width: 100%; padding: 10px; margin-top: 6px; border: 1px solid #ccc; border-radius: 8px; font: inherit;
}
form input[type="text"]:focus-visible, form input[type="email"]:focus-visible, form textarea:focus-visible{
  border-color: #88b7ff; outline-color: rgba(0, 123, 255, 0.35);
}

/* 
 * ========================================
 * Products page (Search-style grid + controls)
 * ========================================
 */
.controls{
  display:grid; grid-template-columns:1fr auto auto;
  gap:8px; align-items:center;
  padding:6px 0 12px; max-width: var(--maxw); margin-inline: auto;
  position: static !important;
}
.search-wrap{ position:relative; min-width:0; }
.input{
  width:100%; height:40px; padding:8px 30px 8px 12px; font-size:14px;
  border-radius:10px; border:2px solid var(--box-border);
  background:#fff; color:#111; outline:none;
  box-shadow:0 1px 4px rgba(0,0,0,.08) inset, 0 1px 2px rgba(0,0,0,.06);
}
.input:focus{ border-color:#2563eb; box-shadow:0 0 0 4px var(--ring-color), 0 2px 6px rgba(0,0,0,.12); }
.clear-btn{
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:26px; height:26px; border-radius:999px;
  border:1px solid #d1d5db; background:#fff; color:#444;
  font-size:14px; line-height:24px; cursor:pointer;
  display:none; align-items:center; justify-content:center;
}
.clear-btn.show{ display:flex; }

.chip{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  height:34px; padding:0 16px; font-size:13px;
  border:1px solid #d1d5db; border-radius:9999px;
  background:#f9fafb; color:#374151;
  cursor:pointer; user-select:none; white-space:nowrap;
  box-shadow:0 1px 2px rgba(0,0,0,.05);
  transition: all .15s ease;
}
.chip:hover{ border-color:#9ca3af; background:#f3f4f6; }
.chip[aria-pressed="true"]{ background:#e0e7ff; color:#1e3a8a; border-color:#6366f1; box-shadow:0 2px 6px rgba(0,0,0,.12); }
.chip::after{ content:""; width:1em; height:1em; }

/* mobile: keep them on one line with the input */
@media (max-width: 576px){
  .controls{ grid-template-columns: minmax(140px,1fr) auto auto; }
}

/* Grid & product cards */
.grid{
  display:grid; gap:12px; grid-template-columns:repeat(auto-fill, minmax(150px,1fr));
  max-width: var(--maxw); margin: 0 auto;
}
.card{
  position:relative;
  background:#fafafa;
  border:2px solid var(--box-border);
  border-radius: var(--radius);
  padding:10px;                       /* <- removed bottom reservation */
  text-align:center;
  box-shadow: var(--box-shadow);
  transition: box-shadow .15s, border-color .15s, transform .15s;
  display:flex; flex-direction:column; justify-content:flex-start; align-items:center;
  width:100%;
}
.card:hover{ border-color: var(--box-border-hover); box-shadow: var(--box-shadow-hover); }
.card h3{ margin:0 0 4px; font-size:14px; line-height:1.2; font-weight:700; word-break:break-word; }
.price{ font-size:13px; color:#0f172a; margin-bottom:6px; }

.actions{ display:flex; align-items:center; justify-content:center; gap:6px; width:100%; }

/* Buttons inside product cards */
.btn{
  height:25px; min-width:68px; padding:0 10px; font-size:12px; line-height:1;
  border-radius:10px; border:1px solid #d1d5dc; background:#fff; color:#111;
  display:inline-flex; align-items:center; justify-content:center;
  box-shadow:0 1px 2px rgba(0,0,0,.06);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.btn:hover{ background:#f8fafc; box-shadow:0 2px 6px rgba(0,0,0,.12); transform:translateY(-1px); }
.btn:active{ transform:translateY(0); box-shadow:0 1px 2px rgba(0,0,0,.08); }

/* Image thumbnail */
.thumb{
  width: var(--thumb-size); height: var(--thumb-size);
  border-radius:10px; background:#fff; box-shadow:inset 0 0 0 1px #eef1f5;
}
.thumb img{ width:100%; height:100%; object-fit:contain; border-radius:8px; display:block; }

/* Product description under price in normal flow */
.comment-box{
  position: static;                 /* no absolute positioning */
  width: 100%;
  margin-top: 6px;
  font-size: var(--comment-fs);
  line-height: var(--comment-lh);
  color:#000;
  text-align: left;
  /* Soft clamp (remove the next two lines if you want full expansion always) */
  display:-webkit-box; -webkit-line-clamp: var(--comment-lines); -webkit-box-orient: vertical; overflow:hidden;
}
.comment-line{ margin-top:4px; }

/* Stronger product flash on add */
@keyframes flashAddBoost{
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.00), inset 0 0 0 0 rgba(37,99,235,0);
         border-color: var(--box-border); background-color: #fafafa; transform: translateY(0) scale(1); }
  18%  { box-shadow: 0 0 0 10px rgba(37,99,235,0.34), 0 10px 24px rgba(0,0,0,.22), inset 0 0 0 3px rgba(37,99,235,.35);
         border-color:#1d4ed8; background-color:#e8efff; transform: translateY(-3px) scale(1.06); }
  55%  { box-shadow: 0 0 0 4px rgba(37,99,235,0.22), 0 6px 16px rgba(0,0,0,.18), inset 0 0 0 2px rgba(37,99,235,.22);
         transform: translateY(-2px) scale(1.02); }
  100% { box-shadow: var(--box-shadow); border-color: var(--box-border); background-color:#fafafa; transform: translateY(0) scale(1); }
}
.card.flash-boost{ animation: flashAddBoost 1.15s ease-out 1; }

/* Flying sprite */
.fly-sprite{
  position: fixed; left: 0; top: 0;
  background: #fff; background-size: contain; background-position: center; background-repeat: no-repeat;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18), inset 0 0 0 1px #eef1f5;
  opacity: .95; z-index: 9999; will-change: transform, opacity; pointer-events: none;
}

/* Matched-query highlight */
.hl{ font-weight:700; text-decoration: underline; text-underline-offset: 2px; }

/* Product Detail */
.product-detail-container{ display:flex; flex-wrap:wrap; align-items:flex-start; gap:16px; }
.product-detail-container img{ width:100%; height:auto; border-radius:8px; }

/* 
 * ========================================
 * Cart
 * ========================================
 */
.cart-title{ scroll-margin-top: 70px; }

/* Title row with Clear Cart button */
.cart-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
  flex-wrap:wrap;
}
.cart-title-row .clear-cart-btn{
  padding:8px 12px;
  white-space:nowrap;
}

.cart-items-container{ display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }

/* Cart item row (match page background, keep border, no shadow) */
.cart-item{
  display: grid;
  grid-template-columns: var(--thumb-size) 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--background-color);
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 10px;
  box-shadow: none;                        /* <-- changed from var(--box-shadow) */
  transition: border-color .15s ease, background-color .3s ease;
  min-height: var(--cart-row-h);
  transform: translateZ(0);
}
.cart-item:hover{
  border-color: var(--box-border-hover);
  box-shadow: none;
  transform: translateY(0); /* no lift */
}

/* Pulse highlight uses page bg at start/end */
@keyframes pulseRow {
  0%   { background-color: var(--background-color); }
  30%  { background-color: #f1f5ff; }
  100% { background-color: var(--background-color); }
}
.cart-item.pulse{ animation: pulseRow 1.1s ease-out 1; }

/* Ensure cart thumbnails never blow up */
.cart-items-container .cart-media{ width: var(--thumb-size); }
.cart-items-container .cart-media .thumb{
  width: var(--thumb-size);
  height: var(--thumb-size);
  background: var(--background-color);     /* blend with row/page */
  box-shadow: inset 0 0 0 1px #eef1f5;
}
.cart-items-container img{
  max-width: var(--thumb-size);
  max-height: var(--thumb-size);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.cart-media .thumb{ width: var(--thumb-size); height: var(--thumb-size); }
.cart-media .thumb img{ width:100%; height:100%; object-fit:contain; border-radius:8px; display:block; }
.thumb.placeholder{ display:flex; align-items:center; justify-content:center; border:1px dashed #ddd; background:#f9fafb; color:#555; font-size:11px; padding:2px; border-radius:8px; }

.cart-info h3{ margin:0 0 2px 0; font-size: 1rem; font-family: 'Inter', sans-serif; line-height: 1.2; }
.cart-meta{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size: 0.94rem; color:#444; }
.cart-meta .sep{ color:#bbb; }

.cart-ctrls{ display:flex; align-items:center; gap:8px; justify-content: flex-end; }
.cart-ctrls .button{ padding: 8px 12px; }

.qty-controls-group{ display:flex; align-items:center; width:auto; max-width:none; margin:0; }
.qty-input-field{ text-align:center; width:56px !important; height:34px; font-size:.95rem; padding:0; border: 1px solid #ced4da; border-radius: 6px; }
.qty-controls-group .qty-minus, .qty-controls-group .qty-plus{
  width:34px; height:34px; font-size:1.1rem; line-height:1; display:flex; align-items:center; justify-content:center;
  font-weight:700; color:#495057; background:#fff; border:1px solid #ced4da;
}
.qty-controls-group .qty-minus{ border-right:none; border-radius: 6px 0 0 6px; }
.qty-controls-group .qty-plus{  border-left:none;  border-radius: 0 6px 6px 0; }

.cart-item-price{ font-weight:600; color:#222; }
.cart-item-total .item-total-price{ font-weight:700; color:#111; }

/* Cart summary matches page bg but keeps a border */
.cart-summary{
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 16px;
  background: var(--background-color);
  border: 1px solid #ddd;
  border-radius:12px;
  box-shadow: none;
  gap:12px;
}
.cart-summary h3{ margin:0; font-size:1.05rem; }
.checkout-button{ font-size:1.05rem; padding:10px 16px; font-weight:700; }

/* Smooth collapse on remove */
.cart-item.fade-out{
  opacity: 0; max-height: 0; margin: 0 !important;
  padding-top: 0 !important; padding-bottom: 0 !important;
  border: none; overflow: hidden;
  transition: opacity .35s ease-out, max-height .35s ease-out, margin .35s ease-out, padding .35s ease-out;
}

/* Responsive tweaks */
@media (max-width: 680px){
  .cart-item{
    grid-template-columns: var(--thumb-size) 1fr;
    grid-template-areas:"media info" "ctrls ctrls";
    align-items: start;
    min-height: auto;
  }
  .cart-media{ grid-area: media; }
  .cart-info{ grid-area: info; min-height: 0; }
  .cart-ctrls{ grid-area: ctrls; justify-content: flex-start; }
  .cart-ctrls .button{ padding:8px 10px; }
}
@media (max-width: 576px){
  .checkout-button{ width:100%; }
  .cart-summary{ flex-direction: column; align-items: stretch; gap: 10px; }
}

/* Status Messages & Modal */
.status-message {
  display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background-color: #333; color: #fff; padding: 10px 20px; border-radius: 6px;
  z-index: 2000; font-size: 1rem; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
#custom-confirm-modal .modal-content { border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); background-color: #f6f6f6; border: 1px solid #ccc; }
#custom-confirm-modal .modal-header { background: transparent; border-bottom: 1px solid #ccc; color:#000; }
#custom-confirm-modal .modal-title { font-weight: 800; }
#custom-confirm-modal .modal-body { padding: 16px 20px; color:#111; }
#custom-confirm-modal .modal-footer { border-top: 1px solid #dee2e6; }

/* Footer */
footer { text-align: center; padding: 20px; margin-top: auto; background-color: var(--background-color); color: #333; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }
footer p { margin: 0; }

/* Back to top button */
.scroll-to-top-btn {
  position: fixed; left: 20px; bottom: 20px; width: 40px; height: 40px;
  background-color: #f6f6f6; border: 1px solid #cccccc; border-radius: 50%;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.2); display: none; justify-content: center; align-items: center;
  cursor: pointer; text-decoration: none; transition: background-color .2s, transform .15s, opacity .2s; z-index: 99;
}
.scroll-to-top-btn:hover { background-color: #e0e0e0; transform: translateY(-2px); box-shadow: 4px 4px 8px rgba(0,0,0,0.3); }
.scroll-to-top-btn svg { width: 20px; height: 20px; fill: #000; display:block; }

/* 
 * ========================================
 * Performance Optimizations
 * ========================================
 */
@media (prefers-reduced-motion: reduce) {
  .cart-counter.bounce,
  .cart-counter.pulse,
  .card.flash-boost,
  .fly-sprite {
    animation: none !important;
  }
  .cart-counter { transition: opacity .15s, transform .15s; }
}

/* --- Cart row size lock + jitter fixes --- */
:root{ --cart-row-h: 92px; }

.cart-info{
  min-height: calc(var(--cart-row-h) - 20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Titles shouldn't wrap to two lines or push height */
.cart-info h3{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Clamp (kept for structure, but hidden by .cart-desc display:none) */
.cart-desc{
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(2 * 1.25em);
}

/* No wrap for numeric bits; tabular for stability */
.cart-meta{ white-space: nowrap; align-items: center; font-variant-numeric: tabular-nums; }
.cart-ctrls{ flex-wrap: nowrap; }
.qty-input-field,
.cart-item-price,
.cart-item-total,
#cart-total{ font-variant-numeric: tabular-nums; }

/* Keep image box size stable */
.cart-items-container .cart-media,
.cart-items-container .cart-media .thumb{
  width: var(--thumb-size);
  height: var(--thumb-size);
  flex: 0 0 var(--thumb-size);
}

/* === Sort arrows with width lock (Name/Price chips) === */
.chip[data-key="name"]::after,
.chip[data-key="price"]::after{
  content: "";
  display: inline-block;
  width: 0.9em;          /* reserve arrow width so button width doesn't change */
  margin-left: 6px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
}

.chip[aria-pressed="true"][data-key="name"]::after,
.chip[aria-pressed="true"][data-key="price"]::after{
  opacity: .85;
  visibility: visible;
}

/* Direction symbols */
.chip[aria-pressed="true"][data-dir="asc"][data-key="name"]::after,
.chip[aria-pressed="true"][data-dir="asc"][data-key="price"]::after{ content: "?"; }

.chip[aria-pressed="true"][data-dir="desc"][data-key="name"]::after,
.chip[aria-pressed="true"][data-dir="desc"][data-key="price"]::after{ content: "?"; }
