/**
 * Grapphen Theme - Additional CSS
 * Animations, Components, Enhancements
 */

/* ============================================================
   CUSTOM KEYFRAME ANIMATIONS
   ============================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

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

@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { transform: scale(1.05); }
  70%  { transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(79,70,229,0.4); }
  50%       { box-shadow: 0 0 40px rgba(79,70,229,0.7); }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   FLOATING ELEMENTS
   ============================================================ */
.float-element {
  animation: float 4s ease-in-out infinite;
}

.float-element-reverse {
  animation: floatReverse 4s ease-in-out infinite;
}

.float-delay-1 { animation-delay: 0.5s; }
.float-delay-2 { animation-delay: 1s; }
.float-delay-3 { animation-delay: 1.5s; }

/* ============================================================
   SHIMMER / LOADING STATES
   ============================================================ */
.shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ============================================================
   GRADIENT ANIMATED TEXT
   ============================================================ */
.animated-gradient-text {
  background: linear-gradient(270deg, #4f46e5, #7c3aed, #9333ea, #4f46e5);
  background-size: 300% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

/* ============================================================
   GLOW BUTTON VARIANT
   ============================================================ */
.btn-glow {
  animation: glow 2s ease-in-out infinite;
}

/* ============================================================
   COUNTER ANIMATION
   ============================================================ */
.counter {
  display: inline-block;
  animation: countUp 0.5s ease forwards;
}

/* ============================================================
   SCROLL PROGRESS BAR
   ============================================================ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gradient-primary);
  z-index: 9999;
  width: 0%;
  transition: width 0.1s linear;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 360px;
}

.toast {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  border-left: 4px solid var(--color-primary);
  animation: slideInRight 0.3s ease;
  transition: all 0.3s ease;
}

.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-error); }
.toast.warning { border-left-color: var(--color-warning); }

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--color-gray-700);
  line-height: var(--leading-relaxed);
  font-weight: var(--font-medium);
}

.toast-close {
  margin-left: auto;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--color-gray-400);
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-gray-900);
  color: var(--color-white);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ============================================================
   ACCORDION / FAQ IMPROVEMENTS
   ============================================================ */
.faq-item.open .faq-question {
  color: var(--color-primary);
}

/* ============================================================
   FEATURE TAB NAVIGATION
   ============================================================ */
.feature-tab-link.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary) !important;
}

.feature-tab-link:hover {
  color: var(--color-primary);
  background: var(--color-primary-50);
}

/* ============================================================
   PIPELINE HOVER EFFECTS
   ============================================================ */
.pipeline-stage {
  position: relative;
  overflow: hidden;
}

.pipeline-stage::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform var(--transition-base);
}

.pipeline-stage:hover::before {
  transform: scaleX(1);
}

/* ============================================================
   CARD HOVER GRADIENT OVERLAY
   ============================================================ */
.card-hover-gradient {
  position: relative;
  overflow: hidden;
}

.card-hover-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: inherit;
  pointer-events: none;
}

.card-hover-gradient:hover::after {
  opacity: 1;
}

/* ============================================================
   HERO PARTICLE EFFECTS
   ============================================================ */
.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
  animation: float 6s ease-in-out infinite;
}

.particle:nth-child(1) { width: 200px; height: 200px; top: 10%; left: 5%; background: #4f46e5; animation-delay: 0s; }
.particle:nth-child(2) { width: 150px; height: 150px; top: 60%; right: 10%; background: #7c3aed; animation-delay: 1s; }
.particle:nth-child(3) { width: 100px; height: 100px; bottom: 20%; left: 15%; background: #9333ea; animation-delay: 2s; }
.particle:nth-child(4) { width: 80px;  height: 80px;  top: 30%; right: 25%; background: #4f46e5; animation-delay: 0.5s; animation-direction: reverse; }
.particle:nth-child(5) { width: 60px;  height: 60px;  top: 80%; left: 40%; background: #7c3aed; animation-delay: 1.5s; }

/* ============================================================
   MOBILE MENU IMPROVEMENTS
   ============================================================ */
@media (max-width: 768px) {
  .mobile-nav.open {
    transform: translateX(0);
    display: block;
  }

  .mobile-nav ul li a {
    font-size: var(--text-base);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-xl);
  }

  .mobile-nav ul li a:hover {
    padding-left: calc(var(--space-5) + 0.375rem);
  }
}

/* ============================================================
   STICKY HEADER IMPROVEMENTS
   ============================================================ */
.site-header .header-inner {
  transition: all var(--transition-base);
}

.site-header.scrolled .header-inner {
  /* Slight padding adjustment when scrolled */
}

/* ============================================================
   FORM IMPROVEMENTS
   ============================================================ */
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.form-group.has-error .form-control {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error-text {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: 0.375rem;
  font-weight: var(--font-medium);
}

.form-group.has-success .form-control {
  border-color: var(--color-success);
}

/* ============================================================
   BUTTON LOADING STATE
   ============================================================ */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ============================================================
   IMAGE LAZY LOAD EFFECT
   ============================================================ */
img.lazy {
  opacity: 0;
  transition: opacity var(--transition-slow);
}

img.lazy.loaded {
  opacity: 1;
}

/* ============================================================
   HIGHLIGHT / MARK
   ============================================================ */
mark {
  background: linear-gradient(120deg, rgba(79,70,229,0.15) 0%, rgba(124,58,237,0.15) 100%);
  color: inherit;
  padding: 0.1em 0.2em;
  border-radius: 0.15em;
}

/* ============================================================
   BLOG POST CONTENT IMPROVEMENTS
   ============================================================ */
.post-content-body {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-gray-700);
}

.post-content-body h2 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-gray-900);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}

.post-content-body h3 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-gray-900);
  margin: 2rem 0 0.875rem;
}

.post-content-body p {
  margin-bottom: 1.5rem;
  font-size: var(--text-lg);
  line-height: 1.8;
  color: var(--color-gray-700);
}

.post-content-body ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-content-body ol {
  list-style: decimal;
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-content-body li {
  margin-bottom: 0.625rem;
  font-size: var(--text-lg);
  color: var(--color-gray-700);
  line-height: 1.7;
}

.post-content-body blockquote {
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-50);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  margin: 2rem 0;
}

.post-content-body blockquote p {
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--color-primary-700);
  margin: 0;
}

.post-content-body a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

.post-content-body a:hover {
  color: var(--color-primary-dark);
}

.post-content-body img {
  border-radius: var(--radius-xl);
  margin: 2rem auto;
  box-shadow: var(--shadow-lg);
}

.post-content-body code {
  background: var(--color-gray-100);
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

.post-content-body pre {
  background: var(--color-gray-900);
  color: #e2e8f0;
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  overflow-x: auto;
  margin: 2rem 0;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.post-content-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.post-content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: var(--text-base);
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.post-content-body th {
  background: var(--color-gray-50);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: var(--font-semibold);
  color: var(--color-gray-700);
  border-bottom: 2px solid var(--color-gray-200);
}

.post-content-body td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-gray-100);
  color: var(--color-gray-600);
}

.post-content-body tr:last-child td { border-bottom: none; }

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-gray-400);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--color-gray-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--color-primary); }

.breadcrumb-sep {
  color: var(--color-gray-300);
}

.breadcrumb span:last-child {
  color: var(--color-gray-600);
  font-weight: var(--font-medium);
}

/* ============================================================
   SECTION DIVIDERS
   ============================================================ */
.section-wave {
  overflow: hidden;
  line-height: 0;
  shape-rendering: auto;
}

.section-wave svg {
  display: block;
  width: 100%;
}

/* ============================================================
   GRADIENT BORDERS
   ============================================================ */
.border-gradient {
  position: relative;
  border-radius: var(--radius-2xl);
}

.border-gradient::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--gradient-primary);
  border-radius: calc(var(--radius-2xl) + 2px);
  z-index: -1;
}

/* ============================================================
   SKIP TO CONTENT LINK (Accessibility)
   ============================================================ */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 var(--radius-lg) 0;
}

.skip-to-content:focus {
  top: 0;
}

/* ============================================================
   FOCUS VISIBLE
   ============================================================ */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

/* ============================================================
   PRINT IMPROVEMENTS
   ============================================================ */
@media print {
  .site-header,
  .site-footer,
  .mobile-nav,
  .cta-section,
  .hero-mockup,
  .integrations-strip,
  [data-aos] { display: none !important; }

  body {
    font-size: 12pt;
    color: black;
  }

  .page-hero {
    background: none;
    padding: 2rem 0;
  }

  .page-hero-title,
  .page-hero-subtitle {
    color: black;
  }

  a { color: black; text-decoration: underline; }
  .card { break-inside: avoid; }
}

/* ============================================================
   HIGH CONTRAST MODE
   ============================================================ */
@media (forced-colors: active) {
  .btn-primary,
  .btn-secondary { forced-color-adjust: none; }
}

/* ============================================================
   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;
  }

  [data-aos] {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .integrations-scroll {
    animation: none !important;
  }
}

/* ============================================================
   DARK MODE SUPPORT (basic)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  /* Only apply dark mode if user has explicitly set it via a class */
  /* Grapphen theme is light by default */
}

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ============================================================
   SELECTION COLOR
   ============================================================ */
::selection {
  background: rgba(79, 70, 229, 0.2);
  color: var(--color-primary-900);
}

::-moz-selection {
  background: rgba(79, 70, 229, 0.2);
  color: var(--color-primary-900);
}
