/* VG-MOBILE-FX — mobile experience layer styles (viewgems.app)
 * Everything is scoped to mobile widths. Feature styles hang off the
 * html.vgfx-* classes that mobile-fx.js adds only when the layer is
 * active, so with the master switch off (assets not served) or JS dead,
 * nothing here can change the site. */

/* ---- cross-document view transitions (both documents carry the opt-in) ---- */
@media (max-width: 767px) {
  @view-transition { navigation: auto; }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: var(--vgfx-ms, 220ms);
    animation-timing-function: ease-out;
    animation-fill-mode: both;
  }
  ::view-transition-group(vgfx-shared) {
    animation-duration: var(--vgfx-ms, 220ms);
    animation-timing-function: ease-out;
  }

  /* slide style (direction types are set from JS via the Navigation API) */
  html.vgfx-style-slide:active-view-transition-type(forward)::view-transition-old(root) { animation-name: vgfx-slide-out-fwd; }
  html.vgfx-style-slide:active-view-transition-type(forward)::view-transition-new(root) { animation-name: vgfx-slide-in-fwd; }
  html.vgfx-style-slide:active-view-transition-type(back)::view-transition-old(root) { animation-name: vgfx-slide-out-back; }
  html.vgfx-style-slide:active-view-transition-type(back)::view-transition-new(root) { animation-name: vgfx-slide-in-back; }

  /* fade style */
  html.vgfx-style-fade:active-view-transition-type(forward)::view-transition-old(root),
  html.vgfx-style-fade:active-view-transition-type(back)::view-transition-old(root) { animation-name: vgfx-fade-out; }
  html.vgfx-style-fade:active-view-transition-type(forward)::view-transition-new(root),
  html.vgfx-style-fade:active-view-transition-type(back)::view-transition-new(root) { animation-name: vgfx-fade-in; }

  @keyframes vgfx-slide-out-fwd { from { opacity: 1; transform: translateX(0); } to { opacity: .35; transform: translateX(-10%); } }
  @keyframes vgfx-slide-in-fwd  { from { opacity: .35; transform: translateX(10%); } to { opacity: 1; transform: translateX(0); } }
  @keyframes vgfx-slide-out-back { from { opacity: 1; transform: translateX(0); } to { opacity: .35; transform: translateX(10%); } }
  @keyframes vgfx-slide-in-back  { from { opacity: .35; transform: translateX(-10%); } to { opacity: 1; transform: translateX(0); } }
  @keyframes vgfx-fade-out { from { opacity: 1; } to { opacity: 0; } }
  @keyframes vgfx-fade-in  { from { opacity: 0; } to { opacity: 1; } }
}

/* reduced motion: no view transitions at all, whatever the switches say */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

@media (max-width: 767px) {
  html.vgfx-on { -webkit-tap-highlight-color: transparent; }

  /* fallback entry fade for browsers without cross-document transitions
     (opacity only — a transform on body would trap the fixed bottom bar) */
  html.vgfx-enter body { animation: vgfx-fade-in var(--vgfx-ms, 220ms) ease-out; }

  /* ---- native polish ---- */
  html.vgfx-polish a,
  html.vgfx-polish button,
  html.vgfx-polish [role="button"],
  html.vgfx-polish input,
  html.vgfx-polish select,
  html.vgfx-polish textarea,
  html.vgfx-polish label { touch-action: manipulation; }

  html.vgfx-polish body { overscroll-behavior-y: contain; }

  html.vgfx-polish a:active,
  html.vgfx-polish button:active,
  html.vgfx-polish [role="button"]:active { opacity: .85; }
  html.vgfx-polish .btn:active,
  html.vgfx-polish .card:active { transform: scale(.99); }

  /* ---- swipe-to-back affordances (plugin-owned elements only) ---- */
  .vgfx-edge {
    position: fixed; left: 0; top: 18%; height: 64%; width: 24px;
    z-index: 900; touch-action: pan-y; background: transparent;
  }
  .vgfx-chip {
    position: fixed; left: 0; top: 50%; width: 44px; height: 44px;
    margin-top: -22px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(28, 28, 32, .92); color: #fff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; z-index: 950;
    transform: translateX(-60px);
  }
  .vgfx-chip.vgfx-chip-armed { background: #0ea5e9; }
  .vgfx-chip svg { width: 22px; height: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html.vgfx-polish .btn:active,
  html.vgfx-polish .card:active { transform: none; }
  html.vgfx-enter body { animation: none; }
}
