/* ---- CSS Custom Properties ---- */
:root {
  --color-brand: #2563eb;
  --color-brand-dark: #1a2e4a;
  --color-accent: #f97316;
  --color-surface: #f8fafc;
  --color-surface-alt: #f1f5f9;
  --radius-card: 1.25rem;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 8px 32px rgba(37,99,235,0.1), 0 2px 8px rgba(0,0,0,0.04);
}

html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; color: #0f172a; }

/* ---- FAQ accordion ---- */
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.faq-answer.open { max-height: 500px; transition: max-height 0.5s ease-in; }
.faq-chevron { transition: transform 0.3s ease; }
.faq-chevron.open { transform: rotate(180deg); }

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }
.animation-delay-200 { animation-delay: 0.2s; opacity: 0; }
.animation-delay-400 { animation-delay: 0.4s; opacity: 0; }
.animation-delay-600 { animation-delay: 0.6s; opacity: 0; }

/* ---- Mobile menu ---- */
.mobile-menu { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.mobile-menu.open { max-height: 400px; }

/* ---- Form focus ---- */
input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* ---- Demo styles ---- */
.demo-dropzone {
  border: 1px solid rgba(59,130,246,0.2);
  background: rgba(59,130,246,0.02);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.02), 0 10px 30px rgba(0,0,0,0.03);
  transition: border-color 0.3s, background-color 0.3s, transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}
.demo-dropzone:hover {
  transform: scale(1.01);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.02), 0 14px 36px rgba(0,0,0,0.05);
  border-color: rgba(59,130,246,0.35);
}
.demo-dropzone::after {
  content: '\0905';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Noto Sans Devanagari', sans-serif;
  font-size: 180px;
  opacity: 0.02;
  color: var(--color-brand-dark);
  pointer-events: none;
  z-index: 0;
}
.demo-dropzone > * { position: relative; z-index: 1; }
.demo-dropzone.drag-over { border-color: #2563eb; background-color: #eff6ff; transform: scale(1.01); }
.demo-dropzone.has-file { border-color: #22c55e; background-color: #f0fdf4; }

.demo-progress-track { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.demo-progress-fill {
  height: 100%; border-radius: 3px; transition: width 0.4s ease; width: 0%;
  background: linear-gradient(90deg, #2563eb 0%, #3b82f6 40%, #60a5fa 50%, #3b82f6 60%, #2563eb 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.demo-step { opacity: 0.4; transition: opacity 0.3s; }
.demo-step.active { opacity: 1; }
.demo-step.done { opacity: 1; }

@keyframes pulse-slow { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse-slow { animation: pulse-slow 2s ease-in-out infinite; }

.demo-toggle div, .demo-toggle-orange div {
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.demo-toggle div:hover, .demo-toggle-orange div:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.demo-toggle input:checked + div { border-color: #2563eb; background-color: #eff6ff; color: #1a2e4a; box-shadow: 0 2px 8px rgba(37,99,235,0.12); }
.demo-toggle-orange input:checked + div { border-color: #f97316; background-color: #fff7ed; color: #9a3412; box-shadow: 0 2px 8px rgba(249,115,22,0.12); }

.try-free-gradient {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 30%, #faf5ff 60%, #fff7ed 100%);
}
.paper-texture-bg {
  background-image: radial-gradient(circle, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

.demo-card {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06), 0 12px 40px rgba(37,99,235,0.08);
  transition: box-shadow 0.3s ease;
  background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
  position: relative;
}
.demo-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  border-radius: inherit;
  opacity: 0.3;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}
.demo-card:hover {
  box-shadow: 0 20px 48px -12px rgba(37, 99, 235, 0.18), 0 4px 8px -2px rgba(0,0,0,0.05);
}

@keyframes confetti-pop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.animate-confetti-pop { animation: confetti-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes step-check { 0% { transform: scale(0); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.demo-step.done .step-check { animation: step-check 0.3s ease forwards; }

/* ---- Hero gradient text ---- */
.hero-gradient-text {
  background: linear-gradient(135deg, #1a2e4a, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Hero background depth ---- */
.hero-glow {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: radial-gradient(60% 45% at 50% 40%, rgba(59,130,246,0.08), transparent);
  pointer-events: none;
  z-index: 1;
}
.hero-grain {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  opacity: 0.28;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}


/* ---- Floating Devanagari characters (pseudo-elements avoid LCP candidacy) ---- */
@keyframes float-1 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(5deg); }
}
@keyframes float-2 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(-3deg); }
}
@keyframes float-3 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-25px) rotate(4deg); }
}
#hero::before, #hero::after, #hero > .max-w-7xl::before {
  position: absolute;
  font-family: 'Noto Sans Devanagari', sans-serif;
  opacity: 0.03;
  color: var(--color-brand-dark);
  pointer-events: none;
  user-select: none;
}
#hero::before {
  content: "\0905";
  font-size: 200px;
  top: 10%; left: 5%;
  animation: float-1 20s ease-in-out infinite;
}
#hero::after {
  content: "\0906";
  font-size: 160px;
  top: 60%; right: 8%;
  animation: float-2 25s ease-in-out infinite 2s;
}
#hero > .max-w-7xl::before {
  content: "\0908";
  font-size: 140px;
  bottom: 15%; left: 15%;
  z-index: 0;
  animation: float-3 22s ease-in-out infinite 4s;
}

/* ---- Bento grid ---- */
.bento-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 768px) {
  .bento-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .bento-ocr { grid-column: 1 / 4; grid-row: 1 / 3; }
  .bento-word { grid-column: 4 / 6; grid-row: 1; }
  .bento-excel { grid-column: 4 / 6; grid-row: 2; }
  .bento-translate { grid-column: 1 / 3; grid-row: 3; }
  .bento-ai { grid-column: 3 / 6; grid-row: 3; }
  .bento-secure { grid-column: 1 / 6; grid-row: 4; }
}
.bento-cell {
  border-radius: var(--radius-card);
  padding: 2rem;
  border: 1px solid rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.bento-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(37,99,235,0.15);
}

/* ---- Pipeline ---- */
.pipeline-line {
  height: 2px;
  background-image: repeating-linear-gradient(90deg, var(--color-brand) 0, var(--color-brand) 8px, transparent 8px, transparent 16px);
  background-size: 16px 2px;
}
.pipeline-line.animate-flow {
  animation: pipeline-flow 1s linear infinite;
}
@keyframes pipeline-flow { to { background-position: 16px 0; } }

/* ---- Scroll animations ---- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.animate-on-scroll.animate-visible {
  opacity: 1;
  transform: translateY(0);
}
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.stagger-children.animate-visible > * { opacity: 1; transform: translateY(0); }
.stagger-children.animate-visible > *:nth-child(1) { transition-delay: 0s; }
.stagger-children.animate-visible > *:nth-child(2) { transition-delay: 0.08s; }
.stagger-children.animate-visible > *:nth-child(3) { transition-delay: 0.16s; }
.stagger-children.animate-visible > *:nth-child(4) { transition-delay: 0.24s; }
.stagger-children.animate-visible > *:nth-child(5) { transition-delay: 0.32s; }
.stagger-children.animate-visible > *:nth-child(6) { transition-delay: 0.4s; }

/* ---- FAQ left border accent ---- */
.faq-item { border-left: 3px solid transparent; transition: border-color 0.3s ease; }
.faq-item.faq-open { border-left-color: var(--color-brand); }

/* ---- SSE Progress: Ring animations ---- */
@keyframes ring-enter {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.ring-enter {
  animation: ring-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ring-spin {
  0%   { transform: rotate(-90deg); }
  100% { transform: rotate(270deg); }
}
.ring-indeterminate svg {
  animation: ring-spin 1.4s linear infinite;
}
.ring-indeterminate .ring-progress {
  stroke-dasharray: 69 207; /* ~25% of 276 visible */
}
.ring-determinate svg {
  animation: none;
  transform: rotate(-90deg);
}
.ring-determinate .ring-progress {
  transition: stroke-dashoffset 0.6s ease-out, stroke 0.3s ease;
}

/* ---- SSE Progress: Thumbnail animations ---- */
@keyframes demo-thumb-enter {
  0%   { opacity: 0; transform: scale(0.85) translateY(10px); }
  100% { opacity: 1; transform: scale(1)    translateY(0);    }
}
.demo-thumb-enter {
  animation: demo-thumb-enter 0.35s ease-out forwards;
}

.demo-thumb-ring {
  transition: stroke-dashoffset 0.5s ease-out, stroke 0.3s ease;
}

/* ---- SSE Progress: Badge and step animations ---- */
@keyframes badge-pop {
  0%   { transform: scale(0);   }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1);   }
}
.badge-pop { animation: badge-pop 0.3s ease forwards; }

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1;   }
}
.phase-label-thinking {
  animation: thinking-pulse 1.5s ease-in-out infinite;
}

.demo-step-connector {
  background-color: #d1d5db;
  transition: background-color 0.3s ease;
}
.demo-step-connector.filled {
  background-color: #22c55e;
}

/* ---- SSE Progress: Spinner ---- */
.spinner {
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  width: 16px; height: 16px;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 24px; height: 24px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- SSE Progress: Dashboard-specific styles ---- */
#conv-thumbnails::-webkit-scrollbar { display: none; }
#conv-thumbnails { -ms-overflow-style: none; scrollbar-width: none; }
#conv-success-thumbnails::-webkit-scrollbar { display: none; }
#conv-success-thumbnails { -ms-overflow-style: none; scrollbar-width: none; }
#conv-error-thumbnails::-webkit-scrollbar { display: none; }
#conv-error-thumbnails { -ms-overflow-style: none; scrollbar-width: none; }

.conv-step { opacity: 0.4; transition: opacity 0.3s; }
.conv-step.active { opacity: 1; }
.conv-step.done { opacity: 1; }
.conv-step.done .step-check { animation: step-check 0.3s ease forwards; }

.conv-step-connector {
  background-color: #d1d5db;
  transition: background-color 0.3s ease;
}
.conv-step-connector.filled {
  background-color: #22c55e;
}

.conv-thumb-ring {
  transition: stroke-dashoffset 0.5s ease-out, stroke 0.3s ease;
}
.conv-thumb-enter {
  animation: demo-thumb-enter 0.35s ease-out forwards;
}

.conv-progress-track { height: 6px; background: #e2e8f0; border-radius: 3px; }
.conv-progress-fill {
  height: 100%; border-radius: 3px; transition: width 0.4s ease; width: 0%;
  background: linear-gradient(90deg, #2563eb, #3b82f6, #60a5fa, #3b82f6, #2563eb);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* ---- Accessibility: respect 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;
  }
  .ring-indeterminate svg { animation: none !important; transform: rotate(-90deg); }
  .ring-indeterminate .ring-progress { stroke-dasharray: 69 207; }
  .demo-thumb-ring { transition: none !important; }
  .ring-determinate .ring-progress { transition: none !important; }
  .badge-pop { animation: none !important; }
  .phase-label-thinking { animation: none !important; }
}
