/* 
  Sawariya Solution - Custom Premium Animations and Styles
  Consolidates toast notifications, cursor ambient glow, ripple transition, and 3D tilts.
*/

/* 1. Global Button Active Press Feedback */
button:active, 
a.btn:active, 
.btn-interactive:active, 
.btn-pulse:active,
[role="button"]:active {
  transform: scale(0.95) !important;
  transition: transform 0.1s ease-out !important;
}

/* 2. Custom Modern Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-success {
  background-color: #0040a1; /* Primary brand blue */
  border-left: 4px solid #F7A400; /* Gold highlight */
}

.toast-error {
  background-color: #ba1a1a; /* Error red */
  border-left: 4px solid #ffdad6;
}

.toast-info {
  background-color: #0a192f; /* Deep navy */
  border-left: 4px solid #b2c5ff;
}

/* 3. Ambient Glow Cursor Follower */
#ambient-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 86, 210, 0.15) 0%, rgba(247, 164, 0, 0.05) 55%, transparent 70%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              height 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              background 0.5s ease;
  will-change: left, top;
}

.dark #ambient-glow {
  background: radial-gradient(circle, rgba(0, 86, 210, 0.25) 0%, rgba(247, 164, 0, 0.08) 55%, transparent 70%);
}

#ambient-glow.hovering {
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(247, 164, 0, 0.22) 0%, rgba(0, 86, 210, 0.1) 60%, transparent 75%);
}

/* 4. 3D Card Perspective Tilt Effect */
.tilt-card {
  transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1), 
              box-shadow 0.3s ease, 
              border-color 0.3s ease;
  transform-style: preserve-3d;
  perspective: 1000px;
  will-change: transform;
}

.tilt-card-inner {
  transform: translateZ(24px);
  transform-style: preserve-3d;
}

/* 5. Circular Ripple Theme Switch Animation */
.theme-ripple-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9998;
  pointer-events: none;
  background-color: var(--ripple-bg, #0b0f19);
  clip-path: circle(0% at var(--ripple-x, 50%) var(--ripple-y, 50%));
  transition: clip-path 0.75s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: clip-path;
}

.theme-ripple-overlay.active {
  clip-path: circle(150% at var(--ripple-x, 50%) var(--ripple-y, 50%));
}

/* 6. Neural Link Particle Network Canvas */
#neural-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.22;
  transition: opacity 0.5s ease;
}

.dark #neural-canvas {
  opacity: 0.12;
}

/* 7. Headline Text Particle Scatter */
.particle-letter {
  display: inline-block;
  position: relative;
  transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), 
              opacity 0.8s ease;
  will-change: transform, opacity;
  cursor: default;
}

/* 8. Magnetic Hover Buttons */
.magnetic-btn {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

/* 9. Scroll-Driven Liquid SVG progress indicator */
.liquid-progress-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 60px;
  height: 60px;
  z-index: 9999;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 86, 210, 0.2));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.liquid-progress-container:hover {
  transform: scale(1.1);
}

.liquid-progress-container svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.liquid-progress-bg {
  fill: rgba(0, 64, 161, 0.1);
  stroke: rgba(0, 64, 161, 0.2);
  stroke-width: 2;
  transition: fill 0.3s, stroke 0.3s;
}

.dark .liquid-progress-bg {
  fill: rgba(255, 255, 255, 0.05);
  stroke: rgba(255, 255, 255, 0.1);
}

.liquid-progress-fill {
  fill: #0040a1; /* Primary Brand Blue */
  transition: fill 0.3s;
}

.dark .liquid-progress-fill {
  fill: #b2c5ff; /* Light primary */
}

/* 10. Cyberpunk Grid Background Overlay */
.cyber-grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, rgba(0, 86, 210, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 86, 210, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.8;
}

.dark .cyber-grid-overlay {
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
}

/* 11. Seamless Infinite Marquee Styles */
.marquee-container {
  display: flex;
  overflow: hidden;
  width: 100%;
  position: relative;
  mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 25s linear infinite;
  will-change: transform;
}

.marquee-track:hover {
  animation-play-state: paused;
}

.marquee-content {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.marquee-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 64px; /* Uniform spacing */
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.marquee-logo-link:hover {
  transform: scale(1.08) !important;
}

.marquee-logo {
  height: 88px !important;
  width: auto !important;
  max-width: 240px;
  object-fit: contain !important;
}

@keyframes marquee-scroll {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

/* ============================================
   12. Custom Cursor (disabled — using default)
   ============================================ */


/* ============================================
   13. Neon Glitch Hover Effect on Tilt Cards
   ============================================ */
.tilt-card {
  position: relative;
  overflow: hidden;
}

.tilt-card::before,
.tilt-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  border-radius: inherit;
  transition: opacity 0.15s ease;
}

.tilt-card::before {
  background: linear-gradient(
    135deg,
    rgba(0, 86, 210, 0.08) 0%,
    rgba(247, 164, 0, 0.06) 50%,
    rgba(0, 86, 210, 0.08) 100%
  );
  mix-blend-mode: screen;
}

.tilt-card::after {
  box-shadow: inset 0 0 0 1.5px rgba(0, 86, 210, 0.3),
              0 0 20px rgba(0, 86, 210, 0.1);
}

.dark .tilt-card::after {
  box-shadow: inset 0 0 0 1.5px rgba(178, 197, 255, 0.25),
              0 0 25px rgba(178, 197, 255, 0.08);
}

.tilt-card:hover::before {
  opacity: 1;
  animation: glitch-flicker 0.35s steps(4) 1;
}

.tilt-card:hover::after {
  opacity: 1;
  animation: neon-border-pulse 1.5s ease-in-out infinite;
}

@keyframes glitch-flicker {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  20% {
    opacity: 0.8;
    transform: translate(-2px, 1px);
    background: linear-gradient(135deg, rgba(255, 50, 50, 0.06) 0%, rgba(50, 50, 255, 0.06) 100%);
  }
  40% {
    opacity: 0.5;
    transform: translate(2px, -1px);
    background: linear-gradient(135deg, rgba(50, 255, 50, 0.06) 0%, rgba(255, 50, 255, 0.06) 100%);
  }
  60% {
    opacity: 0.9;
    transform: translate(-1px, 2px);
    background: linear-gradient(135deg, rgba(50, 50, 255, 0.06) 0%, rgba(255, 255, 50, 0.06) 100%);
  }
  80% {
    opacity: 0.3;
    transform: translate(1px, -2px);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0);
    background: linear-gradient(135deg, rgba(0, 86, 210, 0.08) 0%, rgba(247, 164, 0, 0.06) 50%, rgba(0, 86, 210, 0.08) 100%);
  }
}

@keyframes neon-border-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* ============================================
   14. Staggered Word-by-Word Text Reveal
   ============================================ */
.reveal-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(22px) rotateX(15deg);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

/* Preserve spaces between words */
.reveal-word + .reveal-word {
  margin-left: 0.3em;
}

.revealed .reveal-word {
  opacity: 1;
  transform: translateY(0) rotateX(0deg);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .reveal-word {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .tilt-card::before,
  .tilt-card::after {
    animation: none !important;
  }
}

/* ============================================
   15. Custom Branded Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #0040a1, #0056d2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #0056d2, #F7A400);
}

.dark ::-webkit-scrollbar-track,
html.dark::-webkit-scrollbar-track {
  background: #0b0f19;
}

.dark ::-webkit-scrollbar-thumb,
html.dark::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b2c5ff, #0056d2);
}

.dark ::-webkit-scrollbar-thumb:hover,
html.dark::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #F7A400, #b2c5ff);
}

/* Firefox scrollbar */
html {
  scrollbar-width: thin;
  scrollbar-color: #0040a1 #f0f0f0;
  scroll-behavior: smooth;
}

html.dark {
  scrollbar-color: #b2c5ff #0b0f19;
}

/* ============================================
   16. Custom Text Selection Colors
   ============================================ */
::selection {
  background-color: #0040a1;
  color: #F7A400;
}

::-moz-selection {
  background-color: #0040a1;
  color: #F7A400;
}

.dark ::selection {
  background-color: #F7A400;
  color: #0a192f;
}

.dark ::-moz-selection {
  background-color: #F7A400;
  color: #0a192f;
}

/* ============================================
   17. Page Load Preloader
   ============================================ */
#page-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf8ff;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

html.dark #page-preloader {
  background: #0b0f19;
}

#page-preloader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: preloader-pulse 1.2s ease-in-out infinite;
}

html.dark .preloader-logo {
  filter: brightness(0) invert(1);
}

@keyframes preloader-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

/* ============================================
   18. Smooth Page Transition Overlay
   ============================================ */
#page-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99998;
  background: #faf8ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

html.dark #page-transition-overlay {
  background: #0b0f19;
}

#page-transition-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   19. Active Nav Link Indicator
   ============================================ */
.nav-link-active {
  color: var(--color-primary, #0040a1) !important;
  position: relative;
}

.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-primary, #0040a1);
  border-radius: 1px;
}

html.dark .nav-link-active {
  color: var(--color-primary-fixed-dim, #b2c5ff) !important;
}

html.dark .nav-link-active::after {
  background: var(--color-primary-fixed-dim, #b2c5ff);
}

/* ============================================
   20. Branded Focus Ring Styles (Accessibility)
   ============================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid #0040a1;
  outline-offset: 3px;
  border-radius: 4px;
}

html.dark a:focus-visible,
html.dark button:focus-visible,
html.dark input:focus-visible,
html.dark textarea:focus-visible,
html.dark select:focus-visible,
html.dark [role="button"]:focus-visible {
  outline-color: #F7A400;
}

/* ============================================
   21. Mobile & Tablet Device Compatibility
   ============================================ */

/* --- Touch devices: disable mouse-dependent effects --- */
@media (hover: none) and (pointer: coarse) {
  /* Hide ambient glow (no cursor on touch) */
  #ambient-glow {
    display: none !important;
  }

  /* Disable 3D tilt on cards (needs mouse) */
  .tilt-card {
    transform: none !important;
    perspective: none;
    transform-style: flat;
  }

  /* Disable magnetic buttons (needs mouse) */
  .magnetic-btn {
    transform: none !important;
  }

  /* Disable particle scatter on headlines (needs mouse) */
  .particle-letter {
    transform: none !important;
    opacity: 1 !important;
  }

  /* Disable glitch hover (needs hover) */
  .tilt-card::before,
  .tilt-card::after {
    display: none !important;
  }

  /* Reduce neural canvas opacity on mobile for performance */
  #neural-canvas {
    opacity: 0.08 !important;
  }

  /* Smaller liquid progress on mobile */
  .liquid-progress-container {
    width: 44px;
    height: 44px;
    bottom: 16px;
    left: 16px;
  }
}

/* --- Small screens (phones) --- */
@media (max-width: 640px) {
  /* Smaller toasts on mobile */
  #toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    padding: 10px 16px;
    font-size: 0.85rem;
    gap: 8px;
    border-radius: 10px;
  }

  /* Smaller preloader logo */
  .preloader-logo {
    width: 60px;
    height: 60px;
  }

  /* Reduce liquid progress size */
  .liquid-progress-container {
    width: 40px;
    height: 40px;
    bottom: 12px;
    left: 12px;
  }

  /* Simpler reveal animation for mobile performance */
  .reveal-word {
    transform: translateY(12px);
    transition-duration: 0.35s;
  }

  /* Reduce scrollbar width */
  ::-webkit-scrollbar {
    width: 4px;
  }
}

/* --- Medium screens (tablets) --- */
@media (min-width: 641px) and (max-width: 1024px) {
  .preloader-logo {
    width: 70px;
    height: 70px;
  }

  .liquid-progress-container {
    width: 50px;
    height: 50px;
  }

  ::-webkit-scrollbar {
    width: 6px;
  }
}

/* --- Landscape phones --- */
@media (max-height: 500px) and (orientation: landscape) {
  #page-preloader {
    padding: 20px;
  }

  .preloader-logo {
    width: 50px;
    height: 50px;
  }

  .liquid-progress-container {
    display: none;
  }
}

/* --- High performance mode for low-end devices --- */
@media (max-width: 640px) and (hover: none) {
  /* Hide canvas completely on small touch devices for battery */
  #neural-canvas {
    display: none !important;
  }

  /* Disable cyberpunk grid overlay */
  .cyber-grid-overlay {
    display: none !important;
  }

  /* Simpler transitions for better scroll performance */
  .reveal-word {
    transition-duration: 0.25s;
    transform: translateY(10px) rotateX(0deg);
  }

  /* Disable text particle scatter completely */
  .particle-letter {
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
}

/* --- Print styles --- */
@media print {
  #ambient-glow,
  #neural-canvas,
  .cyber-grid-overlay,
  .liquid-progress-container,
  #page-preloader,
  #page-transition-overlay,
  #toast-container {
    display: none !important;
  }

  .reveal-word,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

