/* ═══════════════════════════════════════════════════════════
   Urban Loomz – app-style layer + shopping animations
   Loaded on every page after style.css (see includes/header.php).
   Works together with assets/js/app.js
   ═══════════════════════════════════════════════════════════ */

/* ── Product images: shimmer while loading, soft fade-in when ready ── */
.product-img { background: linear-gradient(100deg, var(--light) 30%, #fff 50%, var(--light) 70%) var(--light); background-size: 220% 100%; animation: ulShimmer 1.4s linear infinite; }
.product-img.is-loaded { animation: none; background: var(--light); }
@keyframes ulShimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
html.ul-js .pcard-main-img { opacity: 0; transition: opacity .45s ease, transform .45s; }
html.ul-js .pcard-main-img.is-loaded { opacity: 1; }

/* ── Press feedback (touch) ── */
.product-card { -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  .product-card:active { transform: scale(.975) !important; transition: transform .12s; }
}

/* ── Ripple ── */
.ul-ripple-host { position: relative; overflow: hidden; }
.ul-ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .25; transform: scale(0);
  animation: ulRipple .6s ease-out forwards;
}
@keyframes ulRipple { to { transform: scale(2.6); opacity: 0; } }

/* ── Quick add (+) and Add to Cart button states ── */
.quick-add-btn.is-busy, .pd-cart-btn.is-busy { pointer-events: none; }
.quick-add-btn.is-busy i, .quick-add-btn.is-done i { opacity: 1; }
.quick-add-btn.is-done, .pd-cart-btn.is-done { background: #1e8a4c !important; color: #fff !important; animation: ulPop .45s cubic-bezier(.3,1.8,.5,1); }
.quick-add-btn.is-busy, .quick-add-btn.is-done { opacity: 1 !important; transform: none; }
@keyframes ulPop { 0% { transform: scale(.7); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ── Fly-to-cart ghost image ── */
.ul-fly {
  position: fixed; z-index: 100000; pointer-events: none; object-fit: cover;
  border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.28);
}

/* ── Badge bump when the cart / wishlist count changes ── */
.badge.ul-bump, .nav-badge.ul-bump, .cart-count.ul-bump { animation: ulBump .55s cubic-bezier(.3,1.8,.5,1); }
@keyframes ulBump { 0% { transform: scale(1); } 35% { transform: scale(1.7); } 100% { transform: scale(1); } }
.ul-cart-shake { animation: ulShake .5s ease; }
@keyframes ulShake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 50% { transform: rotate(10deg); } 75% { transform: rotate(-5deg); } }

/* ── Wishlist heart pop + burst ── */
.wish-btn.ul-heart-pop, .pd-wish-btn.ul-heart-pop { animation: ulPop .5s cubic-bezier(.3,1.8,.5,1); }
.ul-burst { position: fixed; z-index: 100000; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; background: var(--maroon); }

/* ── Toast (replaces the old plain toast) ── */
#ulToast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100001;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(92vw, 440px);
  background: #1c1c1c; color: #fff; padding: 12px 14px 12px 14px; border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.3); font-size: 14px; line-height: 1.35;
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .45s cubic-bezier(.2,1.3,.4,1), opacity .3s;
}
#ulToast.is-on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#ulToast .ult-ic { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; background: var(--maroon); }
#ulToast.ok .ult-ic { background: #1e8a4c; }
#ulToast.err .ult-ic { background: #c0392b; }
#ulToast .ult-msg { flex: 1; min-width: 0; }
#ulToast .ult-act { color: var(--gold); font-weight: 700; white-space: nowrap; padding: 6px 4px; }
#toast { display: none !important; } /* legacy element */

/* ── Desktop: small cart button inside the sticky menu bar ── */
.catnav-cart {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%) scale(.6); opacity: 0; pointer-events: none;
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.16); color: var(--menu-text, #fff) !important; transition: transform .3s, opacity .3s;
}
.catnav-cart .badge { top: -4px; right: -4px; background: var(--gold); color: #1c1c1c; }
body.ul-scrolled .catnav-cart { transform: translateY(-50%) scale(1); opacity: 1; pointer-events: auto; }
#catNav { position: sticky; }

@keyframes ulInk { from { transform: scaleX(0); } to { transform: none; } }

/* ── Checkout progress bar (cart → checkout → done) ── */
.ul-progress { background: #fff; border-bottom: 1px solid var(--border); }
.ul-progress ol { list-style: none; display: flex; max-width: 620px; margin: 0 auto; padding: 18px 20px 16px; position: relative; }
.ul-progress li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; font-size: 12.5px; font-weight: 600; color: #999; text-align: center; }
.ul-progress li::before { /* connector */
  content: ''; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px; background: var(--border); z-index: 0;
}
.ul-progress li:first-child::before { display: none; }
.ul-progress li::after {
  content: ''; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px; background: var(--maroon);
  transform: scaleX(0); transform-origin: left; z-index: 0; transition: transform .7s cubic-bezier(.3,.8,.3,1);
}
.ul-progress li:first-child::after { display: none; }
.ul-progress li.is-done::after, .ul-progress li.is-current::after { transform: scaleX(1); }
.ul-progress .ulp-dot {
  position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border); color: #aaa; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all .35s .35s;
}
.ul-progress li.is-done .ulp-dot { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.ul-progress li.is-current .ulp-dot { border-color: var(--maroon); color: var(--maroon); box-shadow: 0 0 0 5px rgba(0,0,0,.05); animation: ulPulse 1.8s 1s infinite; }
.ul-progress li.is-done, .ul-progress li.is-current { color: var(--charcoal); }
@keyframes ulPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(141,20,11,.35); } 70% { box-shadow: 0 0 0 9px rgba(141,20,11,0); } }
html.ul-js .ul-progress:not(.is-in) li::after { transform: scaleX(0) !important; }

/* ── Order success check (draws itself) ── */
.ul-check { width: 84px; height: 84px; margin: 0 auto 20px; display: block; }
.ul-check circle { fill: rgba(255,255,255,.18); stroke: rgba(255,255,255,.7); stroke-width: 3; stroke-dasharray: 252; stroke-dashoffset: 252; animation: ulDraw .7s .15s ease-out forwards; }
.ul-check path { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: ulDraw .45s .8s ease-out forwards; }
@keyframes ulDraw { to { stroke-dashoffset: 0; } }
.ul-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100000; }

/* ── Cart / checkout entrance ── */
.cart-line, .co-item { animation: ulRow .45s ease both; }
.cart-line:nth-child(2) { animation-delay: .05s; } .cart-line:nth-child(3) { animation-delay: .1s; }
.cart-line:nth-child(4) { animation-delay: .15s; } .cart-line:nth-child(5) { animation-delay: .2s; }
@keyframes ulRow { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pay-option { transition: border-color .2s, background .2s, transform .15s; }
.pay-option:active { transform: scale(.985); }
.pay-option.selected { animation: ulPop .35s ease; }

/* ── Footer logo ── */
.footer-logo { display: inline-block; margin-bottom: 12px; }
.footer-logo img { max-width: 220px; width: auto; display: block; object-fit: contain; }

/* ── Mobile drawer: links slide in one after another ── */
#mobileNav a { transition: background .2s; }
#mobileNav.ul-open > div:nth-child(2) > a { animation: ulSlideIn .4s both; }
#mobileNav.ul-open > div:nth-child(2) > a:nth-child(2) { animation-delay: .04s; }
#mobileNav.ul-open > div:nth-child(2) > a:nth-child(3) { animation-delay: .08s; }
#mobileNav.ul-open > div:nth-child(2) > a:nth-child(4) { animation-delay: .12s; }
#mobileNav.ul-open > div:nth-child(2) > a:nth-child(5) { animation-delay: .16s; }
#mobileNav.ul-open > div:nth-child(2) > a:nth-child(n+6) { animation-delay: .2s; }
@keyframes ulSlideIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

/* ═══════════ TABLET + PHONE (≤ 768px): app layout ═══════════ */
@media (max-width: 900px) {
  /* checkout page uses an inline 2-column grid – stack it below 900px */
  div[style*="grid-template-columns:1fr 340px"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  /* Bottom tab bar on all phones and small tablets */
  .mobile-bottom-nav { display: flex !important; height: calc(62px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); border-top: none; box-shadow: 0 -6px 24px rgba(0,0,0,.08); border-radius: 18px 18px 0 0; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .mobile-bottom-nav a { gap: 3px; font-size: 10.5px; color: #8a8a8a; }
  .mobile-bottom-nav a i { font-size: 19px; transition: transform .3s cubic-bezier(.3,1.8,.5,1); }
  .mobile-bottom-nav a.active { color: var(--maroon); }
  .mobile-bottom-nav a.active::before {
    content: ''; position: absolute; top: 0; left: 50%; width: 26px; height: 3px; margin-left: -13px;
    border-radius: 0 0 4px 4px; background: var(--maroon); animation: ulInk .35s ease both;
  }
  .mobile-bottom-nav a.ul-tap i { transform: scale(.8) translateY(2px); }
  /* raised round cart button in the middle */
  .mobile-bottom-nav #bnCart { overflow: visible; }
  .mobile-bottom-nav #bnCart i {
    width: 50px; height: 50px; margin-top: -26px; border-radius: 50%;
    background: var(--maroon); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 19px; box-shadow: 0 8px 20px rgba(0,0,0,.22); border: 4px solid #fff;
  }
  .mobile-bottom-nav #bnCart.active::before { display: none; }
  .mobile-bottom-nav #bnCart .nav-badge { top: -22px; right: calc(50% - 26px); background: var(--gold); color: #1c1c1c; border: 2px solid #fff; min-width: 19px; height: 19px; font-size: 10px; border-radius: 10px; }

  /* search is hidden in the header on phones – show the mobile search bar */
  .mobile-search-bar { display: block !important; }

  /* WhatsApp bubble sits above the tab bar */
  .whatsapp-float { bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important; right: 12px; width: 46px; height: 46px; font-size: 23px; z-index: 991 !important; }
  /* …and above the product page's sticky Add to Cart bar */
  body.page-product .whatsapp-float { bottom: calc(146px + env(safe-area-inset-bottom, 0px)) !important; }
  .pd-actions { bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important; box-shadow: 0 -6px 18px rgba(0,0,0,.06); }

  #ulToast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  body.page-product #ulToast { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }

  /* Footer: link columns fold into tap-to-open sections */
  .footer-grid { grid-template-columns: 1fr !important; gap: 0 !important; }
  .footer-grid > div:first-child { padding-bottom: 18px; }
  .footer-grid > div:not(:first-child) { border-top: 1px solid rgba(255,255,255,.14); }
  .footer-grid .footer-heading { margin: 0; padding: 15px 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
  .footer-grid .footer-heading::after { content: '+'; font-size: 18px; font-weight: 400; transition: transform .3s; }
  .footer-grid .ul-fold.is-open .footer-heading::after { transform: rotate(45deg); }
  .footer-grid .ul-fold-body { overflow: hidden; max-height: 0; transition: max-height .4s ease; }
  .footer-grid .ul-fold.is-open .ul-fold-body { max-height: 420px; padding-bottom: 14px; }
  .footer-logo img { max-width: 170px; }

  /* product grids: two columns like a shopping app */
  .products-grid:not(.ul-rail), .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .wish-btn { width: 30px; height: 30px; font-size: 13px; top: 8px; right: 8px; }
  .quick-add-btn { width: 32px; height: 32px; bottom: 8px; right: 8px; opacity: 1 !important; transform: none !important; }

  .page-banner { padding: 22px 0 !important; }
  .page-banner h1 { font-size: 22px !important; }

  .ul-progress ol { padding: 14px 12px 12px; }
  .ul-progress li { font-size: 11px; }
  .ul-progress .ulp-dot { width: 28px; height: 28px; font-size: 12px; }
  .ul-progress li::before, .ul-progress li::after { top: 13px; }
}

/* ═══════════ Reduced motion: keep everything, drop the movement ═══════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .product-img { animation: none; }
}

/* Closed mobile drawer: hide its shadow (it showed as a grey strip on the left edge) */
#mobileNav:not(.ul-open) { box-shadow: none !important; }
