/* ==========================================================================
   Imference brand stylesheet — shared by every page of imference.com.

   Ported from the desktop app's design system
   (imference-desktop-go/frontend/src/index.css — the source of truth).
   The site is DARK-ONLY, so tokens carry the app's .dark values directly.

   Load order matters: this file is linked AFTER the Tailwind CDN script so
   its plain-CSS classes win specificity ties naturally.

   Conventions:
   - gradients / glows / motion  → classes here (.btn-brand, .aurora, …)
   - flat tints                  → Tailwind `brand-*` utilities (inline config)
   - oklch/color-mix stay in THIS file; sRGB fallbacks precede each usage so
     old browsers degrade gracefully (flat colors, no glow) instead of breaking.
   ========================================================================== */

/* ---- 1. Tokens ---------------------------------------------------------- */
:root {
  /* sRGB approximations first — upgraded by @supports below. */
  --background: #101319;
  --foreground: #f4f6f9;
  --card: #181c24;
  --muted: #232833;
  --muted-foreground: #9aa3b2;
  --border: rgba(255, 255, 255, 0.11);
  --ring: #4d7fd6;
  /* Signature brand gradient — deep royal blue → cyan (from the app logo). */
  --brand-from: #2f5fd8;
  --brand-to: #3fbfe8;
  /* Payment-rail identifiers (secondary accents — dots & badges only). */
  --rail-x402: #34d399;
  --rail-credits: #c084fc;
  /* Motion vocabulary — one easing family for the whole site (same as app). */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
}
@supports (color: oklch(0.5 0.1 250)) {
  :root {
    /* The app's dark-theme values, verbatim. */
    --background: oklch(0.152 0.01 251);
    --foreground: oklch(0.975 0.003 250);
    --card: oklch(0.205 0.012 251);
    --muted: oklch(0.268 0.01 251);
    --muted-foreground: oklch(0.715 0.012 252);
    --border: oklch(1 0 0 / 11%);
    --ring: oklch(0.62 0.13 245);
    --brand-from: oklch(0.58 0.17 254);
    --brand-to: oklch(0.76 0.14 218);
  }
}

/* ---- 2. Base ------------------------------------------------------------- */
body {
  background-color: var(--background);
  color: var(--foreground);
  font-family:
    "Inter", "Inter Variable", ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  /* Neutral top vignette — the animated brand aurora is a separate layer. */
  background-image: radial-gradient(
    120% 80% at 50% -10%,
    rgba(244, 246, 249, 0.03),
    transparent 60%
  );
  background-attachment: fixed;
}
::selection {
  background: rgba(244, 246, 249, 0.14);
}
/* Quiet, thin scrollbars — the chrome should disappear. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 246, 249, 0.18) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: rgba(244, 246, 249, 0.16);
  border-radius: 9999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(244, 246, 249, 0.28);
}

/* ---- 3. Signature components --------------------------------------------- */

/* Brand gradient fill — logo tiles, small marks. */
.brand-surface {
  background-image: linear-gradient(135deg, var(--brand-from), var(--brand-to));
}

/* Brand gradient as text — for a single accent word in a heading. */
.brand-text {
  background-image: linear-gradient(120deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* The primary action: gradient pill, colored glow, hover lift, tactile press.
   Layout (padding/radius/font) stays in Tailwind utilities at the use site:
   class="btn-brand inline-flex items-center justify-center gap-2 rounded-2xl
          px-5 py-3 text-sm font-semibold" */
.btn-brand {
  background-image: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(63, 191, 232, 0.6); /* fallback */
  box-shadow: 0 8px 24px -8px color-mix(in oklch, var(--brand-to) 65%, transparent);
  transition:
    filter 0.15s ease,
    box-shadow 0.2s ease,
    transform 0.14s var(--ease-spring);
}
.btn-brand:hover:not(:disabled) {
  filter: brightness(1.12) saturate(1.08);
  box-shadow: 0 16px 38px -8px rgba(63, 191, 232, 0.8);
  box-shadow: 0 16px 38px -8px color-mix(in oklch, var(--brand-to) 85%, transparent);
  transform: translateY(-2px);
}
.btn-brand:active:not(:disabled) {
  filter: brightness(0.94) saturate(1.05);
  box-shadow: 0 2px 8px -6px rgba(63, 191, 232, 0.65);
  box-shadow: 0 2px 8px -6px color-mix(in oklch, var(--brand-to) 70%, transparent);
  transform: translateY(1px) scale(0.96);
  transition-duration: 0.04s;
}

/* Secondary action — quiet bordered pill, same motion family as .btn-brand. */
.btn-ghost {
  border: 1px solid var(--border);
  background: rgba(24, 28, 36, 0.6);
  background: color-mix(in oklch, var(--card) 60%, transparent);
  color: var(--foreground);
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    transform 0.14s var(--ease-spring);
}
.btn-ghost:hover:not(:disabled) {
  border-color: rgba(47, 95, 216, 0.4);
  border-color: color-mix(in oklch, var(--brand-from) 40%, transparent);
  transform: translateY(-1px);
}
.btn-ghost:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
  transition-duration: 0.04s;
}

/* Card recipe — replaces ad-hoc `rounded-3xl border-slate-800 bg-slate-900/55`.
   No backdrop-blur on purpose: dozens of blurred cards is the main perf trap. */
.card {
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: rgba(24, 28, 36, 0.72);
  background: color-mix(in oklch, var(--card) 72%, transparent);
}

/* Faint brand tints — chips, active states, icon tiles. */
.brand-wash {
  background-color: rgba(47, 95, 216, 0.08);
  background-color: color-mix(in oklch, var(--brand-from) 8%, transparent);
}
.brand-hairline {
  border-color: rgba(47, 95, 216, 0.3);
  border-color: color-mix(in oklch, var(--brand-from) 30%, transparent);
}

/* Payment-rail identifiers — the ONLY place emerald/purple survive. */
.rail-dot-x402,
.rail-dot-credits {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}
.rail-dot-x402 {
  background: var(--rail-x402);
}
.rail-dot-credits {
  background: var(--rail-credits);
}

/* Entrance for hero blocks / cards: a short rise + fade. */
.rise-in {
  animation: rise-in 0.35s var(--ease-out-expo) both;
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus halo for bespoke form fields (playgrounds). */
.field-focus {
  outline: none;
}
.field-focus:focus-visible {
  box-shadow: 0 0 0 2px rgba(47, 95, 216, 0.35);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--brand-from) 35%, transparent);
  border-color: rgba(47, 95, 216, 0.55);
  border-color: color-mix(in oklch, var(--brand-from) 55%, transparent);
}

/* ---- 4. Background decor -------------------------------------------------- */

/* Subtle grid overlay (56px), ported from the old per-page inline div. */
.bg-grid {
  background-image:
    linear-gradient(rgba(244, 246, 249, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 246, 249, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
}

/* Animated brand aurora — large blurred gradient blobs drifting behind the
   content. transform/opacity only → GPU-composited. Site usage: one fixed
   full-viewport wrapper right after <body>:
     <div class="aurora aurora-fixed" aria-hidden="true">
       <div class="aurora-blob aurora-blob-1"></div>
       <div class="aurora-blob aurora-blob-2"></div>
       <div class="aurora-blob aurora-blob-3"></div>
     </div> */
.aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.aurora-fixed {
  position: fixed;
}
.aurora-blob {
  position: absolute;
  border-radius: 9999px;
  filter: blur(100px);
  opacity: 0.42;
  will-change: transform;
}
.aurora-blob-1 {
  width: 42rem;
  height: 42rem;
  top: -16rem;
  left: -10rem;
  background: radial-gradient(circle, rgba(47, 95, 216, 0.6), transparent 70%);
  background: radial-gradient(
    circle,
    color-mix(in oklch, var(--brand-from) 60%, transparent),
    transparent 70%
  );
  animation: aurora-1 26s ease-in-out infinite alternate;
}
.aurora-blob-2 {
  width: 40rem;
  height: 40rem;
  top: -18rem;
  right: -12rem;
  background: radial-gradient(circle, rgba(63, 191, 232, 0.58), transparent 70%);
  background: radial-gradient(
    circle,
    color-mix(in oklch, var(--brand-to) 58%, transparent),
    transparent 70%
  );
  animation: aurora-2 32s ease-in-out infinite alternate;
}
.aurora-blob-3 {
  width: 34rem;
  height: 34rem;
  top: 8rem;
  left: 38%;
  background: radial-gradient(circle, rgba(55, 143, 224, 0.5), transparent 70%);
  background: radial-gradient(
    circle,
    color-mix(in oklch, var(--brand-from) 38%, var(--brand-to)),
    transparent 70%
  );
  opacity: 0.16;
  animation: aurora-3 38s ease-in-out infinite alternate;
}
@keyframes aurora-1 {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(7rem, 4rem, 0) scale(1.18);
  }
}
@keyframes aurora-2 {
  from {
    transform: translate3d(0, 0, 0) scale(1.05);
  }
  to {
    transform: translate3d(-6rem, 5rem, 0) scale(0.92);
  }
}
@keyframes aurora-3 {
  from {
    transform: translate3d(0, 0, 0) scale(0.9);
  }
  to {
    transform: translate3d(-5rem, -4rem, 0) scale(1.2);
  }
}
/* Lighter aurora on small screens: drop the third blob, soften the blur. */
@media (max-width: 640px) {
  .aurora-blob {
    filter: blur(70px);
  }
  .aurora-blob-3 {
    display: none;
  }
}

/* ---- 5. Docs & code (Prism + language tabs + rail switcher) --------------- */

/* Code blocks — replaces the old per-page prism-tomorrow theme + inline
   overrides; one dark VS Code-like palette on the brand card surface. */
pre[class*="language-"],
code[class*="language-"] {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas,
    monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  text-shadow: none;
}
pre[class*="language-"] {
  background: rgba(16, 19, 25, 0.85);
  background: color-mix(in oklch, var(--background) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  margin: 0;
  overflow-x: auto;
}
code[class*="language-"] {
  color: #e2e8f0;
  background: none;
}
.token.comment,
.token.prolog,
.token.cdata {
  color: #6a9955;
}
.token.punctuation {
  color: #d4d4d4;
}
.token.property,
.token.tag,
.token.constant,
.token.symbol {
  color: #9cdcfe;
}
.token.boolean,
.token.number {
  color: #b5cea8;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
  color: #ce9178;
}
.token.operator,
.token.entity,
.token.url {
  color: #d4d4d4;
}
.token.atrule,
.token.attr-value,
.token.keyword {
  color: #569cd6;
}
.token.function,
.token.class-name {
  color: #dcdcaa;
}
.token.regex,
.token.important,
.token.variable {
  color: #d16969;
}

/* Language tabs (curl / Python / JS / JSON). site.js only toggles `.active`
   and `hidden` — all styling lives here. */
.lang-tab {
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.lang-tab:hover {
  color: var(--foreground);
}
.lang-tab.active {
  color: var(--brand-to);
  background-color: rgba(47, 95, 216, 0.12);
  background-color: color-mix(in oklch, var(--brand-from) 12%, transparent);
}

/* Payment-rail switcher (docs): body[data-rail] shows one variant, hides the
   other. Elements marked data-rail-only render only for their rail. */
body[data-rail="credits"] [data-rail-only="x402"],
body[data-rail="x402"] [data-rail-only="credits"] {
  display: none;
}
.rail-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: rgba(24, 28, 36, 0.72);
  background: color-mix(in oklch, var(--card) 72%, transparent);
}
.rail-switch button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted-foreground);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.rail-switch button:hover {
  color: var(--foreground);
}
.rail-switch button[aria-pressed="true"] {
  color: #fff;
  background-image: linear-gradient(135deg, var(--brand-from), var(--brand-to));
}

/* Docs sidebar link states (scrollspy toggles .active via site.js). */
.docs-nav a {
  display: block;
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.docs-nav a:hover {
  color: var(--foreground);
}
.docs-nav a.active {
  color: var(--brand-to);
  background-color: rgba(47, 95, 216, 0.12);
  background-color: color-mix(in oklch, var(--brand-from) 12%, transparent);
}

/* ---- 6. Motion guard ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .aurora-blob,
  .rise-in {
    animation: none;
  }
  .btn-brand,
  .btn-ghost {
    transition: none;
  }
}
