/* ============================================================
   Cloudly Landing — Matching the Cloudly App Design System
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* --- Theme Custom Properties (from Cloudly globals.css) --- */
:root {
  --background: oklch(0.97 0.005 270);
  --foreground: oklch(0.25 0.02 270);

  --card: oklch(0.99 0.002 270 / 0.6);
  --card-foreground: oklch(0.25 0.02 270);

  --primary: oklch(0.55 0.2 260);
  --primary-foreground: oklch(0.96 0.005 270);

  --secondary: oklch(0.94 0.01 270 / 0.5);
  --secondary-foreground: oklch(0.25 0.02 270);

  --muted: oklch(0.94 0.008 270 / 0.5);
  --muted-foreground: oklch(0.46 0.02 270);

  --accent: oklch(0.94 0.01 270 / 0.55);
  --accent-foreground: oklch(0.25 0.02 270);

  --border: oklch(0.88 0.01 270 / 0.5);
  --input: oklch(0.92 0.008 270 / 0.5);
  --ring: oklch(0.55 0.2 260 / 0.4);

  --glass-bg: oklch(0.99 0.002 270 / 0.55);
  --glass-border: oklch(1 0 0 / 0.5);
  --glass-border-bottom: oklch(0.7 0.01 270 / 0.2);
  --glass-highlight: oklch(1 0 0 / 0.6);
  --glass-shadow: oklch(0.5 0.02 270 / 0.08);
  --glass-blur: 20px;

  --primary-15: oklch(0.55 0.2 260 / 0.15);

  --mesh-1: oklch(0.82 0.12 280);
  --mesh-2: oklch(0.85 0.09 220);
  --mesh-3: oklch(0.88 0.07 340);
  --mesh-4: oklch(0.86 0.08 160);

  --radius: 0.875rem;
}

[data-theme="dark"] {
  --background: oklch(0.35 0.02 270);
  --foreground: oklch(0.95 0.005 270);

  --card: oklch(0.22 0.02 270 / 0.45);
  --card-foreground: oklch(0.95 0.005 270);

  --primary: oklch(0.7 0.17 260);
  --primary-foreground: oklch(0.15 0.02 270);

  --secondary: oklch(0.28 0.02 270 / 0.5);
  --secondary-foreground: oklch(0.95 0.005 270);

  --muted: oklch(0.28 0.02 270 / 0.5);
  --muted-foreground: oklch(0.65 0.015 270);

  --accent: oklch(0.3 0.025 270 / 0.5);
  --accent-foreground: oklch(0.95 0.005 270);

  --border: oklch(0.4 0.02 270 / 0.4);
  --input: oklch(0.35 0.02 270 / 0.4);
  --ring: oklch(0.7 0.17 260 / 0.4);

  --glass-bg: oklch(0.2 0.02 270 / 0.4);
  --glass-border: oklch(0.5 0.02 270 / 0.25);
  --glass-border-bottom: oklch(0.1 0.01 270 / 0.3);
  --glass-highlight: oklch(0.6 0.02 270 / 0.12);
  --glass-shadow: oklch(0.05 0.02 270 / 0.4);
  --glass-blur: 24px;

  --primary-15: oklch(0.7 0.17 260 / 0.15);

  --mesh-1: oklch(0.24 0.08 280);
  --mesh-2: oklch(0.2 0.06 220);
  --mesh-3: oklch(0.22 0.06 340);
  --mesh-4: oklch(0.21 0.06 160);
}

/* --- Body --- */
body {
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.5s ease, color 0.3s ease;
}

/* --- Mesh Background (matching Cloudly's .mesh-background) --- */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, var(--mesh-1) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 25%, var(--mesh-2) 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 50% 85%, var(--mesh-3) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 20% 65%, var(--mesh-4) 0%, transparent 50%),
    var(--background);
  transition: background 0.5s ease;
}

/* --- Glass Surface (matching Cloudly's .glass-surface) --- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-bottom-color: var(--glass-border-bottom);
  border-right-color: var(--glass-border-bottom);
  box-shadow:
    0 2px 16px -2px var(--glass-shadow),
    inset 0 1px 0 0 var(--glass-highlight);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 1120px;
  z-index: 100;
  border-radius: calc(var(--radius) + 4px);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--foreground);
}

.nav-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--primary-15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--primary);
  flex-shrink: 0;
}

.nav-logo span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* --- Theme Toggle Switch --- */
@keyframes knobToRight {
  0% { transform: translateX(3px) scale(1); }
  40% { transform: translateX(13px) scale(1.15, 0.85); }
  70% { transform: translateX(25px) scale(0.95, 1.05); }
  100% { transform: translateX(23px) scale(1); }
}
@keyframes knobToLeft {
  0% { transform: translateX(23px) scale(1); }
  40% { transform: translateX(13px) scale(1.15, 0.85); }
  70% { transform: translateX(1px) scale(0.95, 1.05); }
  100% { transform: translateX(3px) scale(1); }
}
@keyframes iconIn {
  0% { opacity: 0; transform: rotate(90deg) scale(0.3); }
  100% { opacity: 1; transform: rotate(0deg) scale(1); }
}
@keyframes iconOut {
  0% { opacity: 1; transform: rotate(0deg) scale(1); }
  100% { opacity: 0; transform: rotate(-90deg) scale(0.3); }
}

.theme-toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  background: color-mix(in srgb, var(--primary) 25%, transparent);
  cursor: pointer;
  padding: 0;
  transition: background-color 400ms ease;
  flex-shrink: 0;
}

.theme-toggle-switch:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

[data-theme="dark"] .theme-toggle-switch {
  background: var(--primary);
}

.toggle-knob {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: oklch(0.97 0.005 270);
  box-shadow: 0 1px 3px oklch(0.2 0.02 270 / 0.15);
  transform: translateX(3px);
  pointer-events: none;
}

.toggle-knob .toggle-icon-sun,
.toggle-knob .toggle-icon-moon {
  position: absolute;
}

/* Light mode: sun visible, moon hidden */
.toggle-icon-sun {
  opacity: 1;
}
.toggle-icon-moon {
  opacity: 0;
}

[data-theme="dark"] .toggle-icon-sun {
  opacity: 0;
}
[data-theme="dark"] .toggle-icon-moon {
  opacity: 1;
}

/* Animation classes applied by JS */
.toggle-knob.animate-to-dark {
  animation: knobToRight 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toggle-knob.animate-to-dark .toggle-icon-sun {
  animation: iconOut 300ms ease forwards;
}
.toggle-knob.animate-to-dark .toggle-icon-moon {
  animation: iconIn 300ms ease 150ms forwards;
}

.toggle-knob.animate-to-light {
  animation: knobToLeft 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toggle-knob.animate-to-light .toggle-icon-sun {
  animation: iconIn 300ms ease 150ms forwards;
}
.toggle-knob.animate-to-light .toggle-icon-moon {
  animation: iconOut 300ms ease forwards;
}

/* Static positions (no animation) */
[data-theme="dark"] .toggle-knob:not(.animate-to-dark):not(.animate-to-light) {
  transform: translateX(23px);
}
[data-theme="light"] .toggle-knob:not(.animate-to-dark):not(.animate-to-light),
:root:not([data-theme]) .toggle-knob:not(.animate-to-dark):not(.animate-to-light) {
  transform: translateX(3px);
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 160px 24px 60px;
  cursor: grab;
}

.hero:active {
  cursor: grabbing;
}

.hero-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 20px;
}

.hero-title {
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--foreground);
  max-width: 820px;
  margin-bottom: 28px;
  transition: transform 0.2s ease-out;
  transform-style: preserve-3d;
}

.hero-title .accent {
  color: var(--primary);
}

.hero-body {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--muted-foreground);
  max-width: 640px;
  margin-bottom: 36px;
}

/* --- Buttons --- */
.hero-ctas {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 28px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: calc(var(--radius) + 4px);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 4px 20px oklch(0.55 0.2 260 / 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px oklch(0.55 0.2 260 / 0.35);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.btn-secondary:hover {
  background: var(--accent);
}

/* --- Stats --- */
.stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

.stat-card,
.feature-card {
  transition: transform 0.2s ease;
}

.stat-card:hover,
.feature-card:hover {
  transform: translateY(-3px);
}

.stat-card {
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  padding: 28px 24px;
  text-align: left;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--muted-foreground);
}

/* --- Features --- */
.features {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 100px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.feature-card {
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  padding: 36px 32px;
}

.feature-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--foreground);
}

.feature-card p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--muted-foreground);
}

/* --- How It Works --- */
.how-it-works {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 100px;
}

.how-it-works > h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 600px;
  margin-bottom: 48px;
}

.steps {
  display: flex;
  flex-direction: column;
}

.step-card {
  position: sticky;
  overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  padding: 36px 32px;
  margin-bottom: 24px;
  will-change: transform, filter;
  transform-origin: center top;
  transition: filter 0.15s ease-out;
  box-shadow: none;
}

.steps .step-card.glass {
  box-shadow: none;
}

.step-card:nth-child(1) { top: 100px; z-index: 1; }
.step-card:nth-child(2) { top: 132px; z-index: 2; }
.step-card:nth-child(3) { top: 164px; z-index: 3; }
.step-card:nth-child(4) { top: 196px; z-index: 4; }
.step-card:nth-child(5) { top: 228px; z-index: 5; margin-bottom: 0; }

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  background: oklch(0.55 0.2 260 / 0.12);
  color: var(--primary);
  margin-bottom: 20px;
}

.step-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--foreground);
}

.step-card p {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--muted-foreground);
}

/* --- Bottom CTA --- */
.cta-section {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 100px;
}

.cta-card {
  border-radius: calc(var(--radius) + 8px);
  padding: 80px 48px;
  text-align: center;
  overflow: hidden;
}

.cta-card h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 640px;
  margin: 0 auto 20px;
}

.cta-card p {
  font-size: 1.05rem;
  color: var(--muted-foreground);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

/* --- Scroll Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--delay, 0s);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal.visible.stat-card:hover,
.reveal.visible.feature-card:hover {
  transform: translateY(-3px);
}

.reveal:not(.visible) {
  transition-delay: 0s;
}

/* --- Mouse Tilt --- */
.tilt-card {
  position: relative;
  transform-style: preserve-3d;
  cursor: grab;
}


.tilt-card:active {
  cursor: grabbing;
}

.step-card.tilt-card { position: sticky; }

.step-reveal {
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--delay, 0s);
}

.step-reveal.visible {
  opacity: 1;
}

.step-reveal:not(.visible) {
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .step-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .tilt-card {
    transform: none !important;
  }
  .step-card {
    position: relative !important;
    transform: none !important;
    filter: none !important;
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav {
    top: 10px;
    width: calc(100% - 24px);
  }

  .nav-inner {
    padding: 12px 18px;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a {
    display: none;
  }

  .hero {
    padding: 130px 20px 40px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .stats {
    grid-template-columns: 1fr;
    padding: 20px 20px 60px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .step-card:nth-child(1) { top: 72px; }
  .step-card:nth-child(2) { top: 88px; }
  .step-card:nth-child(3) { top: 104px; }
  .step-card:nth-child(4) { top: 120px; }
  .step-card:nth-child(5) { top: 136px; }

  .cta-card {
    padding: 48px 24px;
  }

  .footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.7rem;
  }

  .hero-ctas {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}
