/* Snippets site — mirrors the app's design system
   (Sources/Snippets/DesignSystem, Services/Theme.swift): the canvas and dot
   grid, drifting colour glows, glass surfaces with a white hairline rim,
   `// section` monospace labels and lowercase `lang:` chips.

   Theme: follows the system unless the visitor picks one; site.js sets
   [data-theme] on <html> before first paint. */

/* ───────────── Tokens ───────────── */

:root {
  color-scheme: light;

  /* Theme.swift canvas / canvasDeep / text */
  --canvas: #f5f6f8;
  --canvas-deep: #f1f2f5;
  --text: #24292f;
  --text-2: #3d444c;
  --text-3: #6b7280;
  --accent: #0a84ff;
  --accent-ink: #0060df;
  --pink: #ff375f;
  --yellow: #ffbd3b;
  --purple: #a855f7;

  /* Glass (DSGlassModifier): material + white rim + soft drop shadow */
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-rim: rgba(255, 255, 255, 0.9);
  --glass-edge: rgba(15, 23, 42, 0.07);
  --glass-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -8px rgba(15, 23, 42, 0.14);
  --well: rgba(255, 255, 255, 0.55);
  --code-bg: #ffffff;

  --dot: rgba(15, 23, 42, 0.12);
  --glow-a: rgba(10, 132, 255, 0.26);
  --glow-b: rgba(255, 55, 95, 0.2);
  --glow-c: rgba(168, 85, 247, 0.2);
  --glow-d: rgba(255, 189, 59, 0.18);

  /* DSRadius */
  --r-sm: 8px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  /* DSMotion springs as CSS linear() curves (generated, settle ≈ duration). */
  --spring-reveal: linear(0, 0.0194, 0.0685, 0.1362, 0.2141, 0.2962, 0.3782, 0.4571, 0.531, 0.5988, 0.6599, 0.7143, 0.7619, 0.8033, 0.8388, 0.8691, 0.8946, 0.9159, 0.9336, 0.9482, 0.9601, 0.9697, 0.9774, 0.9834, 0.9882, 0.9919, 0.9948, 0.9969, 0.9985, 0.9996, 1.0004, 1.0009, 1.0013, 1.0014, 1.0015, 1.0015, 1.0015, 1.0014, 1.0012, 1.0011, 1);
  --spring-reveal-d: 460ms;
  --spring-page: linear(0, 0.0122, 0.0442, 0.09, 0.145, 0.2055, 0.2687, 0.3324, 0.3949, 0.4553, 0.5125, 0.5661, 0.6159, 0.6615, 0.7032, 0.7408, 0.7747, 0.8049, 0.8318, 0.8556, 0.8766, 0.8949, 0.9109, 0.9248, 0.9368, 0.9472, 0.9561, 0.9636, 0.9701, 0.9756, 0.9802, 0.984, 0.9873, 0.9899, 0.9922, 0.994, 0.9955, 0.9967, 0.9976, 0.9984, 1);
  --spring-page-d: 900ms;
  --spring-pop: linear(0, 0.023, 0.0791, 0.1537, 0.2368, 0.3217, 0.404, 0.4813, 0.5521, 0.6157, 0.6722, 0.7218, 0.7648, 0.8019, 0.8338, 0.8609, 0.8839, 0.9034, 0.9197, 0.9335, 0.9449, 0.9545, 0.9625, 0.9691, 0.9746, 0.9791, 0.9829, 0.986, 0.9885, 0.9906, 0.9923, 0.9937, 0.9949, 0.9958, 0.9966, 0.9972, 0.9977, 0.9982, 0.9985, 0.9988, 1);
  --spring-pop-d: 330ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dark: the app's own dark canvas. Applied by system preference unless the
   visitor chose light, or always when they chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0e1014;
    --canvas-deep: #090b0e;
    --text: #e6edf3;
    --text-2: #c2cad3;
    --text-3: #949ca6;
    --accent: #0a84ff;
    --accent-ink: #4aa3ff;
    --glass: rgba(28, 33, 40, 0.55);
    --glass-strong: rgba(24, 28, 34, 0.78);
    --glass-rim: rgba(255, 255, 255, 0.14);
    --glass-edge: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 40px -10px rgba(0, 0, 0, 0.55);
    --well: rgba(10, 12, 16, 0.6);
    --code-bg: #0a0b0d;
    --dot: rgba(255, 255, 255, 0.075);
    --glow-a: rgba(10, 132, 255, 0.2);
    --glow-b: rgba(255, 55, 95, 0.15);
    --glow-c: rgba(168, 85, 247, 0.17);
    --glow-d: rgba(255, 189, 59, 0.1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0e1014;
  --canvas-deep: #090b0e;
  --text: #e6edf3;
  --text-2: #c2cad3;
  --text-3: #949ca6;
  --accent: #0a84ff;
  --accent-ink: #4aa3ff;
  --glass: rgba(28, 33, 40, 0.55);
  --glass-strong: rgba(24, 28, 34, 0.78);
  --glass-rim: rgba(255, 255, 255, 0.14);
  --glass-edge: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 40px -10px rgba(0, 0, 0, 0.55);
  --well: rgba(10, 12, 16, 0.6);
  --code-bg: #0a0b0d;
  --dot: rgba(255, 255, 255, 0.075);
  --glow-a: rgba(10, 132, 255, 0.2);
  --glow-b: rgba(255, 55, 95, 0.15);
  --glow-c: rgba(168, 85, 247, 0.17);
  --glow-d: rgba(255, 189, 59, 0.1);
}

/* Light/dark media: an element marked .theme-light shows only in light,
   .theme-dark only in dark. Hidden <img loading=lazy> never downloads. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-dark { display: none !important; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-light { display: none !important; }
}
:root[data-theme="light"] .theme-dark { display: none !important; }
:root[data-theme="dark"] .theme-light { display: none !important; }

/* ───────────── Base ───────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 300ms var(--ease-out), color 300ms var(--ease-out);
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img, video { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.wrap-narrow { max-width: 760px; }

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

/* ───────────── Backdrop: canvas, dot grid, drifting glows ───────────── */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.backdrop::before {          /* dot grid (DotGridBackground: 22pt, 1.4pt dots) */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at center, var(--dot) 0.8px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.85) 55%, rgba(0, 0, 0, 0.35) 100%);
          mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.85) 55%, rgba(0, 0, 0, 0.35) 100%);
}
.backdrop::after {           /* canvas → canvasDeep fade */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--canvas-deep));
  opacity: 0.6;
}

.glow {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(40px);
  will-change: transform;
  transition: background 300ms var(--ease-out);
}
.glow-a { background: radial-gradient(closest-side, var(--glow-a), transparent); top: -26vmax; left: -14vmax; animation: drift-a 64s ease-in-out infinite alternate; }
.glow-b { background: radial-gradient(closest-side, var(--glow-b), transparent); top: -18vmax; right: -22vmax; animation: drift-b 78s ease-in-out infinite alternate; }
.glow-c { background: radial-gradient(closest-side, var(--glow-c), transparent); top: 38vh; left: 18vw; animation: drift-c 92s ease-in-out infinite alternate; }
.glow-d { background: radial-gradient(closest-side, var(--glow-d), transparent); bottom: -30vmax; right: 0; animation: drift-d 70s ease-in-out infinite alternate; }

/* Slow, small drifts — the app's glows move at ~0.07 Hz; these are slower. */
@keyframes drift-a { to { transform: translate3d(14vw, 10vh, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-12vw, 14vh, 0) scale(0.94); } }
@keyframes drift-c { to { transform: translate3d(-16vw, -8vh, 0) scale(1.1); } }
@keyframes drift-d { to { transform: translate3d(-18vw, -12vh, 0) scale(1.05); } }

/* ───────────── Glass ───────────── */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
          backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-rim), var(--glass-shadow);
  border-radius: var(--r-lg);
}

/* ───────────── Navigation: floating glass capsule ───────────── */

.nav {
  position: sticky;
  top: 12px;
  z-index: 50;
  margin: 12px auto 0;
  width: calc(100% - 24px);
  max-width: 1096px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 999px;
  transition: background-color 250ms var(--ease-out), box-shadow 250ms var(--ease-out);
}
.nav.is-scrolled { background: var(--glass-strong); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: auto;
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }

.nav-links { display: flex; gap: 2px; }
.nav-links a {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: 999px;
  transition: background-color 140ms ease-out, color 140ms ease-out;
}
.nav-links a:hover { text-decoration: none; background: var(--glass-edge); color: var(--text); }
.nav-links a[aria-current="page"] { color: var(--text); background: var(--glass-edge); }

/* Theme toggle: segmented auto / light / dark */
.theme-toggle {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-edge);
}
.theme-toggle button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: color 140ms ease-out, transform 100ms ease-out;
}
.theme-toggle button:active { transform: scale(0.9); }
.theme-toggle button[aria-pressed="true"] { color: var(--text); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .thumb {           /* slides between segments (popover spring) */
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 28px;
  border-radius: 999px;
  background: var(--glass-strong);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform var(--spring-pop-d) var(--spring-pop);
}

/* ───────────── Buttons ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 110ms ease-out, filter 140ms ease-out, box-shadow 140ms ease-out, background-color 140ms ease-out;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }   /* feedback on press, not release */
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #2b95ff, #0a7aff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 18px -6px rgba(10, 132, 255, 0.65);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 26px -6px rgba(10, 132, 255, 0.7); }

.btn-glass {
  color: var(--text);
  background: var(--glass);
  border-color: var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-rim);
}
.btn-glass:hover { background: var(--glass-strong); }

.btn-lg { font-size: 17px; padding: 14px 26px; }

/* A button for something not available yet: greyed, not clickable. */
.btn.is-disabled,
.btn.is-disabled:hover {
  color: var(--text-3);
  background: var(--glass-edge);
  border-color: var(--glass-edge);
  box-shadow: none;
  filter: none;
  cursor: not-allowed;
}
.btn.is-disabled:active { transform: none; }

.soon {
  margin: 16px 0 0;
  font-size: 15px;
  color: var(--text-2);
}
.btn-lg svg { width: 19px; height: 19px; }

.nav .btn { padding: 7px 14px; font-size: 14px; }

/* Support Snippets: glass, with the icon's pink heart. */
.btn-sponsor svg { color: var(--pink); width: 15px; height: 15px; transition: transform 200ms var(--ease-out); }
.btn-sponsor:hover svg { transform: scale(1.15); }

/* ───────────── Type ───────────── */

.eyebrow,
.section-label {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-3);
  letter-spacing: 0;
}
.section-label {             /* the app's "// preview ───────" row */
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-edge);
}

h1, h2, h3 {
  color: var(--text);
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
.display {
  font-size: clamp(2.6rem, 6.4vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.headline {
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.028em;
}
h3 { font-size: 19px; line-height: 1.3; letter-spacing: -0.012em; }

.lede {
  font-size: clamp(1.1rem, 1.8vw, 1.3rem);
  line-height: 1.5;
  color: var(--text-2);
  letter-spacing: -0.008em;
  text-wrap: pretty;
}
.muted { color: var(--text-3); }

code, kbd {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--glass-edge);
  padding: 1px 6px;
  border-radius: 6px;
}

/* ───────────── Chips (lang:swift etc.) ───────────── */

.chip {
  --c: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 38%, transparent);
  white-space: nowrap;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ───────────── Reveal on scroll ───────────── */
/* "Materialize, don't just fade": opacity, blur and scale arrive together on
   the app's reveal spring. Stagger 20 ms per item, capped at 120 ms
   (DSMotion.staggerStep / staggerCap). site.js adds .is-in. */

.js .reveal {
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.985);
  filter: blur(6px);
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    opacity 360ms var(--ease-out),
    filter 360ms var(--ease-out),
    transform var(--spring-reveal-d) var(--spring-reveal);
  transition-delay: calc(min(var(--i, 0) * 20ms, 120ms));
}

/* ───────────── Footer ───────────── */

.site-footer {
  margin-top: 80px;
  padding: 28px 0 44px;
  border-top: 1px solid var(--glass-edge);
  color: var(--text-3);
  font-size: 14px;
}
.site-footer .wrap {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.site-footer nav { display: flex; gap: 18px; font-family: var(--mono); font-size: 13px; }
.site-footer a { color: var(--text-3); }
.site-footer a:hover { color: var(--text); }

/* ───────────── Document pages (support / privacy / license) ───────────── */

.doc { padding: 72px 0 0; }
.doc h1 { margin-bottom: 10px; }
.doc .lede { margin: 0 0 28px; }
.doc h2 {
  font-size: 22px;
  letter-spacing: -0.018em;
  margin: 44px 0 10px;
}
.doc p, .doc ul { margin: 0 0 14px; color: var(--text-2); }
.doc strong { color: var(--text); }
.doc ul { padding-left: 22px; }
.doc li { margin-bottom: 7px; }
.doc li::marker { color: var(--text-3); }
.meta { font-family: var(--mono); font-size: 13.5px; color: var(--text-3); margin-bottom: 28px; }

.card { padding: 24px 26px; margin: 24px 0; }
.card > :last-child { margin-bottom: 0; }
.card-accent { box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 var(--glass-rim), var(--glass-shadow); }

.contact { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.contact p { margin: 0; font-family: var(--mono); font-size: 14.5px; }

/* FAQ disclosure: height animates with the page spring where supported. */
.faq { margin-top: 8px; }
.faq details {
  border-bottom: 1px solid var(--glass-edge);
  interpolate-size: allow-keywords;
}
.faq details::details-content {
  height: 0;
  overflow: clip;
  opacity: 0;
  transition: height var(--spring-reveal-d) var(--spring-reveal), opacity 240ms var(--ease-out), content-visibility var(--spring-reveal-d) allow-discrete;
}
.faq details[open]::details-content { height: auto; opacity: 1; }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: -0.01em;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: translateY(-3px) rotate(45deg);
  transition: transform var(--spring-pop-d) var(--spring-pop);
}
.faq details[open] summary::after { transform: translateY(2px) rotate(225deg); }
.faq details > :not(summary) { margin: 0 2px 16px; }

.legal {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* ───────────── Responsive ───────────── */

@media (max-width: 760px) {
  .nav-links { display: none; }
  .wrap { padding: 0 18px; }
  .doc { padding-top: 48px; }
}
@media (max-width: 980px) {
  .nav .btn-sponsor span { display: none; }
  .nav .btn-sponsor { padding: 7px 10px; }
}
@media (max-width: 420px) {
  .nav .btn span { display: none; }
  .nav .btn { padding: 7px 10px; }
}

/* ───────────── Accessibility preferences ───────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .glow { animation: none; }
  .js .reveal { transform: none; filter: none; }
  .js .reveal.is-in { transition: opacity 200ms ease; transition-delay: 0ms; }
  .theme-toggle .thumb, .faq summary::after { transition-duration: 1ms; }
  .faq details::details-content { transition: none; }
  .btn:active { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .glass, .nav { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--canvas); }
  .glow { display: none; }
}

@media (prefers-contrast: more) {
  :root { --glass-edge: color-mix(in srgb, var(--text) 45%, transparent); --text-3: var(--text-2); }
  .glass { background: var(--canvas); }
}
