/**
 * VELARIS V5 BENCHO-INSPIRED INTERACTION SYSTEM (v5-interactions.css)
 * -------------------------------------------------------------------
 * Performance-first progressive enhancement layer.
 * Zero external CSS libraries. Consumes existing VELARIS luxury tokens.
 * -------------------------------------------------------------------
 */

:root {
  --motion-fast: 140ms;
  --motion-normal: 260ms;
  --motion-slow: 380ms;
  --ease-velaris: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===================================================================
   1. DYNAMIC ISLAND (Mobile-first Transactional Status Pill)
   =================================================================== */
.v5-dynamic-island {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px) scale(0.92);
  z-index: 9999;
  background: rgba(13, 13, 12, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  font-family: var(--font-display, 'Montserrat', sans-serif);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--motion-normal) var(--ease-spring),
              opacity var(--motion-normal) ease,
              border-radius var(--motion-normal) var(--ease-velaris),
              padding var(--motion-normal) var(--ease-velaris);
  user-select: none;
  will-change: transform, opacity;
}

.v5-dynamic-island.is-active {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.v5-dynamic-island-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.v5-dynamic-island.state-success .v5-dynamic-island-icon {
  background: #00ffaa;
  color: #000;
}

.v5-dynamic-island.state-pending .v5-dynamic-island-icon {
  background: #ffaa00;
  color: #000;
  animation: v5-island-spin 1s linear infinite;
}

.v5-dynamic-island.state-error .v5-dynamic-island-icon {
  background: #ff4444;
  color: #fff;
}

.v5-dynamic-island-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.v5-dynamic-island-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v5-dynamic-island-sub {
  font-size: 11px;
  color: var(--text-muted, #8e8d8a);
  font-family: var(--font-body, 'Roboto', sans-serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

/* Expanded state (on click or rich event) */
.v5-dynamic-island.is-expanded {
  border-radius: 20px;
  padding: 14px 20px;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-width: 290px;
}

.v5-dynamic-island.is-expanded .v5-dynamic-island-sub {
  display: block;
}

.v5-dynamic-island-actions {
  display: none;
  gap: 8px;
  margin-top: 4px;
}

.v5-dynamic-island.is-expanded .v5-dynamic-island-actions {
  display: flex;
}

.v5-dynamic-island-btn {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: #fff;
  color: #000;
  font-family: var(--font-display, 'Montserrat', sans-serif);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--motion-fast);
}

.v5-dynamic-island-btn:hover {
  background: #e0e0e0;
}

.v5-dynamic-island-btn.secondary {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes v5-island-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===================================================================
   2. FLOATING LABEL EMAIL INPUT (Bencho Label Input Pattern)
   =================================================================== */
.v5-floating-field {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}

.v5-floating-input {
  width: 100%;
  height: 54px;
  padding: 20px 16px 6px 16px;
  background: var(--surface-card, #0d0d0c);
  border: 1px solid var(--border-crisp, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-body, 'Roboto', sans-serif);
  font-size: 14.5px;
  outline: none;
  transition: border-color var(--motion-normal) var(--ease-velaris),
              background-color var(--motion-normal) var(--ease-velaris);
  box-sizing: border-box;
}

.v5-floating-input:focus {
  border-color: rgba(255, 255, 255, 0.45);
  background: var(--surface-elevated, #141413);
}

.v5-floating-label {
  position: absolute;
  top: 17px;
  left: 16px;
  color: var(--text-muted, #8e8d8a);
  font-family: var(--font-display, 'Montserrat', sans-serif);
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: none;
  transition: transform var(--motion-normal) var(--ease-velaris),
              font-size var(--motion-normal) var(--ease-velaris),
              color var(--motion-normal) var(--ease-velaris),
              top var(--motion-normal) var(--ease-velaris);
  transform-origin: left top;
}

.v5-floating-input:focus ~ .v5-floating-label,
.v5-floating-input:not(:placeholder-shown) ~ .v5-floating-label,
.v5-floating-input.has-value ~ .v5-floating-label {
  top: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffaa00;
}

/* ===================================================================
   3. NOW PLAYING & INTERACTIVE VIDEO CONTROLS
   =================================================================== */
.v5-video-interactive-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.v5-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--motion-normal) ease, transform var(--motion-normal) var(--ease-spring);
  pointer-events: none;
  z-index: 4;
}

.v5-play-badge svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
  fill: currentColor;
}

.v5-video-interactive-wrap:hover .v5-play-badge,
.v5-video-interactive-wrap.is-paused .v5-play-badge {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.v5-video-interactive-wrap.is-playing .v5-play-badge {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
}

/* Time Scrubber (Bencho Time Scrubber Pattern) */
.v5-time-scrubber {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  display: flex;
  align-items: flex-end;
  cursor: pointer;
  z-index: 5;
  padding: 0 4px;
}

.v5-scrubber-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  position: relative;
  overflow: visible;
  transition: height var(--motion-fast) ease;
}

.v5-time-scrubber:hover .v5-scrubber-track {
  height: 6px;
}

.v5-scrubber-progress {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  position: relative;
  transition: width 0.05s linear;
}

.v5-scrubber-handle {
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
  transition: transform var(--motion-fast) var(--ease-spring);
}

.v5-time-scrubber:hover .v5-scrubber-handle {
  transform: translateY(-50%) scale(1);
}

/* ===================================================================
   4. PRODUCT CARD ASSET SWAP (Poster <-> Short Muted Video Preview)
   =================================================================== */
.v5-asset-swap-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.v5-asset-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--motion-normal) ease, transform 0.4s ease;
  z-index: 1;
}

.v5-asset-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--motion-normal) ease;
  z-index: 2;
  pointer-events: none;
}

.v5-asset-swap-container.is-previewing .v5-asset-video {
  opacity: 1;
  pointer-events: auto;
}

.v5-asset-swap-container.is-previewing .v5-asset-poster {
  opacity: 0;
}

/* Mobile preview badge */
.v5-asset-preview-btn {
  display: none;
}

@media (max-width: 768px) {
  .v5-asset-preview-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 20px;
    padding: 6px 12px;
    color: #fff;
    font-family: var(--font-display, 'Montserrat', sans-serif);
    font-size: 11px;
    font-weight: 700;
    z-index: 3;
    cursor: pointer;
  }
}

/* ===================================================================
   5. INLINE CONFIRMATION (Bencho Inline Confirm Pattern)
   =================================================================== */
.v5-inline-confirm-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--surface-elevated, #141413);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-family: var(--font-display, 'Montserrat', sans-serif);
  font-size: 11.5px;
  animation: v5-fade-in var(--motion-fast) ease;
}

.v5-inline-confirm-text {
  color: var(--text-muted, #8e8d8a);
  font-weight: 500;
}

.v5-inline-confirm-btn {
  padding: 4px 8px;
  border-radius: 4px;
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.v5-inline-confirm-btn.btn-yes {
  background: #ff4444;
  color: #fff;
}

.v5-inline-confirm-btn.btn-no {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ===================================================================
   6. PULL-TO-REFRESH (Purchases / Drawer Mobile Indicator)
   =================================================================== */
.v5-ptr-indicator {
  height: 0px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display, 'Montserrat', sans-serif);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted, #8e8d8a);
  transition: height var(--motion-fast) ease;
}

.v5-ptr-indicator.is-pulling {
  height: 48px;
}

.v5-ptr-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: v5-island-spin 0.8s linear infinite;
}

/* ===================================================================
   7. TILT CARD (Subtle 3D Luxury Tilt for Desktop)
   =================================================================== */
@media (min-width: 1025px) {
  .v5-tilt-enabled {
    transform-style: preserve-3d;
    transition: transform var(--motion-fast) ease-out, border-color 0.2s;
    will-change: transform;
  }
}

/* ===================================================================
   8. UNIFIED NOTIFICATIONS SYSTEM (Notify Pattern)
   =================================================================== */
.v5-toast-container {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.v5-toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 380px;
  background: rgba(13, 13, 12, 0.94);
  border: 1px solid var(--border-crisp, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display, 'Montserrat', sans-serif);
  font-size: 13px;
  color: #fff;
  transform: translateY(-20px);
  opacity: 0;
  animation: v5-toast-in var(--motion-normal) var(--ease-spring) forwards;
}

.v5-toast.is-leaving {
  animation: v5-toast-out var(--motion-fast) ease forwards;
}

@keyframes v5-toast-in {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes v5-toast-out {
  to { transform: translateY(-16px); opacity: 0; }
}

@keyframes v5-fade-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===================================================================
   9. REDUCED MOTION SAFEGUARD
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .v5-dynamic-island {
    transition: none !important;
  }
  .v5-tilt-enabled {
    transform: none !important;
  }
}
