/* =====================================================================================
   DARAKUM · engagement layer: popups, permission windows, chat, sale prices, motion
   ===================================================================================== */

/* ---------- popups (toasts + live notifications) */
#toasts { position: fixed; z-index: 450; top: calc(14px + env(safe-area-inset-top)); inset-inline: 0; display: grid; justify-items: center; gap: 10px; pointer-events: none; padding: 0 12px; }
.pop { pointer-events: auto; position: relative; overflow: hidden; width: min(440px, 100%); display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 16px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: 0 18px 44px -14px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.06); color: var(--ink); animation: pop-in .42s cubic-bezier(.2,.9,.25,1.15) both; }
.pop.out { animation: pop-out .26s ease both; }
.pop.clickable { cursor: pointer; }
.pop.clickable:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.pop .pi { width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0; display: grid; place-items: center; font-size: 1.3rem; background: var(--ok-bg); color: var(--ok); }
.pop-err .pi { background: var(--err-bg); color: var(--err); } .pop-warn .pi { background: var(--warn-bg); color: var(--warn); }
.pop-info .pi { background: var(--green-100); color: var(--green-ink); } .pop-notif .pi { background: var(--terra-100); color: var(--terra-ink); }
.pop-notif .pi .ico { animation: ring 1.2s ease .2s 2; transform-origin: 50% 10%; }
.pop .pb { flex: 1; min-width: 0; padding-top: 1px; } .pop .pb b { display: block; font-size: .95rem; font-weight: 600; line-height: 1.4; }
.pop .pb p { margin: 2px 0 0; font-size: .88rem; color: var(--muted); line-height: 1.55; } .pop .pb b + p { margin-top: 2px; } .pop .pb p:only-child { color: var(--ink); font-weight: 500; margin-top: 8px; }
.pop .px { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.pop .px:hover { background: var(--surface-2); color: var(--ink); }
.pop .pbar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--green-500), var(--terra)); transform-origin: right; animation: pbar var(--dur, 5s) linear forwards; }
[dir="ltr"] .pop .pbar { transform-origin: left; }
.pop-err .pbar { background: var(--err); } .pop.paused .pbar { animation-play-state: paused; }
@keyframes pbar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(-12px) scale(.97); } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }
.badge.bump { animation: bump .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes bump { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- permission windows (cookies / notifications / location) */
.perm { position: fixed; inset: 0; z-index: 400; display: grid; place-items: end center; padding: 12px; animation: fade .2s; }
.perm.out { animation: fade .2s reverse both; }
.perm-bg { position: absolute; inset: 0; background: rgba(10,18,14,.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.perm-card { position: relative; width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 26px 22px 20px; text-align: center; box-shadow: var(--shadow-lg); animation: up .35s cubic-bezier(.2,.9,.25,1.1) both; margin-bottom: env(safe-area-inset-bottom); }
@media (min-width: 640px) { .perm { place-items: center; } }
.perm-ic { width: 68px; height: 68px; margin: -60px auto 12px; border-radius: 22px; display: grid; place-items: center; font-size: 2rem; color: #fff; box-shadow: 0 14px 28px -10px rgba(0,0,0,.4); border: 4px solid var(--surface); }
.perm-ic.green { background: var(--grad-green); } .perm-ic.terra { background: var(--grad-cta); } .perm-ic.gold { background: linear-gradient(135deg, #CFAE6B, #A9843F); }
.perm-ic .ico { animation: ring 1.4s ease .4s 1; }
.perm-card h3 { font-size: 1.25rem; margin: 0 0 6px; } .perm-card > p { color: var(--muted); margin: 0 auto 14px; max-width: 36ch; font-size: .93rem; }
.perm-card ul { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; text-align: start; }
.perm-card li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: .9rem; font-weight: 500; }
.perm-card li .ico { color: var(--terra-ink); font-size: 1.25em; }
.perm-acts { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.perm-link { display: inline-block; margin-top: 12px; font-size: .82rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- sale prices */
.price .was, .summary s, s.was { color: var(--muted); font-weight: 400; font-size: .82em; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--err) 70%, transparent); margin-inline-end: 6px; }
.price { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 2px; }
.price .now.is-sale { color: var(--terra-ink); font-weight: 700; }
.price.big { font-size: 1.2rem; }
.sale-pill { background: linear-gradient(135deg, #C46D37, #A9572A) !important; color: #fff !important; box-shadow: 0 6px 14px -6px rgba(169,87,42,.7); }
.summary .saved, .saved { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 10px 12px !important; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.summary .before s { color: var(--muted); }

/* ---------- chat widget */
.chatw { position: fixed; z-index: 90; inset-inline-end: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); }
.chatw.hide { display: none; }
.chatw.above-bnav { bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .chatw.above-bnav { bottom: calc(18px + env(safe-area-inset-bottom)); } }
.chat-fab { width: 60px; height: 60px; border-radius: 20px; border: 0; cursor: pointer; display: grid; place-items: center; font-size: 1.7rem; color: #fff; background: var(--grad-green); box-shadow: 0 16px 32px -12px rgba(20,42,31,.75), inset 0 1px 0 rgba(255,255,255,.12); position: relative; transition: transform .2s cubic-bezier(.3,1.5,.5,1), border-radius .2s; }
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab > span { grid-area: 1 / 1; display: grid; transition: transform .25s, opacity .2s; }
.chat-fab .ic-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.chatw.open .chat-fab { border-radius: 50%; } .chatw.open .chat-fab .ic-open { opacity: 0; transform: rotate(90deg) scale(.6); } .chatw.open .chat-fab .ic-close { opacity: 1; transform: none; }
.chat-dot { position: absolute; top: -3px; inset-inline-end: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--terra); border: 3px solid var(--cream); }
.chat-dot.hide { display: none; }
.chat-fab::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(196,109,55,.5); animation: fabpulse 2.8s ease-out 1.5s 3; }
@keyframes fabpulse { to { box-shadow: 0 0 0 18px rgba(196,109,55,0); } }
.chat-panel { position: absolute; bottom: 74px; inset-inline-end: 0; width: min(390px, calc(100vw - 24px)); height: min(620px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: 0 30px 70px -20px rgba(0,0,0,.45); transform-origin: bottom right; animation: chatin .3s cubic-bezier(.2,.9,.25,1.1) both; }
[dir="rtl"] .chat-panel { transform-origin: bottom left; }
.chat-panel[hidden] { display: none; }
@keyframes chatin { from { opacity: 0; transform: translateY(12px) scale(.94); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) {
  .chat-panel { position: fixed; inset-inline: 8px; width: auto; bottom: calc(92px + env(safe-area-inset-bottom)); height: min(620px, calc(100dvh - 160px - env(safe-area-inset-bottom))); }
  .chatw.above-bnav .chat-panel { bottom: calc(158px + env(safe-area-inset-bottom)); height: min(620px, calc(100dvh - 226px - env(safe-area-inset-bottom))); }
}
.chat-h { display: flex; align-items: center; gap: 10px; padding: 14px 14px; background: var(--grad-green); color: #fff; }
.chat-h b { display: block; font-size: 1rem; } .chat-h small { color: rgba(255,255,255,.75); font-size: .78rem; display: flex; align-items: center; gap: 6px; }
.chat-h > div { flex: 1; min-width: 0; }
.chat-h .icon-btn { color: #fff; min-width: 36px; height: 36px; } .chat-h .icon-btn:hover { background: rgba(255,255,255,.12); }
.chat-av { width: 42px; height: 42px; border-radius: 14px; background: #F8F4EC; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.chat-av img { width: 36px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #7fd39b; box-shadow: 0 0 0 3px rgba(127,211,155,.25); display: inline-block; }
.chat-b { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: radial-gradient(400px 200px at 100% 0, color-mix(in srgb, var(--gold) 8%, transparent), transparent), var(--surface-2); }
.chat-intro { text-align: center; padding: 6px 6px 2px; }
.chat-intro .hello { font-size: 2.2rem; color: var(--terra-ink); display: inline-block; animation: wave 1.8s ease .4s 2; transform-origin: 70% 70%; }
@keyframes wave { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(16deg); } 30% { transform: rotate(-8deg); } 45% { transform: rotate(14deg); } 60% { transform: rotate(-4deg); } 75% { transform: rotate(10deg); } }
.chat-intro h4 { margin: 4px 0 4px; font-size: 1.05rem; } .chat-intro p { margin: 0 0 6px; font-size: .86rem; color: var(--muted); }
.chat-form { gap: 10px; } .chat-form .field > span { font-size: .8rem; } .chat-form .input { min-height: 42px; }
.cm { display: flex; flex-direction: column; max-width: 86%; align-self: flex-start; animation: up .25s ease both; }
.cm.me { align-self: flex-end; align-items: flex-end; }
.cm .bub { padding: 10px 13px; border-radius: 16px; border-end-start-radius: 5px; background: var(--surface); border: 1px solid var(--line); font-size: .92rem; line-height: 1.65; box-shadow: var(--shadow-xs); overflow-wrap: anywhere; }
.cm.me .bub { background: var(--grad-green); color: #fff; border: 0; border-end-start-radius: 16px; border-end-end-radius: 5px; }
.cm.me .bub a { color: #F3E5C8; }
.cm.agent .bub { background: var(--terra-100); border-color: var(--terra-line); }
.cm .who { font-size: .74rem; color: var(--terra-ink); font-weight: 600; margin: 0 4px 3px; display: flex; align-items: center; gap: 4px; }
.cm time { font-size: .68rem; color: var(--muted); margin: 3px 6px 0; }
.cm.sys { align-self: center; max-width: 94%; text-align: center; font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px !important; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: tdot 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.chat-f { padding: 10px 12px calc(10px + env(safe-area-inset-bottom) * 0); border-top: 1px solid var(--line); background: var(--surface); display: grid; gap: 6px; justify-items: center; }
.chat-f:empty { display: none; }
.chat-send { display: flex; gap: 8px; width: 100%; align-items: flex-end; }
.chat-send textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); padding: 10px 12px; color: var(--ink); font: inherit; outline: none; }
.chat-send textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent); }
.chat-send .btn { min-height: 44px; width: 46px; padding: 0; border-radius: 14px; }
@media print { .chatw, #toasts, .perm { display: none !important; } }

/* ---------- add-to-cart flight */
.fly { position: fixed; z-index: 460; border-radius: 50%; background: var(--terra) center/cover no-repeat; box-shadow: 0 10px 24px -6px rgba(0,0,0,.45); border: 3px solid #fff; pointer-events: none; }
.cart-pop { animation: cartpop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes cartpop { 0% { transform: scale(1); } 40% { transform: scale(1.3) rotate(-8deg); } 100% { transform: scale(1); } }

/* ---------- customer motion (body.fx is only set on shopper pages, never on dashboards) */
body.fx main.fx-enter > * { animation: fxIn .55s cubic-bezier(.2,.8,.2,1) both; }
body.fx main.fx-enter > *:nth-child(2) { animation-delay: .06s; } body.fx main.fx-enter > *:nth-child(3) { animation-delay: .12s; }
@keyframes fxIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
body.fx .rv { opacity: 0; transform: translateY(22px) scale(.985); transition: opacity .6s cubic-bezier(.2,.8,.2,1) var(--d, 0ms), transform .7s cubic-bezier(.2,.8,.2,1) var(--d, 0ms); }
body.fx .rv.in { opacity: 1; transform: none; }
body.fx .hero2 .kick { animation: fxIn .6s .1s both; }
body.fx .hero2 h1 { animation: heroH .9s cubic-bezier(.2,.8,.2,1) .15s both; }
body.fx .hero2 h1 em { background-size: 200% 100%; animation: shimmer 4s ease-in-out 1.2s infinite; background-image: linear-gradient(90deg, #E8C98A, #D89363, #F3E5C8, #E8C98A); }
body.fx .hero2 p.lead { animation: fxIn .7s .3s both; } body.fx .hero2 .hero-search { animation: fxIn .7s .42s both; } body.fx .hero2 .trust { animation: fxIn .7s .55s both; }
body.fx .hero-collage .ph1 { animation: tileIn 1s cubic-bezier(.2,.8,.2,1) .25s both; } body.fx .hero-collage .ph2 { animation: tileIn 1s cubic-bezier(.2,.8,.2,1) .4s both; } body.fx .hero-collage .ph3 { animation: tileIn 1s cubic-bezier(.2,.8,.2,1) .55s both; }
body.fx .hero-collage .float.f1 { animation: fxIn .7s .9s both, hfloat 5s ease-in-out 1.6s infinite; } body.fx .hero-collage .float.f2 { animation: fxIn .7s 1.05s both, hfloat 5s ease-in-out 2.4s infinite; }
@keyframes heroH { from { opacity: 0; transform: translateY(26px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes tileIn { from { opacity: 0; transform: translateY(40px) rotate(0) scale(.92); } }
@keyframes shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
body.fx .hero2::after { animation: drift 30s linear infinite; }
@keyframes drift { to { background-position: 220px 110px; } }
body.fx .cat-tile:hover .ci { animation: hop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes hop { 40% { transform: translateY(-6px) rotate(-6deg); } }
body.fx .btn.accent { position: relative; overflow: hidden; }
body.fx .btn.accent::before { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%); transform: translateX(-120%); transition: transform .7s ease; }
body.fx .btn.accent:hover::before { transform: translateX(120%); }
body.fx .pcard .add-btn { transition: transform .2s cubic-bezier(.3,1.6,.5,1), box-shadow .2s; }
body.fx .pcard:hover .add-btn { transform: scale(1.1) rotate(90deg); }
body.fx .sale-pill { animation: salePulse 2.4s ease-in-out infinite; }
@keyframes salePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
body.fx .store-hero .cover img { animation: kenburns 18s ease-out both; }
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }
body.fx .timeline .st.cur .dot { animation: curPulse 1.8s ease-in-out infinite; }
@keyframes curPulse { 0%, 100% { box-shadow: 0 0 0 5px var(--terra-100); } 50% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { body.fx .rv { opacity: 1; transform: none; transition: none; } .pop, .perm-card, .chat-panel, .cm { animation: none !important; } }

/* ---------- install-the-app window (phones) */
.pwa-win .perm-card { padding-top: 22px; }
.pw-icon { width: 76px; height: 76px; border-radius: 20px; margin: -60px auto 12px; display: block; box-shadow: 0 16px 30px -12px rgba(0,0,0,.45); border: 4px solid var(--surface); background: var(--surface); }
.pw-feats { list-style: none; padding: 0; margin: 0 0 14px; display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 8px !important; }
.pw-feats li { flex-direction: column; justify-content: center; text-align: center; gap: 4px !important; padding: 10px 6px !important; font-size: .78rem !important; }
.pw-feats li .ico { font-size: 1.4em; }
.pw-steps { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; text-align: start; counter-reset: none; }
.pw-steps li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 13px; background: var(--terra-100); border: 1px solid var(--terra-line); font-size: .9rem; line-height: 1.6; }
.pw-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--terra); color: #fff; font-weight: 700; font-size: .82rem; flex-shrink: 0; }
.pw-k { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.pw-k .ico { color: var(--terra-ink); }
.pwa-win [data-copy] { margin-bottom: 12px; }
