/* AIBuy Unified Silky Motion & Pixel-Locked Sidebar System (2026-11-23 v2)
   1. Pixel-locked left rail icons (0px horizontal drift on collapse/expand) across 对接/比价/避坑
   2. Short-video vertical slide + multi-jump whoosh reel overlay styles for detail panes
   3. Smooth publish composer bloom + whole-site spring micro-interactions
   4. Strictly respects html.theme-revealing and prefers-reduced-motion */

:root {
  --aibuy-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --aibuy-snappy: cubic-bezier(0.2, 0.9, 0.25, 1);
  --board-motion: 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   1. PIXEL-LOCKED LEFT SIDEBAR ICONS (Δx = 0px during expand / collapse)
   ========================================================================== */
@media (min-width: 701px) {
  /* 资源对接 & 交易避坑: rail inner = 57px when collapsed, icon = 16px -> 6 + 14.5 = 20.5px ALWAYS */
  html:not(#a1):not(#a2) .directory-main-matching .match-board .match-rail,
  html:not(#a1):not(#a2) .directory-main-matching .match-board.is-rail-collapsed .match-rail,
  html:not(#a1):not(#a2) .directory-main-risk .risk-board .risk-rail,
  html:not(#a1):not(#a2) .directory-main-risk .risk-board.is-rail-collapsed .risk-rail {
    padding-left: 6px !important;
    padding-right: 6px !important;
    transition: width 0.36s var(--aibuy-spring), box-shadow 0.32s ease !important;
  }

  html:not(#a1):not(#a2) .match-board .match-rail .match-rail-section button,
  html:not(#a1):not(#a2) .match-board.is-rail-collapsed .match-rail .match-rail-section button,
  html:not(#a1):not(#a2) .match-board .match-rail .match-mine-link,
  html:not(#a1):not(#a2) .match-board.is-rail-collapsed .match-rail .match-mine-link,
  html:not(#a1):not(#a2) .risk-board .risk-rail-item,
  html:not(#a1):not(#a2) .risk-board.is-rail-collapsed .risk-rail-item,
  html:not(#a1):not(#a2) .risk-platform-list .risk-rail-item {
    justify-content: flex-start !important;
    padding-left: 14.5px !important;
    padding-right: 10px !important;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.16s var(--aibuy-spring) !important;
  }

  html:not(#a1):not(#a2) .match-board.is-rail-collapsed .match-rail .match-rail-section button,
  html:not(#a1):not(#a2) .match-board.is-rail-collapsed .match-rail .match-mine-link,
  html:not(#a1):not(#a2) .risk-board.is-rail-collapsed .risk-rail-item {
    padding-right: 0 !important;
    gap: 0 !important;
  }

  /* Keep the icon itself rock-solid and never shrink/shift */
  html:not(#a1):not(#a2) .match-board .match-rail .match-rail-section button > svg:not(.match-category-chevron),
  html:not(#a1):not(#a2) .match-board .match-rail .match-platform-icon,
  html:not(#a1):not(#a2) .match-board .match-rail .match-mine-link > svg,
  html:not(#a1):not(#a2) .risk-board .risk-rail-item > svg {
    flex: 0 0 16px !important;
    width: 16px !important;
    height: 16px !important;
    transform: none !important;
  }

  /* Align top brand icon on the exact same vertical axis (14.5 - 1 = 13.5px for 18px brand icon) */
  html:not(#a1):not(#a2) .match-board .match-rail-brand,
  html:not(#a1):not(#a2) .risk-board .risk-rail-brand {
    left: 13.5px !important;
    transition: opacity 0.18s ease, transform 0.34s var(--aibuy-spring), visibility 0s !important;
  }

  /* AI 比价库: rail inner = 57px when collapsed, icon = 22px -> 6 + 11.5 = 17.5px ALWAYS */
  html:not(#a1):not(#a2) .directory-workspace-deals .price-workspace > .price-category-column {
    transition: width 0.36s var(--aibuy-spring), box-shadow 0.32s ease !important;
  }

  html:not(#a1):not(#a2) .directory-workspace-deals .price-category-column .price-categories,
  html:not(#a1):not(#a2) .directory-workspace-deals .price-workspace.is-rail-collapsed .price-categories {
    padding-left: 6px !important;
    padding-right: 6px !important;
    transition: none !important;
  }

  html:not(#a1):not(#a2) .directory-workspace-deals .price-category-column .price-category-option,
  html:not(#a1):not(#a2) .directory-workspace-deals .price-workspace.is-rail-collapsed .price-category-option {
    justify-content: flex-start !important;
    padding-left: 11.5px !important;
    padding-right: 10px !important;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.16s var(--aibuy-spring) !important;
  }

  html:not(#a1):not(#a2) .directory-workspace-deals .price-workspace.is-rail-collapsed .price-category-option {
    padding-right: 0 !important;
    gap: 0 !important;
  }

  html:not(#a1):not(#a2) .directory-workspace-deals .price-category-column .price-category-option > :is(svg, img) {
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    transform: none !important;
  }

  html:not(#a1):not(#a2) .directory-workspace-deals .price-category-column .price-rail-brand {
    left: 19.5px !important;
  }

  /* Smooth fade/clip for rail text labels */
  html:not(#a1):not(#a2) .match-board .match-rail .match-rail-label,
  html:not(#a1):not(#a2) .risk-board .risk-rail-item-label,
  html:not(#a1):not(#a2) .directory-workspace-deals .price-category-column .price-category-option > span:not(.price-count) {
    transition: max-width 0.36s var(--aibuy-spring), opacity 0.18s ease !important;
  }

  /* Ensure detail panes can host lightweight transition overlays cleanly */
  .match-detail,
  .risk-detail,
  .price-quotes {
    position: relative;
  }
}

/* Remove category headings inside self-operated offers list (flat product list) */
.price-quotes .price-self-group-heading {
  display: none !important;
}

/* Keep self-operated timestamps compact on one line without colliding */
.price-offer-row .price-offer-update,
.price-offer-row .price-offer-update time {
  white-space: nowrap;
}

/* Keep docked comment composer strictly ABOVE sliding detail content at all times */
.match-detail > .match-detail-scroll,
.risk-detail > .risk-detail-scroll {
  position: relative;
  z-index: 1;
}

.match-detail > .match-comment-slot,
.risk-detail > .match-comment-slot,
.risk-detail > .risk-comment-slot {
  z-index: 30 !important;
}

/* ==========================================================================
   2. TRUE FULL-HEIGHT SHORT-VIDEO VERTICAL REEL (Portal on body, 0 React DOM touch)
   ========================================================================== */
.aibuy-reel-viewport-lock {
  overflow: hidden !important;
}

.aibuy-reel-portal {
  position: fixed;
  z-index: 25;
  pointer-events: none;
  overflow: hidden;
  contain: layout style paint;
}

.aibuy-reel-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.aibuy-reel-slide {
  flex: 0 0 auto;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--ui-surface, var(--card, #fff));
  border-bottom: 1px solid color-mix(in srgb, var(--ui-line, #d7e1da) 65%, transparent);
}

.aibuy-reel-slide.is-spacer {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 18px;
  padding: 32px 34px;
  background: var(--ui-surface, var(--card, #fff));
}

.aibuy-reel-spacer-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aibuy-reel-spacer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ui-text, #23392d) 9%, transparent);
  flex: none;
}

.aibuy-reel-spacer-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aibuy-reel-spacer-line {
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ui-text, #23392d) 8%, transparent);
}

.aibuy-reel-spacer-line.is-title {
  width: 62%;
  height: 20px;
  margin-top: 6px;
  background: color-mix(in srgb, var(--ui-text, #23392d) 12%, transparent);
}

.aibuy-reel-spacer-line.is-w90 { width: 92%; }
.aibuy-reel-spacer-line.is-w78 { width: 78%; }
.aibuy-reel-spacer-line.is-w45 { width: 45%; }

.aibuy-reel-spacer-block {
  height: 150px;
  border-radius: 14px;
  margin-top: 6px;
  background: color-mix(in srgb, var(--ui-text, #23392d) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--ui-line, #d7e1da) 55%, transparent);
}

/* ==========================================================================
   3. PUBLISH COMPOSER & WHOLE-SITE SILKY MOTION
   ========================================================================== */
@keyframes aibuy-view-lift {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes aibuy-dialog-pop {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes aibuy-backdrop-fade {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes aibuy-spin-smooth {
  to {
    transform: rotate(360deg);
  }
}

/* Smooth page entrances */
html:not(.theme-revealing) .legal-page,
html:not(.theme-revealing) .about-page,
html:not(.theme-revealing) .account-page,
html:not(.theme-revealing) .submission-page,
html:not(.theme-revealing) .messages-page,
html:not(.theme-revealing) .user-profile-page {
  animation: aibuy-view-lift 0.38s var(--aibuy-spring) both;
}

/* Publish composer & dialogs spring pop-in */
html:not(.theme-revealing) .abc-sheet,
html:not(.theme-revealing) .shop-submit-dialog,
html:not(.theme-revealing) [role="dialog"]:not(.abc-sheet),
html:not(.theme-revealing) .share-dialog,
html:not(.theme-revealing) .report-sheet-panel {
  animation: aibuy-dialog-pop 0.34s var(--aibuy-spring) both;
  will-change: transform, opacity, height;
}

html:not(.theme-revealing) .abc-backdrop,
html:not(.theme-revealing) .mobile-drawer-backdrop,
html:not(.theme-revealing) .user-profile-dialog-backdrop {
  animation: aibuy-backdrop-fade 0.24s ease both;
}

/* Publish Step 1 two-option buttons tactile hover & press */
html:not(.theme-revealing) .abc-side-btn {
  transition:
    transform 0.2s var(--aibuy-spring),
    border-color 0.2s var(--aibuy-spring),
    background-color 0.2s var(--aibuy-spring),
    box-shadow 0.24s var(--aibuy-spring) !important;
}

html:not(.theme-revealing) .abc-side-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -14px rgba(24, 58, 42, 0.22);
}

html:not(.theme-revealing) .abc-side-btn:active {
  transform: translateY(0) scale(0.982);
}

/* Silky hover & tactile press micro-interactions across the entire site */
html:not(.theme-revealing) .directory-nav-tab,
html:not(.theme-revealing) .button,
html:not(.theme-revealing) .directory-topbar .account-link,
html:not(.theme-revealing) .directory-topbar .header-nav-link,
html:not(.theme-revealing) .directory-topbar .theme-toggle,
html:not(.theme-revealing) .directory-side-item,
html:not(.theme-revealing) .match-category-button,
html:not(.theme-revealing) .price-spec-option,
html:not(.theme-revealing) .abc-seg button,
html:not(.theme-revealing) .abc-chip,
html:not(.theme-revealing) .abc-tool {
  transition:
    background-color 0.2s var(--aibuy-spring),
    border-color 0.2s var(--aibuy-spring),
    color 0.2s var(--aibuy-spring),
    transform 0.16s var(--aibuy-spring),
    box-shadow 0.22s var(--aibuy-spring);
}

/* NEVER shrink list items or category buttons on press — keep 100% full size like native short-video swipe */
html:not(.theme-revealing) .button:active:not(:disabled),
html:not(.theme-revealing) .directory-nav-tab:active,
html:not(.theme-revealing) .abc-seg button:active,
html:not(.theme-revealing) .abc-chip:active,
html:not(.theme-revealing) .abc-tool:active {
  transform: scale(0.985);
}

html:not(.theme-revealing) .price-category-option:active,
html:not(.theme-revealing) .price-spec-option:active,
html:not(.theme-revealing) .match-item:active,
html:not(.theme-revealing) .risk-item:active,
html:not(.theme-revealing) .match-rail-section button:active,
html:not(.theme-revealing) .risk-rail-item:active,
html:not(.theme-revealing) .directory-side-item:active {
  transform: none !important;
}

/* Subtle silky card hover & press */
html:not(.theme-revealing) .directory-card,
html:not(.theme-revealing) .match-item,
html:not(.theme-revealing) .risk-item,
html:not(.theme-revealing) .price-offer-card {
  transition:
    transform 0.22s var(--aibuy-spring),
    border-color 0.2s var(--aibuy-spring),
    box-shadow 0.24s var(--aibuy-spring),
    background-color 0.18s ease;
}

html:not(.theme-revealing) .directory-card:hover {
  transform: translateY(-2px);
}

html:not(.theme-revealing) .directory-card:active {
  transform: scale(0.992);
}

/* Smooth SVG/ring spinner polish */
.aibuy-motion-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 24%, transparent);
  border-top-color: currentColor;
  animation: aibuy-spin-smooth 0.68s linear infinite;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .legal-page,
  .about-page,
  .account-page,
  .submission-page,
  .messages-page,
  .user-profile-page,
  .abc-sheet,
  .shop-submit-dialog,
  [role="dialog"],
  .share-dialog,
  .report-sheet-panel,
  .abc-backdrop,
  .mobile-drawer-backdrop,
  .user-profile-dialog-backdrop {
    animation: none !important;
  }
}
