/* Shared motion layer — keep edits here so all pages stay in sync */

/* Avoid EN→ZH flash: head script sets html.i18n-wait when UI lang is Chinese */
html.i18n-wait body {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html.motion-reduce *,
  html.motion-reduce *::before,
  html.motion-reduce *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html {
  scroll-behavior: smooth;
}

/* Route transition */
@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html.js:not(.motion-reduce) .page-transition {
  animation: page-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html.js:not(.motion-reduce) .page-transition > * {
  animation: page-enter 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Nav: stronger depth when scrolled */
.site-nav,
nav {
  transition:
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.35s ease,
    transform 0.35s ease;
}

.site-nav[data-scrolled],
nav[data-scrolled] {
  box-shadow:
    0 10px 40px rgba(28, 27, 27, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* Nav links: underline sweep */
@media (hover: hover) and (pointer: fine) {
  html.js:not(.motion-reduce) nav a[href] {
    position: relative;
  }

  html.js:not(.motion-reduce) nav a[href]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, #835400, #fba81f);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    opacity: 0.9;
    pointer-events: none;
  }

  html.js:not(.motion-reduce) nav a[href]:hover::after,
  html.js:not(.motion-reduce) nav a[href]:focus-visible::after {
    transform: scaleX(1);
  }

  html.js:not(.motion-reduce) nav a[href].font-bold::after {
    transform: scaleX(1);
  }
}

/* Logo micro lift */
@media (hover: hover) {
  html.js:not(.motion-reduce) nav > div > a[href] {
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* Universal interactive affordances */
html.js:not(.motion-reduce) a,
html.js:not(.motion-reduce) button {
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    opacity 0.25s ease,
    background-color 0.25s ease,
    color 0.25s ease,
    filter 0.25s ease;
}

html.js:not(.motion-reduce) .interactive-card,
html.js:not(.motion-reduce) .motion-cta,
html.js:not(.motion-reduce) .interactive-link {
  position: relative;
}

html.js:not(.motion-reduce) .interactive-card::before,
html.js:not(.motion-reduce) .motion-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(
      260px circle at var(--pointer-x, 50%) var(--pointer-y, 50%),
      rgba(255, 245, 226, 0.22),
      transparent 42%
    );
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

@media (hover: hover) {
  html.js:not(.motion-reduce) .interactive-card:hover {
    box-shadow:
      0 24px 48px -26px rgba(27, 22, 18, 0.32),
      0 12px 22px -18px rgba(166, 122, 60, 0.18);
  }

  html.js:not(.motion-reduce) .interactive-card:hover::before,
  html.js:not(.motion-reduce) .motion-cta:hover::before {
    opacity: 0.65;
  }

  html.js:not(.motion-reduce) .interactive-link:hover {
    filter: brightness(1.02);
  }

  html.js:not(.motion-reduce) .motion-cta:hover {
    filter: brightness(1.03);
    box-shadow:
      0 16px 32px -18px rgba(131, 84, 0, 0.32),
      0 8px 18px -16px rgba(255, 219, 166, 0.36);
  }

  html.js:not(.motion-reduce) .motion-cta:hover span[aria-hidden],
  html.js:not(.motion-reduce) .interactive-link:hover span[aria-hidden] {
    transform: translateX(3px);
  }
}

html.js:not(.motion-reduce) a:active,
html.js:not(.motion-reduce) button:active {
  transform: scale(0.97);
}

html.js:not(.motion-reduce) .motion-cta span[aria-hidden],
html.js:not(.motion-reduce) .interactive-link span[aria-hidden] {
  display: inline-block;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Image emphasis */
html.js:not(.motion-reduce) .interactive-card img {
  transition:
    transform 0.82s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.45s ease,
    opacity 0.35s ease;
}

@media (hover: hover) {
  html.js:not(.motion-reduce) .interactive-card:hover img {
    transform: scale(1.035);
    filter: saturate(1.06) contrast(1.04) brightness(1.02);
  }
}

/* Form controls feel alive */
html.js:not(.motion-reduce) input,
html.js:not(.motion-reduce) textarea,
html.js:not(.motion-reduce) select {
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease,
    background-color 0.25s ease;
}

html.js:not(.motion-reduce) input:focus,
html.js:not(.motion-reduce) textarea:focus,
html.js:not(.motion-reduce) select:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(131, 84, 0, 0.18);
}

/* Scroll reveal — keyframes avoid a “flash then hide” before JS runs */
@keyframes site-reveal-in {
  from {
    opacity: 0;
    transform: translateY(36px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

html.js:not(.motion-reduce) .reveal-target.is-in-view {
  animation: site-reveal-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--reveal-delay, 0) * 1ms);
}

html.js:not(.motion-reduce) .reveal-child {
  opacity: 0;
  transform: translateY(24px);
  filter: blur(2px);
}

html.js:not(.motion-reduce) .reveal-target.is-in-view .reveal-child {
  animation: site-reveal-in 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--child-delay, 0) * 1ms);
}

/* Hero background: slow Ken Burns on first header image stack */
@keyframes site-ken {
  from {
    transform: scale(1) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.07) translate3d(-0.6%, 0.4%, 0);
  }
}

html.js:not(.motion-reduce) .ken-burns-host > img {
  animation: site-ken 28s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes site-float-soft {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

html.js:not(.motion-reduce) .float-soft {
  animation: site-float-soft 6.5s ease-in-out infinite;
}

/* Primary CTAs / pill links: tactile press */
@media (hover: hover) {
  html.js:not(.motion-reduce) a[class~="rounded-[6px]"],
  html.js:not(.motion-reduce) button[class~="rounded-[6px]"],
  html.js:not(.motion-reduce) a.rounded-full,
  html.js:not(.motion-reduce) button.rounded-full {
    transition:
      transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1),
      box-shadow 0.25s ease;
  }

  html.js:not(.motion-reduce) a[class~="rounded-[6px]"]:active,
  html.js:not(.motion-reduce) button[class~="rounded-[6px]"]:active,
  html.js:not(.motion-reduce) a.rounded-full:active,
  html.js:not(.motion-reduce) button.rounded-full:active {
    transform: scale(0.96);
  }
}

/* Image / product cards: extra depth on hover (does not override Tailwind scale transforms) */
html.js:not(.motion-reduce) .group[class~="rounded-[6px]"].overflow-hidden {
  transition: box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  html.js:not(.motion-reduce) .group[class~="rounded-[6px]"].overflow-hidden:hover {
    box-shadow: 0 22px 48px rgba(28, 27, 27, 0.1);
  }
}

html.js:not(.motion-reduce) .site-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      320px circle at var(--nav-pointer-x, 50%) 0%,
      rgba(255, 243, 225, 0.18),
      transparent 48%
    );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

html.js:not(.motion-reduce) .site-nav[data-scrolled]::before {
  opacity: 1;
}
