/* =========================================================
   theme-fixes.css — loaded LAST on non-homepage pages,
   after styles.css (legacy) and home.css (new chrome).
   1) Neutralizes higher-specificity legacy nav/footer rules.
   2) Harmonizes page content (product detail, cart, checkout)
      with the homepage design language.
   ========================================================= */

/* ---------- 1. Legacy chrome neutralizers ---------- */

/* styles.css caps body height and turns body into the scroll container,
   which breaks window scrolling (back-to-top, anchor restore) */
html, body{
  height: auto; min-height: 100%;
  overflow-x: clip; overflow-y: visible;
}

/* unify fonts (pages set Cal Sans for EN with !important) */
html[lang] body{
  font-family: "Google Sans", "Noto Sans Khmer", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  font-weight: 400;
}

/* styles.css uses nav.nav .nav-inner with fixed height + space-between */
nav.nav .nav-inner{
  justify-content: flex-start;
  height: auto; min-height: var(--nav-h);
  padding: 8px 12px; gap: 4px 6px;
}
@media (min-width: 900px){
  nav.nav .nav-inner{ padding: 8px 24px; gap: 8px 12px; }
}

/* styles.css legacy checkbox-burger nav force-hides the new toggle/menu */
@media (max-width: 899px){
  nav.nav .nav-toggle{ display: inline-flex !important; }
}
ul#site-nav.nav-links{ display: flex; } /* beats styles.css `#site-nav{display:none}` */
.floating-cart > svg{ display: block !important; } /* styles.css hides inline cart icons */

/* styles.css adds hover underline + hop to nav links; home.css owns the look now */
nav.nav .nav-links{ animation: none; }
nav.nav .nav-links a{ font-weight: 500; font-size: 1rem; }
nav.nav .nav-links a:hover,
nav.nav .nav-links a:focus{ transform: none; color: var(--brand-strong); }
nav.nav .nav-links a:not(.active)::after{ content: none; }
@media (min-width: 900px){
  nav.nav .nav-links a{ padding: 9px 14px; }
}

nav.nav #lang-switcher{
  padding: 0 6px; font-weight: 400;
  border: 1px solid var(--line); background: #fff;
}

/* checkout.css sizes .brand with a clamp(); keep the shared header size */
body .nav .brand{ font-size: 1.05rem; }
@media (min-width: 900px){ body .nav .brand{ font-size: 1.25rem; } }

/* legacy pages sized content for a fixed (out-of-flow) navbar; nav is sticky now */
.pd-breadcrumb{ margin-top: 16px; }
.pd-wrap{ margin-top: 8px; }

/* legacy styles.css decorates CTAs with an icon circle and centers the footer */
.cta.cartified::before, .cta.cartified::after,
.pd-actions .cta::before, .pd-actions .cta::after,
.products-grid .cta::before, .products-grid .cta::after{ content: none !important; }
.site-footer .footer-inner{ text-align: left; }

/* ---------- 2. Product detail pages ---------- */
.pd-back{
  color: var(--muted); display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: .9rem;
}
.pd-back:hover{ color: var(--brand-deep); text-decoration: none; }

.pd-wrap{ gap: 28px; }
@media (min-width: 901px){ .pd-wrap{ gap: 44px; align-items: start; } }

.pd-gallery{
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: none; padding: 10px; background: #fff;
}
.pd-arrow{
  width: 42px; height: 42px;
  background: rgba(255, 255, 255, .94); color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  transition: background var(--dur) var(--ease);
}
.pd-arrow:hover{ background: #fff; }
.pd-thumbs{ gap: 8px; }
.pd-thumbs button{
  border: 2px solid transparent; background: var(--bg-soft); border-radius: 10px;
  cursor: pointer; opacity: .75;
  transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.pd-thumbs button:hover{ opacity: 1; }
.pd-thumbs button[aria-current="true"]{ border-color: var(--brand-strong); opacity: 1; }

/* info column: centered on mobile, left-aligned beside the gallery on desktop */
.pd-info h1{
  font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 700; color: var(--ink);
  margin-bottom: 2px;
}
.pd-sub{ color: var(--muted); font-size: .95rem; margin: 0 0 10px; }
.pd-price{
  color: var(--ink); font-size: 1.55rem; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-bottom: 20px;
}
.pd-actions{ width: 100%; }
.pd-actions .cta{ width: min(100%, 340px); min-height: 48px; font-size: 1rem; }

.pd-trust{
  list-style: none; margin: 22px 0 0; padding: 14px 0 0;
  border-top: 1px solid var(--line);
  display: grid; gap: 10px; justify-content: center;
}
.pd-trust li{
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: .9rem; text-align: left;
}
.pd-trust svg{ width: 20px; height: 20px; flex: none; color: var(--brand-strong); }

.pd-desc{
  color: var(--muted); max-width: 58ch;
  margin: 22px auto 0; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: .95rem; line-height: 1.75;
}
@media (min-width: 901px){
  .pd-info h1, .pd-info .pd-price, .pd-info .pd-sub{ text-align: left; margin-left: 0; margin-right: 0; }
  .pd-actions{ justify-content: flex-start; }
  .pd-trust{ justify-content: start; }
  .pd-desc{ margin-left: 0; margin-right: 0; }
}

.pd-more{ max-width: var(--max-w); margin: 0 auto; padding: 48px 16px 60px; }
.pd-more .product-title-main{
  text-align: center; font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  font-weight: 700; color: var(--ink); margin-bottom: 8px;
}
.pd-more .product-title-main::after{
  content: ""; display: block; margin: 8px auto 24px;
  width: 36px; height: 3px; border-radius: 2px;
  background: var(--grad-chip);
}
.pd-more .products-grid{ justify-content: center; }
@media (min-width: 720px){
  .pd-more .products-grid{ grid-template-columns: repeat(2, minmax(0, 300px)); }
}

/* ---------- 3. Cart page ---------- */
.cart-page{ background: var(--bg-soft); }
.bag-wrap{ margin: calc(var(--nav-h, 64px) + 28px) auto 72px; max-width: var(--max-w); padding: 0 16px; }
.bag-card{
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px rgba(82, 39, 95, .08); background: #fff;
  padding: 22px 18px 24px; margin: 0;
}
@media (min-width: 760px){ .bag-card{ padding: 30px 32px 32px; } }
.bag-card h1, .bag-card h2{
  color: var(--ink); text-align: center;
  font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 700;
  margin: 0 0 6px;
}
.bag-card h1::after, .bag-card h2::after{
  content: ""; display: block; margin: 8px auto 18px;
  width: 36px; height: 3px; border-radius: 2px;
  background: var(--grad-chip);
}
.bag-kicker{
  max-width: 50ch; margin: -8px auto 22px; text-align: center;
  color: var(--muted); font-size: .92rem; line-height: 1.65;
}

.bag-table{ width: 100%; border-collapse: collapse; }
.bag-table thead th{
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--line) !important;
  background: none;
}
.bag-table td{
  padding: 16px 8px; vertical-align: middle;
  border-bottom: 1px solid #f3eaf7 !important;
  font-variant-numeric: tabular-nums;
}
.bag-row .product-info{ display: flex; align-items: center; gap: 14px; }
.bag-row .product-thumb{
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft);
}
.bag-row .product-title{ font-weight: 600; color: var(--ink); }
.bag-row .cell-price{ color: var(--muted); }
.bag-row .cell-subtotal{ font-weight: 700; color: var(--ink); }

.bag-row .qty-control{
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff;
}
.bag-row .qty-btn{
  width: 36px; height: 38px; border: 0; background: none; color: var(--ink);
  font-size: 1.05rem; cursor: pointer; border-radius: 0;
}
.bag-row .qty-btn:hover{ background: var(--bg-soft); color: var(--brand-deep); }
.bag-row .qty-input{
  width: 42px; height: 38px; border: 0; text-align: center;
  font: inherit; color: var(--ink); -moz-appearance: textfield; appearance: textfield;
  background: none;
}
.bag-row .qty-input::-webkit-outer-spin-button,
.bag-row .qty-input::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }
.bag-row .remove-btn{
  border: 0; background: none; color: var(--muted);
  font-size: .85rem; text-decoration: underline; cursor: pointer;
  padding: 8px; border-radius: 6px;
}
.bag-row .remove-btn:hover{ color: #c0264a; }

.bag-summary{
  margin-top: 18px; padding-top: 8px;
  border-top: 1px solid var(--line);
}
.bag-summary .summary-row{
  display: flex; justify-content: flex-end; align-items: baseline; gap: 18px;
  padding: 16px 8px 6px; font-size: 1.05rem; font-weight: 600;
}
.bag-summary .summary-amount{
  font-size: 1.45rem; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bag-summary .actions{
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px;
  margin-top: 14px;
}
.bag-wrap .btn-primary{
  background: var(--grad-btn); color: #fff; border: 0 !important; border-radius: 10px;
  min-height: 48px; padding: 0 28px; font-weight: 600; font-size: 1rem;
  box-shadow: 0 2px 8px rgba(168, 77, 196, .25);
  display: inline-flex; align-items: center; justify-content: center;
}
.bag-wrap .btn-primary:hover{ background: var(--grad-btn-hover); }
.bag-wrap .btn-ghost{
  border: 1px solid var(--line) !important; border-radius: 10px; color: var(--ink);
  background: #fff; min-height: 48px; padding: 0 22px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
}
.bag-wrap .btn-ghost:hover{ border-color: var(--brand) !important; background: var(--bg-soft); }

@media (max-width: 759px){
  .bag-wrap{ margin-top: calc(var(--nav-h, 64px) + 18px); padding: 0 12px; }
  .bag-card{ padding: 20px 14px; }
  .bag-summary .actions{ display: grid; grid-template-columns: 1fr; }
  .bag-wrap .btn-primary, .bag-wrap .btn-ghost{ width: 100%; }
}

/* ---------- 4. Checkout page ---------- */
.checkout-page .container{ margin-top: 20px; max-width: var(--max-w); }
.checkout-page .checkout-title{
  text-align: center; color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 700;
}
.checkout-page .checkout-title::after{
  content: "" !important; display: block; position: static;
  margin: 8px auto 4px; width: 36px; height: 3px; border-radius: 2px;
  background: var(--grad-chip);
}

.checkout-page .grid{ gap: 22px; }
.checkout-page .panel{
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: none; background: #fff; padding: 20px;
}
@media (min-width: 760px){ .checkout-page .panel.form-panel{ padding: 26px 28px; } }

.checkout-page .buyer-title,
.checkout-page .payment-title,
.checkout-page .summary-title{
  font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin: 0 0 14px;
}
.checkout-page .payment-title{ margin-top: 24px; }

.checkout-page .field label{ font-weight: 600; font-size: .92rem; color: var(--ink); }
.checkout-page .req{ color: #c0264a; }
.checkout-page input[type="text"],
.checkout-page input[type="tel"],
.checkout-page textarea{
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  min-height: 46px; padding: 10px 14px; background: #fff;
  transition: border-color var(--dur) var(--ease);
}
.checkout-page textarea{ min-height: 90px; }
.checkout-page input:hover, .checkout-page textarea:hover{ border-color: #dcc3e6; }
.checkout-page input:focus, .checkout-page input:focus-visible,
.checkout-page textarea:focus, .checkout-page textarea:focus-visible{
  outline: 2px solid var(--brand-strong); outline-offset: 0; border-color: var(--brand-strong);
}
.checkout-page .province-chips .chip{
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  padding: 7px 14px; font-size: .88rem; color: var(--ink); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.checkout-page .province-chips .chip:hover{ border-color: var(--brand); background: var(--bg-soft); }

/* bag items shown above checkout */
.checkout-page .bag-list{ gap: 12px; }
.checkout-page .bag-list > *{
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; background: #fff;
}
.checkout-page .item-img{
  width: 68px; height: 68px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft);
}
.checkout-page .item-title{ font-weight: 600; color: var(--ink); }
.checkout-page .item-sub{ color: var(--muted); font-size: .88rem; }
.checkout-page .btn-qty{
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.checkout-page .btn-qty:hover{ background: var(--bg-soft); color: var(--brand-deep); }
.checkout-page .qty-num{ min-width: 26px; text-align: center; font-weight: 600; }
.checkout-page .link-remove{ color: var(--muted); font-size: .85rem; text-decoration: underline; }
.checkout-page .link-remove:hover{ color: #c0264a; }
.checkout-page .price-line{ font-weight: 700; font-variant-numeric: tabular-nums; }

/* summary */
.checkout-page .summary-panel{ border: 0; padding: 0; background: none; }
.checkout-page .summary-panel .summary-box{
  border: 1px solid var(--line) !important; border-radius: var(--radius-lg);
  background: var(--bg-soft); padding: 16px 18px;
}
.checkout-page .summary-box .row{
  padding: 8px 0; color: var(--muted); font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.checkout-page .summary-box hr.dash{
  border: 0; border-top: 1px solid var(--line); margin: 6px 0;
}
.checkout-page .summary-box .row.total{
  color: var(--ink); font-weight: 700; font-size: 1.1rem;
}
.checkout-page .pink,
.checkout-page #total{ color: var(--brand-deep) !important; font-weight: 700; }

/* payment method + purchase */
.checkout-page .panel.payment.aba-card{
  border: 1px solid var(--brand); background: var(--bg-soft);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.checkout-page .pay-row{ display: flex; align-items: center; gap: 14px; }
.checkout-page .logo-img{ width: 52px; height: auto; border-radius: 8px; }
.checkout-page .pay-title{ font-weight: 700; color: var(--ink); }
.checkout-page .check{
  display: flex; align-items: center; gap: 8px;
  margin: 18px 0 4px; color: var(--ink);
}
.checkout-page .check input{ width: 18px; height: 18px; }
.checkout-page .btn-purchase{
  width: 100%; margin-top: 18px;
  background: var(--grad-btn); color: #fff; border: 0; border-radius: 12px;
  min-height: 50px; font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 2px 8px rgba(168, 77, 196, .25);
  cursor: pointer; filter: none;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.checkout-page .btn-purchase:hover:not(:disabled){ background: var(--grad-btn-hover); }
.checkout-page .btn-purchase:disabled{
  opacity: .45; cursor: default; box-shadow: none; filter: none;
  background: var(--grad-btn);
}

/* ---------- 5. Legacy gradient/color overrides that slipped through ---------- */
/* product page CTA (and its qty state) — legacy .cta rules strip the brand fill */
.pd-actions .cta{
  background: var(--grad-btn) !important; color: #fff !important;
  border: 0 !important; box-shadow: 0 2px 8px rgba(168, 77, 196, .25) !important;
}
.pd-actions .cta:hover{ background: var(--grad-btn-hover) !important; }
.pd-actions .cta .qty-btn,
.pd-actions .cta .qty-number{ color: #fff !important; background: none; }
.pd-actions .cta .qty-btn:hover{ background: rgba(255, 255, 255, .15); }

/* cart primary button — cart.css paints its own pink gradient */
.bag-wrap .btn-primary{ background: var(--grad-btn) !important; }
.bag-wrap .btn-primary:hover{ background: var(--grad-btn-hover) !important; }
.bag-wrap .btn-ghost{ background: #fff !important; color: var(--ink) !important; }

/* checkout bag qty buttons — legacy sets invisible glyph color */
.checkout-page .btn-qty{
  color: var(--ink) !important; font-size: 1rem !important;
  line-height: 1 !important; display: inline-flex; align-items: center; justify-content: center;
}
.checkout-page .item-title{ color: var(--ink) !important; }
/* legacy styles.css collapses the CTA into a 40px circle once qty-controls render */
.pd-actions .cta{
  width: min(100%, 340px) !important;
  min-height: 48px !important; height: auto !important;
  border-radius: 10px !important;
}

/* legacy styles.css :has(.qty-controls) pill (0,3,0 !important) — out-specify it */
.pd-shell .product-card .cta:has(.qty-controls){
  width: min(100%, 340px) !important;
  height: auto !important; min-height: 48px !important;
  border-radius: 10px !important;
  padding: 0 !important;
}
.pd-shell .product-card .cta:has(.qty-controls) .qty-controls{
  position: static !important; transform: none !important;
  width: 100% !important; justify-content: space-between !important;
  gap: 0 !important;
}
.pd-shell .product-card .cta:has(.qty-controls) .qty-btn,
.pd-shell .product-card .cta:has(.qty-controls) .qty-number{
  width: 46px !important; height: 46px !important;
  font-size: 1.15rem !important; border-radius: 10px !important;
  background: none !important; color: #fff !important; border: 0 !important;
}
.pd-shell .product-card .cta:has(.qty-controls) .qty-btn:hover{
  background: rgba(255, 255, 255, .15) !important;
}

/* ---------- 6. Checkout two-column layout ---------- */
.checkout-page .co-grid{ display: grid; gap: 18px; }
@media (min-width: 960px){
  .checkout-page .co-grid{ grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
  .checkout-page .co-side{ position: sticky; top: calc(var(--nav-h) + 16px); }
}
.checkout-page .order-panel{ display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.checkout-page .order-panel .summary-title{ margin: 0; }
.checkout-page .order-panel .bag-section{ display: flex; flex-direction: column; gap: 10px; margin: 0; }
.checkout-page .order-panel .summary-box{ margin: 0; }
.checkout-page .order-panel .btn-purchase{ margin-top: 4px; }
.checkout-page .form-panel .payment-title{ margin-top: 26px; }
.checkout-page .form-panel > div[style]{ margin-top: 14px; }

/* checkout.css paints qty glyphs white with !important — restore visibility */
.checkout-page .item-qty .btn-qty.btn-minus,
.checkout-page .item-qty .btn-qty.btn-plus{
  color: var(--ink) !important; background: #fff !important;
  border: 1px solid var(--line) !important;
}

/* checkout.css stacks several container hacks (glass card, clamp side padding,
   fixed-nav offsets) — assert the final container once */
.checkout-page .container{
  max-width: var(--max-w) !important;
  margin: 0 auto !important;
  padding: 24px 16px 56px !important;
  background: none !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
}
@media (min-width: 760px){
  .checkout-page .container{ padding: 28px 24px 64px !important; }
}

/* checkout.css re-fixes the navbar (content then starts underneath it) */
body nav.nav{ position: sticky !important; top: 0 !important; }

/* ---------- 7. Structured product details ---------- */
.pd-details{
  margin-top: 24px; padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: left;
}
.pd-lead{ color: var(--ink); font-size: 1rem; line-height: 1.75; max-width: 58ch; }
.pd-h{
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin: 24px 0 12px;
}
.pd-benefits{ list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.pd-benefits li{
  display: flex; gap: 11px; align-items: flex-start;
  color: var(--ink); font-size: .95rem; line-height: 1.6;
}
.pd-benefits svg{
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  color: var(--brand-strong); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px;
}
.pd-tags{ list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pd-tags li{
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 500;
}
.pd-details, .pd-details .pd-h, .pd-details .pd-lead{ text-align: left !important; }
.pd-details .pd-h{ margin-left: 0 !important; margin-right: 0 !important; }
