/* «بضاعة بلدي» — motion layer. Adds movement only: every rule here either
   animates transform/opacity or styles an element motion.js creates. The
   approved layouts are untouched; reduced-motion users get the static UI. */
:root {
  --motion-forest: #1D5C3A;
  --motion-green: #1F8A43;
  --motion-ivory: #F7F3EA;
  --motion-orange: #E07B24;
  --motion-error: #C7323D;
  --motion-ease-out: cubic-bezier(.22, 1, .36, 1);
  --motion-ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

/* 4. Button loading → check ------------------------------------------- */
.motion-btn-busy { cursor: progress; }
.motion-btn-status { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; margin-inline-end: 8px; line-height: 0; }
.motion-btn-overlay { position: relative; }
.motion-btn-overlay > :not(.motion-btn-status) { opacity: 0; }
.motion-btn-overlay > .motion-btn-status { position: absolute; inset: 0; margin: 0; }
.motion-spinner {
  width: 1.05em; height: 1.05em; min-width: 16px; min-height: 16px; border-radius: 50%;
  border: 2.4px solid currentColor; border-inline-end-color: transparent; opacity: .9;
  animation: motion-spin .7s linear infinite;
}
.motion-check { width: 1.25em; height: 1.25em; min-width: 18px; min-height: 18px; }
.motion-check path { fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; animation: motion-draw .38s var(--motion-ease-out) forwards; }
.motion-btn-done { animation: motion-pop .32s var(--motion-ease-out); }
@keyframes motion-spin { to { transform: rotate(360deg); } }
@keyframes motion-draw { to { stroke-dashoffset: 0; } }
@keyframes motion-pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* 5. Drawn success check ---------------------------------------------- */
.motion-success-check { display: block; width: 76px; height: 76px; margin: 0 auto 10px; color: var(--motion-green); }
.motion-success-check circle { fill: none; stroke: currentColor; stroke-width: 3; stroke-dasharray: 202; stroke-dashoffset: 202; opacity: .28; animation: motion-ring-draw .6s var(--motion-ease-out) forwards; }
.motion-success-check path { fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 48; stroke-dashoffset: 48; animation: motion-check-draw .45s .42s var(--motion-ease-out) forwards; }
.motion-success-check.is-inline { display: inline-block; width: 30px; height: 30px; margin: 0 0 0 6px; vertical-align: middle; }
@keyframes motion-ring-draw { to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes motion-check-draw { to { stroke-dashoffset: 0; } }
.motion-celebrate {
  position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px;
  background: rgba(16, 42, 30, .36); animation: motion-fade-in .2s ease-out;
}
.motion-celebrate.is-leaving { animation: motion-fade-out .28s ease-in forwards; }
.motion-celebrate-card {
  width: min(320px, 100%); padding: 26px 22px 22px; border-radius: 24px; text-align: center;
  background: var(--motion-ivory); color: var(--motion-forest); font-family: Cairo, system-ui, sans-serif;
  box-shadow: 0 24px 60px rgba(16, 42, 30, .28); animation: motion-rise .42s var(--motion-ease-out);
}
.motion-celebrate-card strong { display: block; font-size: 1.15rem; font-weight: 900; }
.motion-celebrate-card p { margin: 6px 0 0; color: #4b5a4f; font-size: .92rem; }
@keyframes motion-fade-in { from { opacity: 0; } }
@keyframes motion-fade-out { to { opacity: 0; } }
@keyframes motion-rise { from { opacity: 0; transform: translateY(18px) scale(.96); } }

/* 6. OTP digit boxes --------------------------------------------------- */
.otp-source { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; clip-path: inset(50%) !important; }
.otp-boxes { display: flex; justify-content: center; gap: 8px; margin: 8px 0 4px; direction: ltr; }
.otp-box {
  width: 44px; height: 52px; padding: 0; border-radius: 12px; text-align: center;
  font: 800 1.35rem/1 Cairo, system-ui, sans-serif; color: var(--motion-forest);
  background: #fff; border: 1.5px solid #cfd8cf; caret-color: var(--motion-green);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s var(--motion-ease-out);
}
.otp-box:focus { outline: none; border-color: var(--motion-green); box-shadow: 0 0 0 3px rgba(31, 138, 67, .18); }
.otp-box.is-filled { border-color: var(--motion-forest); transform: translateY(-1px); }
.otp-boxes.is-invalid .otp-box { border-color: var(--motion-error); box-shadow: 0 0 0 3px rgba(199, 50, 61, .14); }
@media (max-width: 360px) { .otp-boxes { gap: 6px; } .otp-box { width: 38px; height: 48px; } }

/* 7. Shake on error ---------------------------------------------------- */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--motion-error) !important; box-shadow: 0 0 0 3px rgba(199, 50, 61, .13) !important; }
.motion-field-error { display: block; margin-top: 5px; color: var(--motion-error); font-size: .82rem; font-weight: 700; animation: motion-fade-in .2s ease-out; }
.motion-shake { animation: motion-shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes motion-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* 8. Draggable bottom sheet ------------------------------------------- */
.motion-sheet-enabled .mobile-sheet-handle, .motion-sheet-enabled .mobile-sheet-head { touch-action: none; cursor: grab; }
.motion-sheet-enabled.is-dragging, .motion-sheet-enabled.is-dragging * { cursor: grabbing; user-select: none; }
.motion-sheet-enabled.is-snapping { transition: transform .32s var(--motion-ease-out) !important; }
.motion-sheet-enabled .mobile-sheet-handle { position: relative; }
.motion-sheet-enabled .mobile-sheet-handle::after { content: ""; position: absolute; inset: -12px -40px; }

/* 9. Swinging discount badge ------------------------------------------ */
.offer-ribbon { animation: motion-ribbon-swing 4.8s ease-in-out infinite; }
[dir="ltr"] .offer-ribbon { animation-name: motion-ribbon-swing-ltr; }
.offer-tag { transform-origin: 50% 0; animation: motion-tag-swing 4.8s ease-in-out infinite; }
@keyframes motion-ribbon-swing {
  0%, 70%, 100% { transform: rotate(45deg); }
  76% { transform: rotate(48.5deg); }
  82% { transform: rotate(42.5deg); }
  88% { transform: rotate(46.5deg); }
  94% { transform: rotate(44.4deg); }
}
@keyframes motion-ribbon-swing-ltr {
  0%, 70%, 100% { transform: rotate(-45deg); }
  76% { transform: rotate(-48.5deg); }
  82% { transform: rotate(-42.5deg); }
  88% { transform: rotate(-46.5deg); }
  94% { transform: rotate(-44.4deg); }
}
@keyframes motion-tag-swing {
  0%, 70%, 100% { transform: rotate(0); }
  76% { transform: rotate(4deg); }
  82% { transform: rotate(-3deg); }
  88% { transform: rotate(1.6deg); }
  94% { transform: rotate(-.6deg); }
}

/* 10. Store stories ---------------------------------------------------- */
.seller-circle-item.story-unseen .seller-circle-avatar,
.seller-circle-item.story-seen .seller-circle-avatar { box-shadow: 0 0 0 2.5px var(--motion-ivory), 0 0 0 5px var(--motion-green); transition: box-shadow .3s ease; }
.seller-circle-item.story-unseen .seller-circle-avatar { box-shadow: 0 0 0 2.5px var(--motion-ivory), 0 0 0 5px var(--motion-green), 0 0 0 7px rgba(31, 138, 67, .14); }
.seller-circle-item.story-seen .seller-circle-avatar { box-shadow: 0 0 0 2.5px var(--motion-ivory), 0 0 0 4px #b9bfb8; }
#homeSellersCircles { padding-block: 8px; }
.story-viewer {
  position: fixed; inset: 0; z-index: 4000; display: flex; flex-direction: column; background: #0c1a12; color: #fff;
  font-family: Cairo, system-ui, sans-serif; touch-action: none; animation: story-open .28s var(--motion-ease-out);
}
.story-viewer.is-leaving { animation: story-close .22s ease-in forwards; }
@keyframes story-open { from { opacity: 0; transform: scale(.94); } }
@keyframes story-close { to { opacity: 0; transform: translateY(40px) scale(.96); } }
.story-top { position: absolute; inset: 0 0 auto; z-index: 3; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 18px; background: linear-gradient(#000a, #0000); }
.story-bars { display: flex; gap: 4px; direction: rtl; }
.story-bar { flex: 1; height: 3px; border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, .32); }
.story-bar i { display: block; height: 100%; width: 100%; background: #fff; transform: scaleX(0); transform-origin: right center; }
.story-bar.is-done i { transform: scaleX(1); }
.story-head { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.story-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--motion-green); font-weight: 900; box-shadow: 0 0 0 2px #fff; flex: none; }
.story-avatar img { width: 100%; height: 100%; object-fit: cover; }
.story-title { flex: 1; min-width: 0; }
.story-title strong { display: block; font-size: .98rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-title small { color: rgba(255, 255, 255, .78); font-size: .78rem; }
.story-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.story-stage { position: relative; flex: 1; display: grid; place-items: center; overflow: hidden; }
.story-stage img { width: 100%; height: 100%; object-fit: contain; animation: story-img-in .35s var(--motion-ease-out); }
@keyframes story-img-in { from { opacity: .2; transform: scale(1.03); } }
.story-tap { position: absolute; top: 0; bottom: 0; width: 38%; z-index: 2; background: transparent; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.story-tap.is-prev { right: 0; }
.story-tap.is-next { left: 0; width: 62%; }
.story-bottom { position: absolute; inset: auto 0 0; z-index: 3; padding: 34px 16px calc(16px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(#0000, #000c 42%); }
.story-caption strong { display: block; font-size: 1.05rem; font-weight: 800; }
.story-caption span { color: #d9f2df; font-weight: 700; font-size: .92rem; }
.story-actions { display: flex; gap: 10px; margin-top: 12px; }
.story-actions button { flex: 1; min-height: 46px; border-radius: 14px; border: 0; font: 800 .95rem Cairo, system-ui, sans-serif; cursor: pointer; }
.story-actions .is-primary { background: var(--motion-green); color: #fff; }
.story-actions .is-secondary { background: rgba(255, 255, 255, .16); color: #fff; }
.story-loading { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: motion-spin .8s linear infinite; }
.story-viewer.is-paused .story-bar.is-active i { opacity: .75; }

/* 11. Pull to refresh -------------------------------------------------- */
html { overscroll-behavior-y: contain; }
.motion-ptr {
  position: fixed; top: 0; left: 50%; z-index: 1200; width: 42px; height: 42px; margin-left: -21px; border-radius: 50%;
  display: grid; place-items: center; background: var(--motion-ivory); color: var(--motion-green);
  box-shadow: 0 6px 18px rgba(16, 42, 30, .2); transform: translateY(-60px); opacity: 0; pointer-events: none;
}
.motion-ptr svg { width: 22px; height: 22px; }
.motion-ptr.is-ready { color: #fff; background: var(--motion-green); }
.motion-ptr.is-settling { transition: transform .3s var(--motion-ease-out), opacity .3s ease; }
.motion-ptr.is-refreshing svg { animation: motion-spin .9s linear infinite; }

/* 12. Direction-aware view transitions -------------------------------- */
.motion-view-forward { animation: motion-view-from-left .3s var(--motion-ease-out); }
.motion-view-back { animation: motion-view-from-right .3s var(--motion-ease-out); }
@keyframes motion-view-from-left { from { opacity: .35; transform: translateX(-28px); } }
@keyframes motion-view-from-right { from { opacity: .35; transform: translateX(28px); } }

/* 13. Rotating search placeholder ------------------------------------- */
.motion-ph-host { position: relative; }
.motion-ph {
  position: absolute; pointer-events: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  display: flex; align-items: center; color: #8a8f86; transition: opacity .32s ease, transform .32s var(--motion-ease-out);
}
.motion-ph.is-out { opacity: 0; transform: translateY(-9px); }
.motion-ph.is-in-start { opacity: 0; transform: translateY(9px); transition: none; }
.motion-ph[hidden] { display: none; }

/* 14. Marquee ticker --------------------------------------------------- */
.motion-ticker {
  position: relative; overflow: hidden; margin: 10px 0 4px; height: 34px; border-radius: 12px;
  background: var(--motion-forest); color: var(--motion-ivory); font: 700 .86rem/34px Cairo, system-ui, sans-serif;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.motion-ticker-track { display: flex; width: max-content; animation: motion-ticker-rtl var(--ticker-duration, 30s) linear infinite; }
.motion-ticker:hover .motion-ticker-track, .motion-ticker.is-held .motion-ticker-track, .motion-ticker:focus-within .motion-ticker-track { animation-play-state: paused; }
.motion-ticker-group { display: flex; flex: none; }
.motion-ticker-item { display: inline-flex; align-items: center; gap: 8px; padding-inline: 18px; white-space: nowrap; color: inherit; text-decoration: none; border: 0; background: none; font: inherit; cursor: pointer; }
.motion-ticker-item::after { content: "✦"; color: var(--motion-orange); font-size: .7rem; margin-inline-start: 18px; }
.motion-ticker-item b { color: #ffd39c; font-weight: 900; }
@keyframes motion-ticker-rtl { from { transform: translateX(0); } to { transform: translateX(50%); } }

/* 15. Sliding selection pill ------------------------------------------ */
.motion-pill { position: absolute; z-index: 0; pointer-events: none; opacity: 0; top: 0; left: 0; transition: transform .34s var(--motion-ease-out), width .34s var(--motion-ease-out), height .34s var(--motion-ease-out), opacity .18s ease; }
.motion-pill-host > .motion-pill-item { z-index: 1; }
.motion-pill-host > .motion-pill-item:not([style*="position"]) { position: relative; }
.motion-pill-host.is-pill-moving .motion-pill { opacity: 1; }
.motion-pill-host.is-pill-moving > .motion-pill-active { background: transparent !important; background-color: transparent !important; border-color: transparent !important; box-shadow: none !important; }

@media (prefers-reduced-motion: reduce) {
  .offer-ribbon, .offer-tag, .motion-ticker-track, .motion-shake, .motion-btn-done,
  .motion-view-forward, .motion-view-back, .story-viewer, .story-stage img, .motion-celebrate, .motion-celebrate-card { animation: none !important; }
  .motion-ticker-track { overflow-x: auto; }
  .motion-ticker { overflow-x: auto; }
  .motion-success-check circle, .motion-success-check path, .motion-check path { animation: none !important; stroke-dashoffset: 0 !important; opacity: 1 !important; }
  .motion-pill { display: none !important; }
  .motion-ph, .motion-ptr.is-settling, .motion-sheet-enabled.is-snapping, .otp-box { transition: none !important; }
  .motion-spinner, .story-loading, .motion-ptr.is-refreshing svg { animation-duration: 1.6s; }
}
