/* Theme tokens */
:root,
[data-theme="light"] {
  --page-bg: #ffffff;
  --surface-bg: #f1f5f9;

  /* RGB triplets so Tailwind's <alpha-value> works (e.g. text-ink-900/70) */
  --ink-50: 241 245 249;
  /* slate-100 — subtle surface */
  --ink-100: 226 232 240;
  /* slate-200 — borders / dividers */
  --ink-200: 203 213 225;
  /* slate-300 — stronger borders */
  --ink-900: 15 23 42;
  /* slate-900 — primary text */
  --ink-950: 2 6 23;
  /* slate-950 — max emphasis */

  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(15, 23, 42, 0.06);

  --hero-blob-1: rgb(16 185 129 / 0.30);
  --hero-blob-2: rgb(6 182 212 / 0.22);
  --hero-blob-3: rgb(45 212 191 / 0.28);

  --grid-dot: rgba(15, 23, 42, 0.06);

  --code-bg: #0d1525;
  /* always dark — code/terminal blocks */
  --code-text: #e2e8f0;
}

[data-theme="dark"] {
  --page-bg: #0f172a;
  --surface-bg: #1e293b;

  --ink-50: 30 41 59;
  /* slate-800 — elevated surface */
  --ink-100: 51 65 85;
  /* slate-700 — borders */
  --ink-200: 71 85 105;
  /* slate-600 — stronger borders */
  --ink-900: 248 250 252;
  /* slate-50 — primary text */
  --ink-950: 255 255 255;
  /* pure white — max emphasis */

  --glass-bg: rgba(15, 23, 42, 0.55);
  --glass-border: rgba(255, 255, 255, 0.06);

  --hero-blob-1: rgb(16 185 129 / 0.18);
  --hero-blob-2: rgb(6 182 212 / 0.13);
  --hero-blob-3: rgb(45 212 191 / 0.15);

  --grid-dot: rgba(255, 255, 255, 0.05);

  --code-bg: #020617;
  --code-text: #e2e8f0;
}

/* Brand gradient — emerald → green → cyan */
:root {
  --grad: linear-gradient(120deg, #059669 0%, #10b981 35%, #06b6d4 75%, #22d3ee 100%);
}

/* Base document */
html {
  background: var(--page-bg);
  scroll-padding-top: 80px;
  overflow-x: clip;
}

body {
  font-feature-settings: "ss01", "cv11";
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: clip;
}

@supports not (overflow-x: clip) {

  html,
  body {
    overflow-x: hidden;
  }
}

/* Reusable surfaces */
.text-grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bg-grad {
  background: var(--grad);
}

/* Pressed state on actual buttons/links with the gradient surface.
   Scoped to button/a so icon containers (also .bg-grad) don't react. */
button.bg-grad,
a.bg-grad {
  transition: filter 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

button.bg-grad:active,
a.bg-grad:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

/* Pressed state for outline buttons in the "Built in public" CTA row */
.btn-outline:active {
  transform: scale(0.98);
  background: rgb(var(--ink-100) / 0.4);
}

/* Active nav link (scroll-spy adds aria-current="true" via JS) */
[aria-current="true"],
[aria-current="page"] {
  color: rgb(var(--ink-900));
  font-weight: 600;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid var(--glass-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* Cheaper blur on small screens — stacked glass surfaces are expensive on
   mid-range Android. Falls back to a slightly more opaque surface. */
@media (max-width: 640px) {
  .glass {
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
  }
}

.grid-bg {
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 24px 24px;
}

.mask-fade-b {
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* Always-dark code/terminal blocks */
.code-block {
  background: var(--code-bg);
  color: var(--code-text);
}

/* Theme toggle pill */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 9999px;
  padding: 3px;
}

.theme-toggle button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  background: transparent;
  color: inherit;
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  opacity: 0.6;
}

.theme-toggle button:hover {
  opacity: 1;
}

.theme-toggle button.active {
  background: var(--grad);
  color: #fff;
  opacity: 1;
}

.theme-toggle button svg {
  width: 20px;
  height: 20px;
}

/* FAQ accordion — animated open/close.
   The native <details> element snaps open/closed because its non-summary
   children are not rendered when closed. We wrap the answer in `.faq-body`
   and let JS animate its height while keeping `[open]` set throughout the
   transition. */
.faq-item summary {
  /* Hide the default disclosure triangle in all browsers */
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item .faq-body {
  overflow: hidden;
  will-change: height;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When opened via deep-link / page load (no animation), avoid a flash */
.faq-item[data-anchor-target="true"] {
  scroll-margin-top: 96px;
}

/* A11y: focus, motion, sr-only, skip-link */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid #10b981;
  outline-offset: 2px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: rgb(var(--ink-950));
  color: rgb(var(--ink-50));
  padding: 12px 16px;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}