/* ═══════════════════════════════════════════════════════════════════════════
   Vespera fx — styles for the 3D scene, the page portal and the interaction
   layer (scene.js, depth.js, fx.js). Loaded after depth.css.
   Nothing here sets the size, spacing or position of in-flow content.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --fx-light: 207 199 255;     /* the light: pale violet */
  --fx-violet: 143 125 255;
  --fx-ink: 238 235 243;
}

/* ── the scene ───────────────────────────────────────────────────────── */
.vs-scene {
  position: fixed; inset: 0; z-index: -1; width: 100vw; height: 100vh; display: block;
  pointer-events: none; opacity: 0; transition: opacity var(--m-4, 600ms) var(--m-ease, ease-out);
}
.vs-scene.is-on { opacity: 1; }
/* the canvas paints the background: the page lets it through */
html.vs-scene-on body { isolation: isolate; }
html.vs-scene-on body.site-page { background: transparent; }
html.vs-scene-on .vs-ambient { display: none; }

/* ── the page portal ─────────────────────────────────────────────────── */
/* content travels as its own layers; the root (with the live scene) just shows the new page */
html.vs-leaving main { view-transition-name: vs-out-main; }
html.vs-leaving body > footer { view-transition-name: vs-out-foot; }
html.vs-portal main { view-transition-name: vs-in-main; }
html.vs-portal body > footer { view-transition-name: vs-in-foot; }
html.vs-portal::view-transition-old(root) { display: none; }
html.vs-portal::view-transition-new(root) { animation: none; }
html.vs-portal::view-transition-old(vs-out-main), html.vs-portal::view-transition-old(vs-out-foot),
html.vs-portal::view-transition-new(vs-in-main), html.vs-portal::view-transition-new(vs-in-foot) { animation: none; }
.vs-portal-ring {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2147483000;
  pointer-events: none; overflow: visible; fill: none; view-transition-name: vs-portal;
}
.vs-portal-ring .halo { stroke: rgb(var(--fx-violet) / .12); stroke-width: 34px; }
.vs-portal-ring .mid { stroke: rgb(var(--fx-violet) / .3); stroke-width: 7px; }
.vs-portal-ring .chroma { stroke: rgb(120 196 255 / .4); stroke-width: 1.5px; }
.vs-portal-ring .core { stroke: rgb(236 232 255 / .95); stroke-width: 1.25px; }
.vs-portal-local { view-transition-name: none; }
::view-transition-group(vs-portal) { z-index: 10; animation: none; }
::view-transition-new(vs-portal), ::view-transition-old(vs-portal) { animation: none; }

/* ── decoding text ───────────────────────────────────────────────────── */
.vs-decode { display: inline; }
.vs-ch { position: relative; }
.vs-ch.is-scrambled { color: transparent; }
.vs-ch.is-scrambled::after {
  content: attr(data-g); position: absolute; left: 0; top: 0; color: rgb(var(--fx-light)); opacity: .55;
  font-style: inherit;
}
.vs-ch.is-set { animation: vs-ch-set 400ms var(--m-ease, ease-out); }
@keyframes vs-ch-set { from { opacity: .45; filter: brightness(1.9) drop-shadow(0 0 .3em rgb(var(--fx-violet) / .9)); } }
.vs-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ── cursor ──────────────────────────────────────────────────────────── */
.vs-cursor-ring, .vs-cursor-dot {
  position: fixed; left: 0; top: 0; z-index: 2147483600; pointer-events: none; opacity: 0;
  contain: layout style; will-change: transform;
}
.vs-cursor-ring { width: 30px; height: 30px; border-radius: 15px; transition: opacity var(--m-2) var(--m-ease), scale var(--m-1) var(--m-ease); }
/* two looks on two layers: only their opacity changes, so the ring never animates colour */
.vs-cursor-ring::before, .vs-cursor-ring::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; transition: opacity var(--m-2) var(--m-ease);
}
.vs-cursor-ring::before { border: 1px solid rgb(var(--fx-light) / .5); background: rgb(var(--fx-violet) / .035); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); }
.vs-cursor-ring::after { opacity: 0; border: 1px solid rgb(var(--fx-light) / .42); background: rgb(var(--fx-violet) / .09); box-shadow: 0 0 24px -6px rgb(var(--fx-violet) / .55), inset 0 1px 0 rgb(255 255 255 / .08); }
.vs-cursor-ring:is([data-mode=wrap], [data-mode=hover], [data-mode=text])::before { opacity: 0; }
.vs-cursor-ring:is([data-mode=wrap], [data-mode=hover], [data-mode=text])::after { opacity: 1; }
.vs-cursor-ring[data-mode=hover]::after { border-color: rgb(var(--fx-light) / .6); background: rgb(var(--fx-violet) / .12); }
.vs-cursor-ring[data-mode=text]::after { border-color: transparent; background: rgb(var(--fx-light) / .9); box-shadow: 0 0 10px rgb(var(--fx-violet) / .7); }
.vs-cursor-ring.is-down { scale: .9; }
.vs-cursor-dot { width: 4px; height: 4px; border-radius: 50%; background: rgb(var(--fx-ink)); transition: opacity var(--m-1) linear; }
html.vs-cursor-shown .vs-cursor-ring, html.vs-cursor-shown .vs-cursor-dot { opacity: 1; }
html.vs-cursor-shown .vs-cursor-ring[data-mode=native], html.vs-cursor-shown .vs-cursor-dot:is([data-mode=native], [data-mode=wrap], [data-mode=text], [data-mode=hover]) { opacity: 0; }
/* the system cursor gives way to ours, except where you type */
html.vs-cursor-shown, html.vs-cursor-shown * { cursor: none !important; }
html.vs-cursor-shown :is(input:not([type=checkbox], [type=radio], [type=range], [type=submit], [type=button]), textarea, select, [contenteditable=""], [contenteditable=true]),
html.vs-cursor-shown :is(input:not([type=checkbox], [type=radio], [type=range], [type=submit], [type=button]), textarea, [contenteditable=""], [contenteditable=true]) * { cursor: auto !important; }
html.vs-cursor-shown :is(button, [role=button], a):disabled { cursor: not-allowed !important; }

/* ── magnetic controls ───────────────────────────────────────────────── */
.vs-pull { translate: var(--vs-mx, 0px) var(--vs-my, 0px); }
/* the extension lifts and presses its buttons with `translate` too: add the two together */
html body .vs-pull.vs-pull.vs-pull:hover:not(:active) { translate: var(--vs-mx, 0px) calc(var(--vs-my, 0px) - 1px); }
html body .vs-pull.vs-pull.vs-pull:active { translate: var(--vs-mx, 0px) calc(var(--vs-my, 0px) + 1px); }

/* ── light themes (extension): the light becomes ink-violet ──────────── */
body[data-theme="light"] { --fx-light: 90 63 240; --fx-violet: 108 92 224; --fx-ink: 24 22 34; }
@media (prefers-color-scheme: light) { body[data-theme="auto"] { --fx-light: 90 63 240; --fx-violet: 108 92 224; --fx-ink: 24 22 34; } }

/* ── edge light: the cursor lights the border that faces it ──────────── */
.vs-edge-pos { position: relative; }
.vs-edge::after, .workbench.vs-edge::after {
  content: ""; position: absolute; inset: 0; z-index: 2; width: auto; aspect-ratio: auto; border-radius: inherit;
  padding: 1px; pointer-events: none;
  background: radial-gradient(260px circle at var(--vs-lx, -999px) var(--vs-ly, -999px), rgb(var(--fx-light) / .85), rgb(var(--fx-violet) / .28) 42%, transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: var(--vs-la, 0);
  transition: opacity var(--m-2) var(--m-ease);
}

/* ── glass: the two sample windows let the scene's light through ─────── */
html.vs-scene-on :is(.home-hero .site-proof, .product-hero .workbench, main > :first-child .read-sample, main .site-form:not(.compute-desk .site-form)) {
  background: linear-gradient(180deg, rgb(22 21 32 / .62), rgb(10 10 16 / .74));
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}
html.vs-scene-on :is(.site-card, .price-row, .specimen) { background-color: rgb(10 10 15 / .55); }
/* extension: the library's hero panel is glass too */
html.vs-scene-on .hero-panel {
  background: color-mix(in srgb, var(--ink-2, #111117) 66%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
}

/* ── grain over everything: a film texture that keeps gradients from banding ── */
.site-page::after {
  content: ""; position: fixed; inset: 0; z-index: 2147482000; pointer-events: none; opacity: .028;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── scroll-driven 3D ────────────────────────────────────────────────── */
.vs-3d { transform-origin: 50% 60%; backface-visibility: hidden; }

/* ── off: reduced motion, high contrast, print ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .vs-scene, .vs-portal-ring, .vs-cursor-ring, .vs-cursor-dot { display: none !important; }
  .vs-pull { translate: none; }
}
@media (prefers-contrast: more), (forced-colors: active) {
  .vs-scene, .vs-portal-ring, .vs-cursor-ring, .vs-cursor-dot, .vs-edge::after, .site-page::after { display: none !important; }
  html.vs-cursor-shown, html.vs-cursor-shown * { cursor: auto !important; }
  html.vs-scene-on body.site-page { background: var(--void); }
  html.vs-scene-on :is(.home-hero .site-proof, .product-hero .workbench, main > :first-child .read-sample, main .site-form) { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--ink-2); }
}
html.vs-fx-off .vs-cursor-ring, html.vs-fx-off .vs-cursor-dot { display: none; }
@media print {
  .vs-scene, .vs-portal-ring, .vs-cursor-ring, .vs-cursor-dot, .site-page::after { display: none !important; }
  .vs-3d { transform: none !important; opacity: 1 !important; }
}
