/* ==========================================================================
   FORME — interface states: transitions, loading, empty states, fallbacks.
   Loaded after forme.css. Every animation is skipped for prefers-reduced-motion.
   ========================================================================== */

/* ---------- page transitions (cross-document View Transitions; unsupported browsers just navigate) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: vt-out .2s var(--ease) both; }
  ::view-transition-new(root) { animation: vt-in .5s var(--ease-out) both; }
  .site-header { view-transition-name: site-header; }
  .tabbar { view-transition-name: tabbar; }
  .gallery__main > img { view-transition-name: product-media; }
  ::view-transition-group(product-media) { animation-duration: .6s; animation-timing-function: var(--ease-out); z-index: 2; }
  ::view-transition-old(product-media), ::view-transition-new(product-media) { height: 100%; object-fit: cover; overflow: clip; }
  ::view-transition-group(site-header), ::view-transition-group(tabbar) { animation-duration: .35s; z-index: 3; }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------- dialogs: animate out as well as in ---------- */
.drawer::backdrop, .qv::backdrop, .nav-drawer::backdrop, .search-dialog::backdrop { animation: fade-in .4s var(--ease) both; }
dialog.is-closing::backdrop { animation: fade-out .32s var(--ease) both; }
.drawer.is-closing { animation: slide-out .36s cubic-bezier(.4, 0, 1, 1) both; }
.nav-drawer.is-closing { animation: slide-out-left .34s cubic-bezier(.4, 0, 1, 1) both; }
.qv.is-closing { animation: sink .28s cubic-bezier(.4, 0, 1, 1) both; }
.search-dialog[open] { animation: drop-in .45s var(--ease-out); }
.search-dialog.is-closing { animation: lift-out .28s cubic-bezier(.4, 0, 1, 1) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes slide-out { to { transform: translateX(100%); } }
@keyframes slide-out-left { to { transform: translateX(-100%); } }
@keyframes sink { to { opacity: 0; transform: translateY(18px) scale(.985); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-16px); } }
@keyframes lift-out { to { opacity: 0; transform: translateY(-16px); } }

/* ---------- content swaps ---------- */
.is-entering { animation: content-in .5s var(--ease-out) both; }
.results.is-entering { animation: none; }
.results.is-entering .card { animation: content-in .6s var(--ease-out) both; }
.results.is-entering .card:nth-child(2) { animation-delay: .04s; }
.results.is-entering .card:nth-child(3) { animation-delay: .08s; }
.results.is-entering .card:nth-child(4) { animation-delay: .12s; }
.results.is-entering .card:nth-child(n+5) { animation-delay: .16s; }
@keyframes content-in { from { opacity: 0; transform: translateY(12px); } }
.results { transition: opacity .25s var(--ease); }
.results.is-loading { cursor: progress; }

.card.is-removing { animation: card-out .38s var(--ease) both; pointer-events: none; }
@keyframes card-out { to { opacity: 0; transform: scale(.96); } }
.mini-line { transition: opacity .25s var(--ease); }
.mini-line.is-updating { opacity: .5; pointer-events: none; }
.mini-line.is-removing { animation: line-out .26s var(--ease) both; }
@keyframes line-out { to { opacity: 0; transform: translateX(24px); } }

.wish-btn.is-popped svg { animation: pop .45s var(--ease-out); }
@keyframes pop { 40% { transform: scale(1.28); } }

/* ---------- loading: progress bar ---------- */
.nav-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 200; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0); background: var(--olive); opacity: 0; }
.nav-progress.is-active { opacity: 1; animation: progress-crawl 8s cubic-bezier(.08, .7, .2, 1) forwards; }
.nav-progress.is-done { animation: none; transform: scaleX(1); opacity: 0; transition: transform .2s var(--ease), opacity .35s .15s var(--ease); }
@keyframes progress-crawl { from { transform: scaleX(0); } 10% { transform: scaleX(.3); } to { transform: scaleX(.92); } }

/* ---------- loading: buttons ---------- */
.btn[aria-busy="true"], button[aria-busy="true"] { pointer-events: none; cursor: progress; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 1.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn[aria-busy="true"] .arrow { display: none; }
.icon-btn[aria-busy="true"] svg { animation: pulse .9s var(--ease) infinite alternate; }
.link[aria-busy="true"] { opacity: .55; }
.delivery__result.is-checking { color: var(--ink-2); }
.delivery__result.is-checking::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: .5rem; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes pulse { to { opacity: .35; transform: scale(.9); } }

/* ---------- loading: skeletons ---------- */
.sk, .img-loading {
  background-color: var(--stone-2);
  background-image: linear-gradient(100deg, transparent 20%, rgba(250, 249, 245, .7) 45%, transparent 70%);
  background-size: 220% 100%; background-repeat: no-repeat;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -90% 0; } }
.sk { display: block; border-radius: var(--radius); }
.sk-line { height: .8rem; }
.sk-title { height: 2.2rem; width: 80%; }
.sk-block { height: 5rem; }
.sk-btn { height: 52px; width: 100%; margin-top: .5rem; }
.sk-media { aspect-ratio: 4 / 5; width: 72px; }
.sk-stack { display: grid; gap: .55rem; align-content: start; }
.w20 { width: 20%; } .w30 { width: 30%; } .w40 { width: 40%; } .w70 { width: 70%; }
.sk-row > .sk-line.w20 { width: 3.5rem; }
.qv__media.sk { aspect-ratio: 4 / 5; }

/* ---------- images: fade in when ready ---------- */
img.is-pending { opacity: 0 !important; }
img.img-in { animation: img-in .7s var(--ease) both; }
@keyframes img-in { from { opacity: 0; } } /* no "to": ends on the element's own opacity (keeps hover-swap images hidden) */

/* ---------- fallbacks ---------- */
.img-failed { background: var(--stone-2); }
.img-failed::before {
  content: "FORME"; position: absolute; inset: 0; display: grid; place-items: center; z-index: 0;
  font-family: var(--serif); font-size: clamp(.9rem, .6rem + 1.2vw, 1.4rem); letter-spacing: .32em; color: var(--grey);
  background: repeating-linear-gradient(135deg, transparent 0 14px, rgba(37, 38, 36, .025) 14px 15px);
}
.fallback-inline { padding: 2.5rem 0; display: grid; gap: 1rem; justify-items: start; font-size: var(--fs-sm); }
.fallback-inline p { margin: 0; color: var(--ink-2); }
.fallback-inline--qv { padding: clamp(2rem, 1.5rem + 3vw, 4rem); justify-items: center; text-align: center; }
html.is-offline .nav-progress { background: var(--danger); }

/* ---------- empty states ---------- */
.empty-state { padding: clamp(3rem, 2rem + 4vw, 5.5rem) 0; text-align: center; display: grid; gap: 1rem; justify-items: center; }
.empty-state--sm { padding: 2.25rem 0; gap: .7rem; }
.empty-state__art { width: 116px; color: var(--olive); margin-bottom: .5rem; }
.empty-state--sm .empty-state__art { width: 76px; margin-bottom: .25rem; }
.empty-state__art svg { width: 100%; height: auto; overflow: visible; }
.empty-state__title { font-size: var(--fs-h3); max-width: 22ch; margin: 0; text-wrap: balance; }
.empty-state--sm .empty-state__title { font-size: var(--fs-h4); }
.empty-state__text { color: var(--ink-2); max-width: 46ch; margin: 0; text-wrap: pretty; }
.empty-state--sm .empty-state__text { font-size: var(--fs-sm); }
.empty-state__actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; margin-top: .5rem; }
.empty-state__chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; align-items: center; margin-top: 1rem; max-width: 640px; }
.empty-state__chips-label { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); margin-right: .25rem; }
.empty-state .chip { transition: background-color .25s, color .25s, border-color .25s; }
.empty-state .chip:hover { background: var(--charcoal); color: var(--ivory); border-color: var(--charcoal); }
td > .empty-state { padding-block: 1.5rem; }

.motion .empty-state > * { animation: content-in .7s var(--ease-out) both; }
.motion .empty-state > :nth-child(2) { animation-delay: .06s; }
.motion .empty-state > :nth-child(3) { animation-delay: .12s; }
.motion .empty-state > :nth-child(n+4) { animation-delay: .18s; }
.motion .ea-float { animation: ea-float 5.5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ea-float { 50% { transform: translateY(-3px); } }

/* ---------- error pages ---------- */
.error-page { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--ivory); }
.error-page__head, .error-page__foot { padding: 1.25rem var(--gutter); display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: var(--fs-xs); color: var(--ink-2); }
.error-page__head { border-bottom: 1px solid var(--line); }
.error-page__foot { border-top: 1px solid var(--line); }
.error-page main { display: grid; place-items: center; padding: 2rem var(--gutter); }
.error-page .empty-state__title { font-size: var(--fs-h2); max-width: 18ch; }
.error-code { font-size: var(--fs-xs); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .sk, .img-loading { animation: none; }
  .nav-progress.is-active { animation: none; transform: scaleX(.6); }
}

/* ==========================================================================
   Action feedback — add to bag, buy now, wishlist, copy, quantity, totals
   ========================================================================== */
/* every button gives a tactile press */
.btn, .icon-btn, .offer__code, .qty button { transition: transform .15s var(--ease), background-color .3s, color .3s, border-color .3s; }
.btn:active:not(:disabled), .icon-btn:active, .offer__code:active, .qty button:active { transform: scale(.97); }

/* success morph: "✓ Added to bag" */
.btn.is-success { --bg: var(--olive); --fg: var(--ivory); --bd: var(--olive); pointer-events: none; animation: success-pulse .5s var(--ease-out); }
.btn.is-success::after { transform: none; background: var(--olive); }
.btn.is-success [data-label], .btn.is-success { gap: .5rem; }
.btn.is-success > span, .btn.is-success [data-label] > span { animation: content-in .35s var(--ease-out) both; }
.btn-check { display: inline-block; flex: none; vertical-align: -2px; margin-right: .15rem; }
.btn-check path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: draw-check .45s .08s var(--ease-out) forwards; }
@keyframes draw-check { to { stroke-dashoffset: 0; } }
@keyframes success-pulse { 0% { box-shadow: 0 0 0 0 rgba(89, 99, 78, .45); } 100% { box-shadow: 0 0 0 12px rgba(89, 99, 78, 0); } }

/* refused: small shake */
.is-shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* buy now: heading to checkout */
.btn--buy-now.is-going { pointer-events: none; }
.btn--buy-now.is-going span { animation: content-in .3s var(--ease-out) both; }

/* fly-to-bag ghost */
.fly-ghost { position: fixed; z-index: 300; pointer-events: none; object-fit: cover; box-shadow: 0 18px 40px -12px rgba(37, 38, 36, .45); will-change: transform, opacity; }
.fly-dot { position: fixed; z-index: 300; width: 22px; height: 22px; border-radius: 50%; background: var(--olive); pointer-events: none; box-shadow: 0 6px 16px rgba(89, 99, 78, .45); will-change: transform; }
.is-bump svg { animation: bag-bump .55s var(--ease-out); transform-origin: 50% 80%; }
@keyframes bag-bump { 30% { transform: scale(1.25) rotate(-8deg); } 55% { transform: scale(.92) rotate(4deg); } }
.badge.is-pop { animation: badge-pop .5s var(--ease-out); }
@keyframes badge-pop { 0% { transform: scale(.4); } 55% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* new line in the drawer glows briefly */
.mini-line.is-new { animation: line-new 1.8s var(--ease) both; }
@keyframes line-new { 0% { background: var(--stone); box-shadow: inset 3px 0 0 var(--olive); } 100% { background: transparent; box-shadow: inset 3px 0 0 transparent; } }

/* wishlist: fill pop + ring burst; unsave shrinks */
.wish-btn { position: relative; }
.wish-btn.is-popped::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 1.5px solid var(--olive); pointer-events: none; animation: ring-burst .55s var(--ease-out) forwards; }
.btn.wish-btn.is-popped::after { inset: auto; transform: none; background: none; z-index: 0; }
@keyframes ring-burst { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.wish-btn.is-unpopped svg { animation: unpop .35s var(--ease); }
@keyframes unpop { 40% { transform: scale(.75); } }
.wish-btn svg path { transition: fill .25s var(--ease); }

/* changed values: price, stock, totals, quantity */
.tick { animation: tick-up .4s var(--ease-out); }
span.tick:not(.stock) { display: inline-block; }
.tick--down { animation-name: tick-down; }
@keyframes tick-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes tick-down { from { opacity: 0; transform: translateY(-8px); } }
.grand dd.tick, [data-checkout-total].tick { animation: tick-up .45s var(--ease-out), total-flash 1.2s var(--ease); border-radius: 2px; }
@keyframes total-flash { 0%, 30% { background: var(--stone); } 100% { background: transparent; } }

/* copy code */
.offer__code.is-copied { animation: success-pulse .5s var(--ease-out); }

/* bag page: lines leave before the page reloads */
.line.is-leaving, .line.is-saving { overflow: hidden; animation: line-collapse .32s var(--ease) forwards; }
.line.is-saving { animation-name: line-save; }
@keyframes line-collapse { to { opacity: 0; transform: translateX(28px); height: 0; padding-block: 0; } }
@keyframes line-save { 40% { opacity: .6; transform: translateY(-6px) scale(.98); } to { opacity: 0; transform: translateY(-18px) scale(.96); height: 0; padding-block: 0; } }

/* flash messages (coupon applied, saved for later…) arrive softly */
.flash { animation: content-in .5s var(--ease-out) both; }
/* tab bar peeks up so the flying item has somewhere to land */
html.peek-tabbar .tabbar { transform: none !important; z-index: 60; }

/* ==========================================================================
   Loading screen (first page of a visit / app launch)
   ========================================================================== */
.splash { display: none; }
html.show-splash body { overflow: hidden; }
html.show-splash .splash {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 1000;
  background: var(--ivory); color: var(--charcoal);
}
.splash__inner { display: grid; justify-items: center; gap: 1rem; }
.splash__word { font-family: var(--serif); font-size: clamp(3rem, 2rem + 6vw, 6rem); letter-spacing: .32em; margin-right: -.32em; line-height: 1; display: flex; overflow: hidden; }
.splash__word > span { display: inline-block; animation: splash-letter .9s calc(var(--i) * .07s) var(--ease-out) both; }
.splash__tag { font-size: var(--fs-xs); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-2); animation: content-in .8s .45s var(--ease-out) both; }
.splash__bar { width: 120px; height: 1px; background: var(--line); overflow: hidden; margin-top: .5rem; }
.splash__bar > span { display: block; height: 100%; background: var(--olive); transform-origin: 0 50%; animation: splash-bar 1.1s .2s var(--ease-out) both; }
html.splash-out .splash { opacity: 0; visibility: hidden; transition: opacity .6s var(--ease), visibility 0s .6s; }
html.splash-out .splash__inner { transform: translateY(-12px); transition: transform .6s var(--ease-out); }
@keyframes splash-letter { from { transform: translateY(105%); opacity: 0; } }
@keyframes splash-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ==========================================================================
   Skeleton screens
   ========================================================================== */
/* page skeleton: covers the old page while a slow navigation loads (sits under the header and tab bar) */
.page-skeleton {
  position: fixed; inset: var(--header-h) 0 var(--tabbar-h, 0px) 0; z-index: 55; overflow: hidden;
  background: var(--ivory); padding-top: 1.5rem; animation: fade-in .25s var(--ease) both;
}
.sk-gap { margin-bottom: 1rem; }
.sk-heading { height: clamp(2.4rem, 1.6rem + 3vw, 4.5rem); width: min(70%, 560px); margin-bottom: 1rem; }
.sk-price { height: 1.6rem; width: 9rem; margin: .5rem 0; }
.sk-pill { height: 44px; width: 7.5rem; border-radius: 2px; }
.sk-toolbar { display: flex; gap: .75rem; justify-content: space-between; padding: .75rem 0; margin: 1rem 0 2rem; border-block: 1px solid var(--line); }
.sk-pdp__info .sk-toolbar { justify-content: flex-start; border: 0; margin: .5rem 0; padding: 0; }
.sk-grid { pointer-events: none; }
.sk-card { display: grid; gap: .6rem; align-content: start; }
.sk-card__media { aspect-ratio: 4 / 5; width: 100%; margin-bottom: .4rem; }
.sk-pdp { display: grid; gap: 2rem; }
@media (min-width: 1000px) { .sk-pdp { grid-template-columns: 1.15fr 1fr; gap: clamp(2rem, 1rem + 3vw, 5rem); } }
.sk-pdp__media { aspect-ratio: 4 / 5; width: 100%; max-height: 70vh; }
.sk-pdp__info { gap: .8rem; }
.sk-article { max-width: 760px; display: grid; gap: .7rem; }
.sk-article .sk-line { height: .9rem; }

/* listing: skeleton cards replace results while filters reload */
.results.is-loading { opacity: 1; }
.results.is-loading > :not(.sk-grid):not([hidden]) { opacity: .35; }

/* search suggestions loading */
.suggest__sk { display: grid; grid-template-columns: 48px 1fr auto; gap: 1rem; align-items: center; padding: .6rem .5rem; border-bottom: 1px solid var(--line); }
.suggest__sk .sk:first-child { width: 48px; height: 60px; }
.suggest__sk .sk-stack .sk { height: .8rem; }
.suggest__sk > .sk:last-child { width: 4.5rem; height: .8rem; }

/* checkout totals while the server re-prices */
.totals.is-quoting dd { color: transparent !important; border-radius: 2px; background-color: var(--stone-2);
  background-image: linear-gradient(100deg, transparent 20%, rgba(250, 249, 245, .7) 45%, transparent 70%); background-size: 220% 100%; background-repeat: no-repeat; animation: shimmer 1.4s linear infinite; }
/* while a page skeleton shows, the see-through home header turns solid like every other page */
html:has(.page-skeleton) .site-header--overlay { background: var(--ivory); color: var(--charcoal); border-color: var(--line); }
html:has(.page-skeleton) .site-header--overlay::before { opacity: 0; }
