/**
 * Wehome Premium Craft — motion utilities
 * SSOT: docs/design-md/motion.md · craft.md · wh-tokens.css
 * Load after wh-tokens / _wh-bridge
 */

/* ── Press / release ── */
.wh-pressable {
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--wh-motion-base, 260ms) var(--wh-ease-spring, cubic-bezier(0.34, 1.28, 0.64, 1)),
    opacity var(--wh-motion-fast, 180ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1)),
    background-color var(--wh-motion-fast, 180ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1)),
    box-shadow var(--wh-motion-base, 260ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1)),
    border-color var(--wh-motion-fast, 180ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1));
}
.wh-pressable:active {
  transform: scale(var(--wh-scale-press, 0.96));
  transition-duration: var(--wh-motion-fast, 180ms);
  transition-timing-function: var(--wh-ease-press, cubic-bezier(0.4, 0, 0.2, 1));
}
.wh-pressable--deep:active {
  transform: scale(var(--wh-scale-press-deep, 0.92));
}

/* ── Desktop card lift ── */
.wh-lift {
  box-shadow: var(--wh-shadow-listing, 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06));
  transition:
    transform var(--wh-motion-base, 260ms) var(--wh-ease-spring-soft, cubic-bezier(0.22, 1.08, 0.36, 1)),
    box-shadow var(--wh-motion-base, 260ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1));
}
@media (hover: hover) and (pointer: fine) {
  .wh-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--wh-shadow-listing-hover, 0 2px 4px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.1));
  }
}
.wh-lift:active {
  transform: scale(0.98);
  transition-duration: var(--wh-motion-fast, 180ms);
  transition-timing-function: var(--wh-ease-press, cubic-bezier(0.4, 0, 0.2, 1));
}

/* Listing image zoom on hover */
.wh-lift .wh-lift__img,
.wh-lift .r26-prop-img,
.r26-prop-card.wh-lift .r26-prop-img {
  transition: transform 600ms var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1));
}
@media (hover: hover) and (pointer: fine) {
  .wh-lift:hover .wh-lift__img,
  .wh-lift:hover .r26-prop-img,
  .r26-prop-card.wh-lift:hover .r26-prop-img {
    transform: scale(1.04);
  }
}

/* ── Scroll / page enter ── */
.wh-enter {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--wh-motion-enter, 520ms) var(--wh-ease-spring-soft, cubic-bezier(0.22, 1.08, 0.36, 1)),
    transform var(--wh-motion-enter, 520ms) var(--wh-ease-spring-soft, cubic-bezier(0.22, 1.08, 0.36, 1));
}
.wh-enter.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Button loading ── */
.wh-btn--loading,
.wh-pressable.wh-btn--loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}
.wh-btn--loading::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  vertical-align: -0.15em;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wh-spin var(--wh-motion-slow, 380ms) linear infinite;
}
.wh-btn--accent.wh-btn--loading::after,
.wh-btn--secondary.wh-btn--loading::after,
.wh-btn--ghost.wh-btn--loading::after {
  border-color: rgba(104, 0, 205, 0.25);
  border-top-color: var(--wh-brand, #6800cd);
}
@keyframes wh-spin {
  to { transform: rotate(360deg); }
}

/* ── Skeleton ── */
.wh-skeleton {
  background: var(--wh-surface, #f4f5f7);
  border-radius: var(--wh-radius-sm, 16px);
  position: relative;
  overflow: hidden;
}
.wh-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: wh-shimmer 1.2s var(--wh-ease-in-out-smooth, cubic-bezier(0.45, 0, 0.55, 1)) infinite;
}
@keyframes wh-shimmer {
  to { transform: translateX(100%); }
}
.wh-skeleton-card {
  border-radius: var(--wh-radius-md, 20px);
  overflow: hidden;
  background: var(--wh-card, #fff);
  box-shadow: var(--wh-shadow-listing, 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06));
}
.wh-skeleton-card .wh-skeleton-img {
  aspect-ratio: 4 / 3;
  width: 100%;
  border-radius: 0;
}
.wh-skeleton-card .wh-skeleton-line {
  height: 14px;
  margin: 8px 14px;
  border-radius: 8px;
}
.wh-skeleton-card .wh-skeleton-line.short {
  width: 55%;
}

/* ── Empty ── */
.wh-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--wh-space-5xl, 48px) var(--wh-space-xl, 24px);
  gap: var(--wh-space-sm, 12px);
}
.wh-empty__icon {
  width: var(--wh-icon-lg, 40px);
  height: var(--wh-icon-lg, 40px);
  border-radius: var(--wh-radius-sm, 16px);
  background: var(--wh-surface, #f4f5f7);
  color: var(--wh-tx3, #8b95a1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}
.wh-empty__title {
  margin: 0;
  font-size: var(--wh-text-title, 1rem);
  font-weight: 700;
  color: var(--wh-tx, #191f28);
  letter-spacing: var(--wh-tracking-title, -0.03em);
  word-break: keep-all;
}
.wh-empty__desc {
  margin: 0;
  font-size: var(--wh-text-sm, 0.875rem);
  color: var(--wh-tx3, #8b95a1);
  line-height: var(--wh-lh-body, 1.47);
  max-width: 280px;
  word-break: keep-all;
}
.wh-empty__actions {
  margin-top: var(--wh-space-xs, 8px);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ── Error panel ── */
.wh-error-panel {
  background: var(--wh-err-bg, #fef2f2);
  border: 1px solid var(--wh-err-bd, #fecaca);
  border-radius: var(--wh-radius-md, 20px);
  padding: var(--wh-space-xl, 24px);
  color: var(--wh-err-tx, #b91c1c);
}
.wh-error-panel__title {
  margin: 0 0 6px;
  font-size: var(--wh-text-title, 1rem);
  font-weight: 700;
  color: var(--wh-err-tx, #b91c1c);
}
.wh-error-panel__desc {
  margin: 0 0 14px;
  font-size: var(--wh-text-sm, 0.875rem);
  color: var(--wh-tx2, #4e5968);
  line-height: 1.47;
}
.wh-error-panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Media scrim (allowed gradient) */
.wh-media-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent);
}

/* Price hierarchy */
.wh-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--wh-tx, #191f28);
  letter-spacing: -0.02em;
}
.wh-price__strike {
  font-size: 12px;
  font-weight: 500;
  color: var(--wh-tx3, #8b95a1);
  text-decoration: line-through;
  margin-right: 4px;
}
.wh-price__unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--wh-tx3, #8b95a1);
}
.wh-price__total {
  font-size: 12px;
  font-weight: 500;
  color: var(--wh-tx2, #4e5968);
  margin-top: 2px;
}

/* View Transitions — MPA 레이아웃 전환 FOUC(위시리스트 우측 깜빡임 등)로 비활성.
 * 단일 레이아웃 SPA급 전환이 준비되면 motion.md §14 기준으로 재도입. */
/*
@supports (view-transition-name: none) {
  @view-transition {
    navigation: auto;
  }
  ::view-transition-old(root) {
    animation: wh-vt-out var(--wh-motion-slow, 380ms) var(--wh-ease-out-smooth, cubic-bezier(0.16, 1, 0.3, 1)) both;
  }
  ::view-transition-new(root) {
    animation: wh-vt-in var(--wh-motion-base, 260ms) var(--wh-ease-spring-soft, cubic-bezier(0.22, 1.08, 0.36, 1)) both;
  }
}
@keyframes wh-vt-out {
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes wh-vt-in {
  from { opacity: 0; transform: translateY(10px); }
}
*/

@media (prefers-reduced-motion: reduce) {
  .wh-pressable,
  .wh-pressable:active,
  .wh-lift,
  .wh-lift:hover,
  .wh-lift:active,
  .wh-enter,
  .wh-lift .wh-lift__img,
  .wh-lift .r26-prop-img {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  .wh-enter { opacity: 1; }
  .wh-skeleton::after { animation: none; }
  .wh-btn--loading::after { animation: none; border-top-color: currentColor; opacity: 0.5; }
}
