/* 开好啦 Phase 2 (P1) — Visual Polish, Iris Gallery 3D Motion, Quick Search & FOUC Guard */

/* 1. Deep-Route FOUC Guard (removed immediately when app.js paints target route) */
html.kh-hydrating #app {
  opacity: 0 !important;
  pointer-events: none;
}
#app {
  transition: opacity 0.16s ease-out;
}

/* 2. Smooth Route Entrance Animation */
@keyframes khFadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: no-preference) {
  #app > .wrap,
  #app > .hall {
    animation: khFadeUp 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

/* 3. Iris Gallery 3D Magnetic Tilt & Cursor-Tracking Holographic Foil (Desktop fine-pointer only) */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .neo-card:not(.is-out) {
    transform: perspective(920px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--ty, 0px));
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), filter 0.25s ease;
    will-change: transform;
  }
  .neo-card:not(.is-out).is-tilting {
    transition: transform 0.08s linear;
  }
  .neo-card:not(.is-out) .neo-card-face::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: var(--foil-o, 0);
    transition: opacity 0.28s ease;
    background: radial-gradient(
      260px circle at var(--mx, 50%) var(--my, 50%),
      rgba(255, 255, 255, 0.22) 0%,
      rgba(56, 189, 248, 0.14) 28%,
      rgba(217, 70, 239, 0.10) 52%,
      transparent 74%
    );
    mix-blend-mode: screen;
    z-index: 2;
  }
  [data-theme="light"] .neo-card:not(.is-out) .neo-card-face::after {
    background: radial-gradient(
      260px circle at var(--mx, 50%) var(--my, 50%),
      rgba(255, 255, 255, 0.55) 0%,
      rgba(56, 189, 248, 0.16) 34%,
      rgba(168, 85, 247, 0.10) 58%,
      transparent 76%
    );
    mix-blend-mode: soft-light;
  }
}

/* 4. Tablet (~861px–1180px) Navbar Wrapping Fix */
@media (min-width: 861px) and (max-width: 1180px) {
  .topbar nav a,
  header nav a {
    padding-left: 9px !important;
    padding-right: 9px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }
  .topbar nav,
  header nav {
    gap: 2px !important;
    flex-wrap: nowrap !important;
  }
}

/* 5. FAQ Accordion Polish (softer divider + smooth open) */
@keyframes khFaqOpen {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.faq-item[open] .ans {
  border-top-color: rgba(148, 163, 184, 0.18) !important;
  animation: khFaqOpen 0.2s ease-out both;
}
[data-theme="light"] .faq-item[open] .ans {
  border-top-color: rgba(15, 23, 42, 0.1) !important;
}

/* 6. Catalog Empty Category Toggle */
.cat-empty-toggle {
  margin-top: 8px;
  padding: 6px 10px;
  width: 100%;
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  background: transparent;
  color: var(--text-3, #94a3b8);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.cat-empty-toggle:hover {
  border-color: rgba(45, 212, 191, 0.5);
  color: var(--text-1, #f8fafc);
  background: rgba(45, 212, 191, 0.06);
}
@media (max-width: 860px) {
  .cat-empty-toggle {
    width: auto;
    margin-top: 0;
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* 7. Checkout Fee Board Switch Pulse */
@keyframes khFeePulse {
  0% { transform: scale(0.992); opacity: 0.72; }
  100% { transform: scale(1); opacity: 1; }
}
.fee-board.is-pulse {
  animation: khFeePulse 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 8. Quick Search Command Palette Modal */
.kh-qsearch-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(12vh, 96px) 16px 24px;
  background: rgba(5, 7, 14, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: khFadeUp 0.16s ease-out both;
}
[data-theme="light"] .kh-qsearch-backdrop {
  background: rgba(15, 23, 42, 0.42);
}
.kh-qsearch-modal {
  width: min(620px, 100%);
  max-height: min(74vh, 620px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(14, 17, 29, 0.96);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}
[data-theme="light"] .kh-qsearch-modal {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}
.kh-qsearch-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
[data-theme="light"] .kh-qsearch-head {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
.kh-qsearch-head input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 15px;
  outline: none;
}
.kh-qsearch-kbd {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-3, #94a3b8);
  cursor: pointer;
  background: transparent;
}
.kh-qsearch-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kh-qsearch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}
.kh-qsearch-item:hover {
  background: rgba(45, 212, 191, 0.1);
}
.kh-qsearch-item.is-out {
  opacity: 0.56;
}
.kh-qsearch-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
.kh-qsearch-sub {
  font-size: 12px;
  color: var(--text-3, #94a3b8);
}
.kh-qsearch-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.kh-qsearch-price {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.kh-qsearch-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3, #94a3b8);
}
