/* ==========================================================================
   GSTInvoice Animations & Micro-Interactions Suite
   Engineered for modern, high-conversion SaaS aesthetics
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. SHARED COMPONENT UTILITIES & THEME TOKENS
   -------------------------------------------------------------------------- */
:root {
  --color-brand: #635bff;
  --color-brand-hover: #5248e5;
  --color-brand-soft: #f0efff;
  --color-brand-border: #d9d6fe;
  --color-charcoal: #1f2937;
  --color-muted: #6b7280;
  --color-surface: #f8f9fc;
}

.text-brand { color: #635bff !important; }
.text-brand-hover { color: #5248e5 !important; }
.hover\:text-brand:hover { color: #635bff !important; }
.bg-brand { background-color: #635bff !important; }
.bg-brand-hover { background-color: #5248e5 !important; }
.hover\:bg-brand-hover:hover { background-color: #5248e5 !important; }
.bg-brand-soft { background-color: #f0efff !important; }
.border-brand { border-color: #635bff !important; }
.border-brand-border { border-color: #d9d6fe !important; }
.text-charcoal { color: #1f2937 !important; }
.text-muted { color: #6b7280 !important; }
.bg-surface { background-color: #f8f9fc !important; }

/* Sticky header helper */
#site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: block;
}

/* --------------------------------------------------------------------------
   1. KEYFRAME DEFINITIONS
   -------------------------------------------------------------------------- */

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(-0.5deg);
  }
}

@keyframes floatReverse {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(10px) rotate(0.6deg);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.35;
    transform: scale(1);
    filter: blur(28px);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.08);
    filter: blur(36px);
  }
}

@keyframes shimmerSweep {
  0% {
    transform: translateX(-150%) skewX(-20deg);
  }
  25%, 100% {
    transform: translateX(250%) skewX(-20deg);
  }
}

@keyframes badgeLivePulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(18, 183, 106, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0);
  }
}

@keyframes subtleSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes borderGlowPulse {
  0%, 100% {
    border-color: rgba(99, 91, 255, 0.2);
    box-shadow: 0 10px 25px -5px rgba(99, 91, 255, 0.1);
  }
  50% {
    border-color: rgba(99, 91, 255, 0.6);
    box-shadow: 0 20px 35px -5px rgba(99, 91, 255, 0.25);
  }
}

/* --------------------------------------------------------------------------
   2. FLOATING & AMBIENT UTILITIES
   -------------------------------------------------------------------------- */

.animate-float-slow {
  animation: floatSlow 6s ease-in-out infinite;
  will-change: transform;
}

.animate-float-reverse {
  animation: floatReverse 7s ease-in-out infinite;
  will-change: transform;
}

.animate-glow-pulse {
  animation: pulseGlow 5s ease-in-out infinite;
  will-change: transform, opacity;
}

.pulse-live-dot {
  animation: badgeLivePulse 2.2s infinite;
}

.highlight-pulse-card {
  animation: borderGlowPulse 4s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   3. SCROLL REVEAL SYSTEM (INTERSECTION OBSERVER)
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-left {
  opacity: 0;
  transform: translateX(-36px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-right {
  opacity: 0;
  transform: translateX(36px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.is-visible,
.reveal-left.is-visible,
.reveal-right.is-visible,
.reveal-scale.is-visible {
  opacity: 1;
  transform: translate(0) scale(1);
}

/* Stagger Delay Helpers */
.delay-100 { transition-delay: 100ms; }
.delay-150 { transition-delay: 150ms; }
.delay-200 { transition-delay: 200ms; }
.delay-250 { transition-delay: 250ms; }
.delay-300 { transition-delay: 300ms; }
.delay-400 { transition-delay: 400ms; }
.delay-500 { transition-delay: 500ms; }

/* --------------------------------------------------------------------------
   4. BUTTON & CARD MICRO-INTERACTIONS
   -------------------------------------------------------------------------- */

/* Shimmer Button Sweep */
.btn-shimmer {
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.35) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmerSweep 4.5s ease-in-out infinite;
  pointer-events: none;
}

.btn-shimmer:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -6px rgba(99, 91, 255, 0.35);
}

.btn-shimmer:active {
  transform: scale(0.97) translateY(0);
}

/* Interactive Card Hover */
.card-interactive {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s ease;
  will-change: transform, box-shadow;
}

.card-interactive:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.12),
              0 8px 16px -8px rgba(99, 91, 255, 0.1);
  border-color: rgba(99, 91, 255, 0.4);
}

.card-interactive:hover .icon-bounce {
  transform: scale(1.15) rotate(4deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-bounce {
  transition: transform 0.3s ease;
}

/* Accordion Smooth Reveal */
details summary {
  user-select: none;
  transition: color 0.2s ease;
}

details[open] summary svg {
  transform: rotate(180deg);
}

details[open] p {
  animation: fadeInDown 0.35s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   5. ACCESSIBILITY: REDUCED MOTION PREFERENCE
   -------------------------------------------------------------------------- */

@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;
  }
  .reveal, .reveal-left, .reveal-right, .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* --------------------------------------------------------------------------
   PAGE LOADER (CSS-only overlay; components.js adds html.page-ready)
   Fails safe: hides itself after 8s even if a script never runs.
   -------------------------------------------------------------------------- */
@keyframes loaderSpin { to { transform: rotate(360deg); } }
@keyframes loaderFailsafe { to { opacity: 0; visibility: hidden; } }

body::before,
body::after {
  content: '';
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
body::before {
  inset: 0;
  background: #ffffff url('images/optimized/brand/logo.webp') no-repeat center calc(50% - 28px);
  background-size: 168px auto;
  animation: loaderFailsafe 0.3s ease 8s forwards;
}
body::after {
  top: calc(50% + 20px);
  left: calc(50% - 16px);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--color-brand-soft);
  border-top-color: var(--color-brand);
  animation: loaderSpin 0.8s linear infinite, loaderFailsafe 0.3s ease 8s forwards;
}
html.page-ready body::before,
html.page-ready body::after {
  opacity: 0;
  visibility: hidden;
}

/* --------------------------------------------------------------------------
   MOBILE MENU — fade/slide on open & close (JS toggles [hidden], .is-open, .is-closing)
   -------------------------------------------------------------------------- */
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@keyframes menuOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-8px); }
}
#mobile-menu.is-open { animation: menuIn 0.22s ease-out; }
#mobile-menu.is-closing { animation: menuOut 0.18s ease-in forwards; pointer-events: none; }

/* --------------------------------------------------------------------------
   MODAL DIALOGS (demo video & image zoom)
   -------------------------------------------------------------------------- */
html.dialog-open { overflow: hidden; }

.site-dialog {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: 0;
  background: transparent;
  overflow: auto;
}
.site-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.site-dialog::backdrop {
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(3px);
}
.site-dialog__panel {
  position: relative;
  animation: dialogIn 0.22s ease-out;
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.site-dialog__close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--color-charcoal);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.3);
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}
.site-dialog__close:hover { color: var(--color-brand); transform: scale(1.06); }
.site-dialog__close:focus-visible { outline: 3px solid var(--color-brand-border); outline-offset: 2px; }
.site-dialog__close svg { width: 20px; height: 20px; }

/* Demo video: 16:9, as wide as fits */
.site-dialog--video .site-dialog__panel { width: min(960px, 100%); }
.site-dialog__video {
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.site-dialog__video video,
.site-dialog__video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Image zoom: fit the viewport, up to 2× the file's own size */
.site-dialog__figure { margin: 0; text-align: center; }
.site-dialog__figure img {
  display: block;
  width: min(calc(100vw - 32px), calc(var(--nw) * 2px), calc((100dvh - 96px) * var(--ratio)));
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.site-dialog__figure figcaption {
  margin-top: 12px;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.4;
}
img.zoomable { cursor: zoom-in; }
img.zoomable:focus-visible { outline: 3px solid var(--color-brand); outline-offset: 3px; }

@media (max-width: 640px) {
  .site-dialog { padding: 12px; }
  .site-dialog__close { top: -12px; right: -6px; width: 36px; height: 36px; }
  .site-dialog__figure img { width: min(calc(100vw - 24px), calc(var(--nw) * 2px), calc((100dvh - 88px) * var(--ratio))); }
}

@media (prefers-reduced-motion: reduce) {
  .site-dialog__panel, #mobile-menu { animation: none !important; }
}

/* In-page view switch (login ↔ forgot password) */
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
[data-view].view-enter { animation: viewEnter 0.25s ease-out; }
@media (prefers-reduced-motion: reduce) {
  [data-view].view-enter { animation: none; }
}

/* --------------------------------------------------------------------------
   HERO MOCKUP (index) — below lg the mockups stack under the text, so the
   phone scales with the laptop instead of a fixed 190–210px that overlapped the CTAs
   -------------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  .hero-mockup { padding-top: 2.5rem; }
  .hero-phone {
    width: 32% !important;
    min-width: 118px;
    right: -6px !important;
    bottom: -1.5rem !important;
    padding: 5px !important;
    border-width: 2px !important;
    border-radius: 22px !important;
  }
  .hero-phone > div { border-radius: 17px !important; }
  .hero-phone > div > div:first-child { width: 34% !important; height: 9px !important; top: 6px !important; }
}
@media (min-width: 1024px) and (max-width: 1279.98px) {
  .hero-phone { right: -0.75rem !important; }
}

/* --------------------------------------------------------------------------
   READ MORE / READ LESS (ul[data-collapse] — see components.js)
   -------------------------------------------------------------------------- */
ul.is-collapsed > .collapse-extra { display: none; }
ul[data-collapse]:not(.is-collapsed) > .collapse-extra { animation: viewEnter 0.25s ease-out; }
/* Expanded list scrolls inside the card instead of stretching it */
ul[data-collapse-bound]:not(.is-collapsed):has(> .collapse-extra) {
  max-height: 22rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-brand-border) transparent;
}
ul[data-collapse-bound]:not(.is-collapsed)::-webkit-scrollbar { display: block; width: 6px; }
ul[data-collapse-bound]:not(.is-collapsed)::-webkit-scrollbar-thumb { background: var(--color-brand-border); border-radius: 3px; }
ul[data-collapse-bound] + .list-toggle { margin-top: -0.75rem; }
.list-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1.5rem;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-brand);
  background: none;
  border: 0;
  cursor: pointer;
}
.list-toggle:hover { color: var(--color-brand-hover); text-decoration: underline; }
.list-toggle:focus-visible { outline: 2px solid var(--color-brand-border); outline-offset: 3px; border-radius: 4px; }
.list-toggle svg { width: 16px; height: 16px; transition: transform 0.2s ease; }
.list-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   AI BACKGROUND (ai-innovations.html) — circuit pattern + neural-network canvas
   (canvas animated by assets/js/ai-background.js)
   -------------------------------------------------------------------------- */
.ai-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.ai-bg canvas { position: absolute; inset: 0; display: block; }
.ai-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-size: 180px 180px;
}
/* Light sections: indigo circuit traces, strongest behind the visuals (right), fading out behind the text */
.ai-bg--light::before {
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none' stroke='%23635bff' stroke-width='1.2'%3E%3Cpath d='M0 45h45l22 22h46M113 67v45l22 22h45M22 180v-45l22-22h34M180 22h-34L124 0M78 113H56M146 22v34l-18 18'/%3E%3Ccircle cx='113' cy='67' r='3.5'/%3E%3Ccircle cx='78' cy='113' r='3.5'/%3E%3Ccircle cx='146' cy='22' r='3'/%3E%3Ccircle cx='128' cy='74' r='2.5' fill='%23635bff'/%3E%3Ccircle cx='45' cy='45' r='2.5' fill='%23635bff'/%3E%3C/svg%3E");
}
.ai-bg--light {
  -webkit-mask-image: radial-gradient(ellipse 70% 85% at 78% 50%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 70% 85% at 78% 50%, #000 25%, transparent 78%);
}
/* Indigo band: white traces, faded towards the centred text */
.ai-bg--dark::before {
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none' stroke='%23ffffff' stroke-width='1.2'%3E%3Cpath d='M0 45h45l22 22h46M113 67v45l22 22h45M22 180v-45l22-22h34M180 22h-34L124 0M78 113H56M146 22v34l-18 18'/%3E%3Ccircle cx='113' cy='67' r='3.5'/%3E%3Ccircle cx='78' cy='113' r='3.5'/%3E%3Ccircle cx='146' cy='22' r='3'/%3E%3Ccircle cx='128' cy='74' r='2.5' fill='%23ffffff'/%3E%3Ccircle cx='45' cy='45' r='2.5' fill='%23ffffff'/%3E%3C/svg%3E");
}
.ai-bg--dark {
  -webkit-mask-image: radial-gradient(ellipse 60% 120% at 50% 50%, transparent 30%, #000 85%);
  mask-image: radial-gradient(ellipse 60% 120% at 50% 50%, transparent 30%, #000 85%);
}
/* Phones: text and visuals stack, so keep the effect soft everywhere */
@media (max-width: 1023.98px) {
  .ai-bg--light {
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.35) 35%, #000 70%);
    mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.35) 35%, #000 70%);
  }
}
/* Content sections: network shows around the edges, the middle stays clear for text and cards */
.ai-bg--soft { opacity: 0.85; }
.ai-bg--soft::before {
  opacity: 0.11;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none' stroke='%23635bff' stroke-width='1.2'%3E%3Cpath d='M0 45h45l22 22h46M113 67v45l22 22h45M22 180v-45l22-22h34M180 22h-34L124 0M78 113H56M146 22v34l-18 18'/%3E%3Ccircle cx='113' cy='67' r='3.5'/%3E%3Ccircle cx='78' cy='113' r='3.5'/%3E%3Ccircle cx='146' cy='22' r='3'/%3E%3Ccircle cx='128' cy='74' r='2.5' fill='%23635bff'/%3E%3Ccircle cx='45' cy='45' r='2.5' fill='%23635bff'/%3E%3C/svg%3E");
}
.ai-bg--soft {
  -webkit-mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,0.25) 22%, transparent 38%, transparent 62%, rgba(0,0,0,0.25) 78%, #000 100%);
  mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,0.25) 22%, transparent 38%, transparent 62%, rgba(0,0,0,0.25) 78%, #000 100%);
}
@media (max-width: 1023.98px) {
  .ai-bg--soft { opacity: 0.5; -webkit-mask-image: none; mask-image: none; }
}
