/* ==========================================================================
   PacsWeb Next-Gen Motion & Ambient Visual System
   Ultra-smooth spring easing, dynamic cursor spotlights, and living glow beams.
   ========================================================================== */

:root {
  --motion-accent: var(--cyan, #38efef);
  --motion-accent-2: var(--blue, #38bdf8);
  --motion-lime: var(--lime, #ccf86c);
  --motion-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --motion-glow-shadow: 0 12px 35px -5px rgba(56, 239, 239, 0.35);
}

/* Base interactive transitions */
@media (prefers-reduced-motion: no-preference) {
  :is(.app-shell, .login-page, .server-dashboard, .server-login-page, .viewer-page) :is(.btn, button, .nav-link, .admin-tabs a, .portal-tab, .window-button, .image-tool, .layout-button, .jalali-trigger, .header-back, .center-entry),
  body :is(.button, .nav-entry, .footer-nav a, .header-links a, .admin-entry, .hero-bottom a) {
    transition: transform 0.32s var(--motion-ease),
                box-shadow 0.32s var(--motion-ease),
                border-color 0.28s var(--motion-ease),
                background-color 0.28s var(--motion-ease),
                color 0.24s var(--motion-ease),
                opacity 0.24s var(--motion-ease) !important;
  }

  body :is(.glass-panel, .glass-card, .hero-panel, .glass-surface, .admin-panel, .panel, .center-card, .stat, .flow-node, .flow-step, .story-card, .info-tile, .portal-form-shell, .architecture-frame, .login-shell, .auth-panel, .auth-visual, .series-card, .migration-card, .hero-copy, .hero-console, .product-module) {
    transition: transform 0.45s var(--motion-ease),
                border-color 0.35s var(--motion-ease),
                background-color 0.35s var(--motion-ease),
                box-shadow 0.45s var(--motion-ease);
  }

  body :is(.brand img, .footer-brand img, .brand-logo, .auth-brand img, .portal-brand img, .viewer-brand-logo) {
    transition: transform 0.45s var(--motion-ease), filter 0.45s var(--motion-ease);
  }

  body :is(.form-control, .form-select, .control, .portal-input input, .auth-input input, .searchbar input, textarea, select):not([type="hidden"]) {
    transition: border-color 0.28s var(--motion-ease),
                box-shadow 0.28s var(--motion-ease),
                background-color 0.28s var(--motion-ease),
                transform 0.28s var(--motion-ease);
  }

  /* Details expansion */
  body :is(details .details-body, details[open] .details-body) {
    animation: motion-unfold 0.35s var(--motion-ease) both;
  }

  @keyframes motion-unfold {
    from { opacity: 0; transform: translateY(-8px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

/* ==========================================================================
   Spotlight & Living Dynamic Glows
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  /* Interactive cursor spotlight surface */
  :is(.glass-card, .hero-panel, .admin-panel, .info-tile, .stat, .login-shell, .portal-form-shell, .hero-console, .product-module, .story-card, .architecture-frame) {
    position: relative;
  }

  :is(.glass-card, .hero-panel, .admin-panel, .info-tile, .stat, .login-shell, .portal-form-shell, .hero-console, .product-module, .story-card, .architecture-frame)::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(
      600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(56, 239, 239, 0.12),
      transparent 60%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 1;
  }

  :is(.glass-card, .hero-panel, .admin-panel, .info-tile, .stat, .login-shell, .portal-form-shell, .hero-console, .product-module, .story-card, .architecture-frame):hover::before {
    opacity: 1;
  }

  /* Soft Ambient Pulse for Hero Panels */
  .hero-panel::after {
    animation: hero-glow-float 10s ease-in-out infinite alternate;
  }

  @keyframes hero-glow-float {
    0% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.6; }
    50% { transform: translate3d(-20px, 15px, 0) scale(1.15); opacity: 0.9; }
    100% { transform: translate3d(15px, -10px, 0) scale(0.95); opacity: 0.7; }
  }

  /* Live Radar Status Indicators */
  .status-pulse,
  .live-status-dot {
    position: relative;
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--motion-accent);
    box-shadow: 0 0 12px var(--motion-accent);
  }

  .status-pulse::after,
  .live-status-dot::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid var(--motion-accent);
    animation: radar-pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  }

  @keyframes radar-pulse {
    0% { transform: scale(0.9); opacity: 1; }
    70% { transform: scale(2.4); opacity: 0; }
    100% { transform: scale(2.6); opacity: 0; }
  }
}

/* ==========================================================================
   Hover & Interactive Micro-Interactions
   ========================================================================== */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  /* Button elevation & aura glow */
  body :is(.btn-primary, .button-primary, .portal-submit):not(:disabled):hover {
    transform: translateY(-2.5px) scale(1.015);
    box-shadow: var(--motion-glow-shadow), 0 0 25px rgba(56, 239, 239, 0.35) !important;
  }

  body :is(.btn-secondary, .btn-outline-light, .button-ghost, .window-button, .layout-button):not(:disabled):hover {
    transform: translateY(-2px);
    border-color: rgba(56, 239, 239, 0.75) !important;
    background-color: rgba(18, 52, 78, 0.72) !important;
    box-shadow: 0 0 20px rgba(56, 239, 239, 0.2) !important;
  }

  /* Glass Card Hover Elevation */
  body :is(.glass-panel, .glass-card, .hero-panel, .admin-panel, .panel, .center-card, .info-tile, .series-card):hover {
    transform: translateY(-4px);
    border-color: rgba(99, 229, 236, 0.45);
    box-shadow: 0 28px 60px -10px rgba(0, 0, 0, 0.6), 0 0 35px rgba(56, 239, 239, 0.15);
  }

  body :is(.brand, .footer-brand, .login-brand, .title-brand):hover img {
    transform: scale(1.03);
    filter: drop-shadow(0 0 24px rgba(56, 239, 239, 0.45));
  }
}

/* Click / Active spring compression */
@media (prefers-reduced-motion: no-preference) {
  body :is(.btn, .button, .nav-entry, .portal-tab, .admin-tabs a, .image-tool, .window-button, .layout-button, .header-back):not(:disabled):active {
    transform: translateY(1px) scale(0.975) !important;
    transition-duration: 0.08s !important;
  }

  /* Form Control Focus Aura */
  body :is(.form-control, .form-select, .control, .portal-input input, .auth-input input, .searchbar input, textarea, select):not([type="hidden"]):focus-visible {
    transform: translateY(-1px);
    border-color: var(--motion-accent) !important;
    box-shadow: 0 0 0 3px rgba(56, 239, 239, 0.22),
                0 0 30px rgba(56, 239, 239, 0.25) !important;
  }
}

/* Accessibility / Reduced Motion */
@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;
  }
}
