/* Klariton Design Tokens v2.0 — Periwinkle */
:root {
  /* Brand */
  --color-brand: #7C7AF5;
  --color-brand-hover: #9290FF;
  --color-brand-subtle: #1D1B3A;
  --color-brand-border: #3A3870;
  --color-brand-on: #0A0A18;

  /* Backgrounds */
  --color-bg: #0A0A12;
  --color-bg-elevated: #12121E;
  --color-bg-elevated-hi: #181828;
  --color-bg-input: #06060C;
  --color-bg-sidebar: #08080F;
  --color-bg-companion: #0E0E18;

  /* Borders */
  --color-border-strong: #383852;
  --color-border-default: #2A2A40;
  --color-border-subtle: #1E1E2E;

  /* Text */
  --color-text-primary: #E8EFED;
  --color-text-muted: #9AAFAB;
  --color-text-dim: #6B847F;

  /* Semantic */
  --color-danger: #E07A6B;
  --color-danger-bg: #2A1614;
  --color-danger-border: #3A2422;
  --color-warning: #D4A656;
  --color-warning-bg: #2A2417;
  --color-warning-border: #3A3220;
  --color-info: #6BA4D4;
  --color-info-bg: #172A36;
  --color-info-border: #234156;
  --color-success: #6BC9A6;
  --color-success-bg: #14241F;
  --color-success-border: #1F3A30;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 20px;

  /* Shadows */
  --shadow-card: 0 1px 0 0 rgba(255,255,255,0.02), 0 1px 2px 0 rgba(0,0,0,0.4);
  --shadow-drawer: 0 24px 60px -12px rgba(0,0,0,0.6);
  --shadow-modal: 0 30px 80px -20px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 0 1px rgba(124,122,245,0.2), 0 12px 40px -12px rgba(124,122,245,0.4);

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px; --space-24: 96px;
  --space-32: 128px;

  /* Type */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.10em;
  --tracking-widest: 0.18em;
  --tracking-label: 0.12em;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* overflow-x only on <html> — putting it on <body> turns body into the
   scroll container and breaks the sticky header. */
html { overflow-x: hidden; }
body { max-width: 100%; }
body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--color-brand); color: var(--color-brand-on); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-subtle); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-default); }

.font-mono { font-family: var(--font-mono); font-feature-settings: 'tnum' on, 'lnum' on; }
.tabular { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-dim);
  font-weight: 500;
}

/* Typography scale */
.t-hero { font-size: clamp(40px, 5.5vw, 72px); line-height: 1.02; letter-spacing: -0.025em; font-weight: 500; }
.t-mega { font-size: clamp(36px, 4.5vw, 56px); line-height: 1.05; letter-spacing: -0.022em; font-weight: 500; }
.t-display { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 500; }
.t-h2 { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2; letter-spacing: -0.015em; font-weight: 500; }
.t-h3 { font-size: 18px; line-height: 1.35; letter-spacing: -0.01em; font-weight: 500; }
.t-body-lg { font-size: 18px; line-height: 1.55; color: var(--color-text-muted); }
.t-body { font-size: 15px; line-height: 1.55; color: var(--color-text-muted); }
.t-small { font-size: 13px; line-height: 1.5; color: var(--color-text-muted); }
.t-micro { font-size: 12px; line-height: 1.4; color: var(--color-text-dim); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-brand); color: var(--color-brand-on); }
.btn-primary:hover { background: var(--color-brand-hover); }
.btn-secondary { background: transparent; color: var(--color-text-primary); border-color: var(--color-border-default); }
.btn-secondary:hover { background: var(--color-bg-elevated); border-color: var(--color-border-strong); }
.btn-ghost { background: transparent; color: var(--color-text-primary); }
.btn-ghost:hover { background: var(--color-bg-elevated); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:disabled:active, .btn[aria-disabled="true"]:active { transform: none; }

/* Cards */
.card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
}

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--color-border-default);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
}
.pill-brand { background: var(--color-brand-subtle); border-color: var(--color-brand-border); color: var(--color-brand); }
.pill-info { background: var(--color-info-bg); border-color: var(--color-info-border); color: var(--color-info); }
.pill-warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning); }
.pill-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }

/* Layout helpers */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}
.container-narrow { max-width: 880px; margin: 0 auto; padding: 0 32px; }

@media (max-width: 640px) {
  .container, .container-narrow { padding: 0 20px; }
}

/* Section */
section { position: relative; }
.section-pad { padding: 96px 0; }
.section-pad-sm { padding: 64px 0; }

/* Divider */
.divider { height: 1px; background: var(--color-border-subtle); width: 100%; }

/* Subtle grid backdrop */
.bg-grid {
  background-image:
    linear-gradient(to right, rgba(124,122,245,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(124,122,245,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* Glow */
.glow {
  background: radial-gradient(60% 50% at 50% 0%, rgba(124,122,245,0.18), transparent 70%);
}

/* Link */
.link {
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-default);
  transition: border-color .15s, color .15s;
}
.link:hover { border-color: var(--color-brand); color: var(--color-brand); }

/* Code-style tag */
.tag-mono {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--color-text-dim);
  text-transform: uppercase;
}

/* Site chrome */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,10,18,0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--color-border-subtle);
}
.nav-bar {
  display: flex; align-items: center;
  height: 64px; gap: 24px;
}
.brand-mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 500; font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark .mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--color-brand);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-brand-on);
  font-weight: 600; font-size: 16px;
}

.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 15.5px; font-weight: 500; letter-spacing: -0.005em;
  color: var(--color-text-primary);
  background: transparent; border: 0;
  font-family: inherit;
  transition: color .15s, background .15s;
  cursor: pointer;
  text-decoration: none;
}
.nav-link:hover, .nav-link.is-open { color: var(--color-brand); background: var(--color-brand-subtle); }
.nav-link svg { width: 13px; height: 13px; opacity: 0.65; transition: transform .15s; }
.nav-link.is-open svg { transform: rotate(180deg); }
.nav-cta { display: flex; align-items: center; gap: 8px; }

/* Mega menu */
.megamenu {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--color-bg-elevated);
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-drawer);
  display: none;
  z-index: 40;
}
.megamenu.is-open { display: block; }
.megamenu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px;
  padding: 36px 0 40px;
}
.mm-col-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin: 0 0 16px;
  font-weight: 500;
}
.mm-link {
  display: block;
  padding: 8px 0;
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 6px;
}
.mm-link:hover { color: var(--color-brand); }
.mm-link .desc {
  display: block;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
  letter-spacing: 0;
}
.mm-link .desc:hover { color: var(--color-text-muted); }
.mm-feature {
  background: var(--color-bg-companion);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* Footer */
.site-footer {
  background: var(--color-bg-sidebar);
  border-top: 1px solid var(--color-border-subtle);
  padding: 64px 0 32px;
  margin-top: 96px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 40px;
  margin-bottom: 56px;
}
@media (max-width: 880px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
.footer-col h4 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-dim);
  font-weight: 500;
  margin: 0 0 16px;
}
.footer-col a {
  display: block;
  font-size: 13.5px;
  color: var(--color-text-muted);
  padding: 5px 0;
  transition: color .15s;
}
.footer-col a:hover { color: var(--color-text-primary); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--color-border-subtle);
  padding-top: 24px;
  font-size: 12px;
  color: var(--color-text-dim);
  gap: 24px;
  flex-wrap: wrap;
}
.lang-switcher {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
}
.lang-switcher:hover { border-color: var(--color-border-default); color: var(--color-text-primary); }
.lang-popover {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 8px;
  display: none;
  width: 280px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
}
.lang-popover.is-open { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.lang-popover button {
  background: none; border: 0; color: var(--color-text-muted);
  text-align: left; padding: 6px 10px; border-radius: 4px;
  font-size: 12px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px;
}
.lang-popover button:hover { background: var(--color-bg-elevated-hi); color: var(--color-text-primary); }
.lang-popover button.is-active { color: var(--color-brand); background: var(--color-brand-subtle); }
.lang-popover .lang-code { font-family: var(--font-mono); color: var(--color-text-dim); font-size: 10.5px; }

/* Mobile nav */
.mobile-toggle { display: none; }
.mobile-menu { display: none; }
@media (max-width: 920px) {
  .nav-links, .nav-cta { display: none; }
  .nav-bar { justify-content: space-between; }
  .mobile-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-md);
    border: 1px solid var(--color-border-subtle); background: transparent;
    color: var(--color-text-primary);
  }
  .mobile-menu {
    position: fixed; left: 0; right: 0; top: 64px; bottom: 0;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border-subtle);
    z-index: 45;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0 56px;
  }
  .mobile-menu.is-open { display: block; }
}
.mobile-nav { display: flex; flex-direction: column; }
.mobile-nav a {
  display: block; padding: 15px 0;
  font-size: 18px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-subtle);
}
.mobile-nav a:hover, .mobile-nav a:active { color: var(--color-brand); }
.mobile-cta { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.mobile-cta .btn { width: 100%; justify-content: center; }
@media (min-width: 921px) { .mobile-menu { display: none !important; } }

/* ── Responsive guards (mobile) ──────────────────────────────
   The design's "mock" visuals are built at desktop widths. On small
   screens, grid/flex children default to min-width:auto and refuse to
   shrink, which stretches the page wider than the viewport and clips
   text. These guards let columns shrink and scale oversized type. */
@media (max-width: 920px) {
  .hero-grid > *, .feat-row > *, .deep-row > *,
  .pl-grid > *, .cs-grid > *, .tp-grid > *, .int-grid > * { min-width: 0; }
  .hero-visual, .mockup, .mock, .pdp-mock, .qr-mock { max-width: 100%; }
}
@media (max-width: 640px) {
  .t-hero { font-size: clamp(30px, 8.5vw, 40px); }
  .t-mega { font-size: clamp(26px, 7.5vw, 38px); }
  .t-display { font-size: clamp(23px, 6.5vw, 32px); }
  .section-pad { padding: 64px 0; }
  .section-headline, .hero-headline { max-width: 100%; }
  /* The design lays out section headers and card rows as multi-column
     (mostly via inline styles) without a mobile fallback. On phones,
     stack everything to a single column. !important is required to beat
     the inline grid-template-columns declarations. */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .trust-row, .trust-checks, .pl-grid, .cs-grid, .tp-grid { grid-template-columns: 1fr !important; }
  .kl-advisor { max-width: 100%; }
  /* wide comparison/feature tables scroll sideways instead of clipping */
  .cmp-table, .ftable, .docs-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  /* docs sidebar + content must be allowed to shrink */
  .docs-layout > * { min-width: 0; }
}

/* Animations */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.fade-up { animation: fade-up .6s ease both; }
.pulse-dot { animation: pulse-dot 2s ease-in-out infinite; }

/* Scroll-reveal — only active when JS adds .js-anim (and motion is allowed).
   Sections start hidden and fade up as they enter the viewport. */
.js-anim main > section[data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .6s ease, transform .6s ease;
  will-change: opacity, transform;
}
.js-anim main > section[data-reveal].is-in { opacity: 1; transform: none; }

/* Reduced motion: turn everything off, show end state. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .js-anim main > section[data-reveal] { opacity: 1 !important; transform: none !important; }
}
