/* ==========================================================================
   Bitty Box — EDITOR VIBRANT OVERLAY  (ADDITIVE, no build step)
   --------------------------------------------------------------------------
   Loaded ONLY by /editor (docs/editor.html), after the built bundle CSS and
   after ui-polish.css. Purpose: bring the /editor surface into the same
   visual language as the new "Bitty Box Agents" landing deck
   (docs/index.html + docs/landing.css): black-navy ink, neon cyan, gold
   accent, Orbitron display type, and a live animated backdrop.

   WHY AN OVERLAY AND NOT A REBUILD
   The built React bundle is hand-patched (assets/index-*.js carries a
   .pre-editor-trim backup); a fresh `vite build` regresses the hand-patched
   lock set. So this layer is CSS + a small runtime only. Nothing in the Vite
   bundle, editor-stars.css, hybrid-theme.css or style.css is edited.

   ROLLBACK: delete the two tags in docs/editor.html and this file.
   Zero build artifacts depend on it.

   PALETTE SOURCE OF TRUTH: docs/landing.css :root
     --ink #000814  --navy #001233  --cyan #0ff  --gold #f5c542
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS — mirrors docs/landing.css so both surfaces share one
   vocabulary. Prefixed --vb- (vibrant) to avoid colliding with bundle vars.
   -------------------------------------------------------------------------- */
:root {
  --vb-ink: #000814;
  --vb-navy: #001233;
  --vb-navy-2: #01173f;
  --vb-cyan: #0ff;
  --vb-cyan-2: #7dfcff;
  --vb-cyan-dim: rgba(0, 255, 255, .55);
  --vb-cyan-ghost: rgba(0, 255, 255, .12);
  --vb-gold: #f5c542;
  --vb-gold-dim: rgba(245, 197, 66, .55);
  --vb-text: #d7f2ff;
  --vb-muted: #7ea6c2;
  --vb-edge: rgba(0, 255, 255, .20);

  --vb-font-display: "Orbitron", "Arial Black", system-ui, sans-serif;
  --vb-font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --vb-font-body: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --vb-glass: rgba(0, 18, 51, .55);
  --vb-glass-2: rgba(0, 8, 20, .72);
  --vb-hairline: rgba(0, 255, 255, .16);
  --vb-glow-cyan: 0 0 18px rgba(0, 255, 255, .32);
  --vb-glow-gold: 0 0 18px rgba(245, 197, 66, .30);
}

/* --------------------------------------------------------------------------
   2. ANIMATED BACKDROP — ports the landing's atmosphere (.bg .grid/.scan/
   .glowline/.vign in landing.css) onto the editor.

   The shell previously shipped <style id="editor-static-background"> which
   forced `.bitty-starfield` static ("without motion"). That block is removed
   from docs/editor.html by this overhaul; the rules below reinstate motion
   and re-point the atmosphere at the landing palette.

   `!important` is required here: it must beat the bundle's own
   `.bitty-starfield` background declaration and any leftover inline block.
   -------------------------------------------------------------------------- */
.bitty-starfield {
  background-color: var(--vb-ink) !important;
  background-image:
    radial-gradient(1200px 700px at 50% -10%, #01214d 0%, transparent 60%),
    radial-gradient(900px 600px at 85% 110%, #0a2b52 0%, transparent 62%),
    linear-gradient(180deg, #000814 0%, #000a1c 45%, #00102c 100%) !important;
  background-size: auto, auto, auto !important;
  background-attachment: fixed !important;
  animation: none !important;
}

/* Perspective floor grid — visible under the composer, fading upward. */
.bitty-starfield::before {
  content: "";
  position: fixed;
  left: -25%;
  right: -25%;
  bottom: -12%;
  height: 62%;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 255, 255, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 255, .16) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(420px) rotateX(72deg);
  transform-origin: bottom center;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 88%);
  mask-image: linear-gradient(to top, #000 0%, transparent 88%);
  animation: vbGridFlow 14s linear infinite;
  opacity: .5;
}

/* CRT scanlines over the whole surface. */
.bitty-starfield::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(180deg, rgba(0, 255, 255, .045) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
  opacity: .5;
}

/* Sweeping glow line, drawn on the app shell so it is not clipped. */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  height: 2px;
  top: -2%;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(90deg, transparent, var(--vb-cyan), transparent);
  filter: blur(1px);
  opacity: .5;
  animation: vbSweep 9s linear infinite;
}

/* Vignette — keeps focus central, matches .bg .vign. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 90% at 50% 50%, transparent 52%, rgba(0, 0, 0, .78) 100%);
}

@keyframes vbGridFlow { to { background-position: 0 64px, 64px 0; } }
@keyframes vbSweep {
  0%   { top: -2%; opacity: 0; }
  12%  { opacity: .55; }
  88%  { opacity: .55; }
  100% { top: 102%; opacity: 0; }
}

/* --------------------------------------------------------------------------
   3. SURFACE + TYPOGRAPHY
   Base violet-black (#090314) -> landing ink. Display type joins headings,
   labels and pills; JetBrains Mono carries meta/readouts (already shipped).
   -------------------------------------------------------------------------- */
body {
  background-color: var(--vb-ink) !important;
  color: var(--vb-text);
  font-family: var(--vb-font-body);
}

/* Display face for structural headings + eyebrow labels. */
h1, h2, h3,
[class*="uppercase"],
[class*="tracking-wider"],
[class*="tracking-widest"],
.holo-button,
.shepherd-title {
  font-family: var(--vb-font-display);
  font-weight: 700;
}

h1, h2, h3 { color: var(--vb-text); letter-spacing: .02em; }

/* Muted body copy picks up the landing's cool grey-blue. */
[class*="text-slate-400"], [class*="text-slate-500"] {
  color: var(--vb-muted) !important;
}

/* --------------------------------------------------------------------------
   4. GLASS PANELS
   Cards/panels keep their own layout; they only gain the landing's glass
   fill, cyan hairline and a soft inner lift. Scoped to structural surfaces
   so tiny inline chips are not double-glazed.
   -------------------------------------------------------------------------- */
:root [class*="rounded-xl"][class*="border"],
:root [class*="rounded-2xl"][class*="border"],
:root [class*="rounded-lg"][class*="border"] {
  border-color: var(--vb-hairline);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

:root [class*="rounded-2xl"][class*="border"] {
  box-shadow: 0 18px 48px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 255, 255, .04) inset;
}

/* --------------------------------------------------------------------------
   5. INPUTS — landing surface treatment + gold focus (landing uses gold for
   :focus-visible). `.holo-input` is the bundle's own field class.
   -------------------------------------------------------------------------- */
.holo-input,
input[class*="bg-[#02010a]"],
textarea[class*="bg-[#02010a]"] {
  background-color: var(--vb-glass-2) !important;
  border-color: var(--vb-hairline) !important;
  color: var(--vb-text) !important;
}

:root input:focus,
:root textarea:focus,
:root .holo-input:focus {
  border-color: var(--vb-gold-dim) !important;
  box-shadow: 0 0 0 1px var(--vb-gold-dim), var(--vb-glow-gold) !important;
}

input::placeholder,
textarea::placeholder { color: rgba(126, 166, 194, .55) !important; }

/* --------------------------------------------------------------------------
   6. SCROLLBARS — the landing never shows a raw OS scrollbar on a neon deck.
   -------------------------------------------------------------------------- */
* { scrollbar-color: rgba(0, 255, 255, .28) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(0, 255, 255, .35), rgba(245, 197, 66, .22));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(0, 255, 255, .55), rgba(245, 197, 66, .35)); background-clip: content-box; }

/* --------------------------------------------------------------------------
   7. LINK + SELECTION LANGUAGE (matches landing a:hover / ::selection)
   -------------------------------------------------------------------------- */
::selection { background: rgba(0, 255, 255, .28); color: #fff; }

/* ==========================================================================
   8. THE SPACE BUTTON  (.bb-spacebtn)
   --------------------------------------------------------------------------
   Faithful port of the supplied reference component:
       <button class="btn"><strong>SPACE</strong>
         <div id="container-stars"><div id="stars"></div></div>
         <div id="glow"><div class="circle"></div><div class="circle"></div></div>
       </button>
   Structure, motion and proportions are preserved exactly:
     - gradient border via the double-background technique + gradient_301 sweep
     - drifting/rotating star field behind a blurred glass well
     - two blurred orbiting glow circles (8s / 10s)
     - Orbitron label, 5px tracking, white text-shadow
     - hover: scale(1.1) and the star well rises to z-index 1
     - active: animation stops, border/star colour collapse to the deep tone

   NAMESPACING IS MANDATORY HERE. The supplied markup uses global ids
   (#container-stars / #stars / #glow), but this page ALREADY owns `#stars`,
   `#stars2` and `#stars3` inside `.bitty-starfield`, and docs/editor.html
   hides those. Reusing the bare ids would collide and kill the app's
   background. So the internals are namespaced to .bb-stars-box / .bb-stars /
   .bb-glow / .bb-circle. Behaviourally identical, collision-free.

   COLOUR: the reference is crimson (#f5434f / #631e29 / #161a25). The brief is
   "match the vibrant look of the landing page", whose palette is neon cyan +
   gold on #000814 -- so cyan is the default here for coherence.
   `.bb-spacebtn--crimson` restores the reference colours verbatim in one
   token swap, and `--gold` matches the landing's secondary accent.
   ========================================================================== */

.bb-spacebtn {
  --bb-btn-bg: #001233;
  --bb-btn-1: var(--vb-cyan);
  --bb-btn-2: #08506b;
  --bb-btn-3: #000;
  --bb-btn-4: #001233;
  --bb-glow-1: rgba(0, 255, 255, .64);
  --bb-glow-2: rgba(8, 80, 107, .70);

  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 13rem;
  height: 3rem;
  padding: 0 1.4rem;
  overflow: hidden;
  background-size: 300% 300%;
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  border-radius: 5rem;
  transition: transform .5s, color .5s, box-shadow .5s;
  animation: bbGradient 5s ease infinite;
  border: double 4px transparent;
  background-image:
    linear-gradient(var(--bb-btn-bg), var(--bb-btn-bg)),
    linear-gradient(137.48deg, var(--bb-btn-1) 10%, var(--bb-btn-2) 45%, var(--bb-btn-3) 67%, var(--bb-btn-4) 87%);
  background-origin: border-box;
  background-clip: content-box, border-box;
  font-family: var(--vb-font-display);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Landing-aligned variants */
.bb-spacebtn--cyan { /* default tokens */ }
.bb-spacebtn--gold {
  --bb-btn-bg: #1a1405;
  --bb-btn-1: var(--vb-gold);
  --bb-btn-2: #7a5f14;
  --bb-btn-3: #000;
  --bb-btn-4: #1a1405;
  --bb-glow-1: rgba(245, 197, 66, .60);
  --bb-glow-2: rgba(122, 95, 20, .70);
}
/* Reference colours, verbatim */
.bb-spacebtn--crimson {
  --bb-btn-bg: #161a25;
  --bb-btn-1: #f5434f;
  --bb-btn-2: #631e29;
  --bb-btn-3: #000000;
  --bb-btn-4: #161a25;
  --bb-glow-1: rgba(245, 67, 79, .636);
  --bb-glow-2: rgba(99, 30, 41, .704);
}

/* Label — the reference's <strong> */
.bb-spacebtn > strong,
.bb-spacebtn .bb-spacebtn-label {
  z-index: 2;
  font-family: var(--vb-font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 5px;
  color: #fff;
  text-shadow: 0 0 4px #fff;
  pointer-events: none;
  white-space: nowrap;
}

/* Star well — reference #container-stars / #stars */
.bb-stars-box {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: .5s;
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  border-radius: 5rem;
  pointer-events: none;
}
.bb-stars {
  position: relative;
  width: 200rem;
  height: 200rem;
  background: transparent;
}
.bb-stars::before {
  content: "";
  position: absolute;
  top: 0;
  left: -50%;
  width: 170%;
  height: 500%;
  background-image: radial-gradient(#fff 1px, transparent 1%);
  background-size: 50px 50px;
  opacity: .5;
  animation: bbStar 60s linear infinite;
}
.bb-stars::after {
  content: "";
  position: absolute;
  top: -10rem;
  left: -100rem;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#fff 1px, transparent 1%);
  background-size: 50px 50px;
  animation: bbStarRotate 90s linear infinite;
}

/* Orbiting glow — reference #glow / .circle */
.bb-glow {
  position: absolute;
  display: flex;
  width: 12rem;
  pointer-events: none;
}
.bb-circle {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  filter: blur(2rem);
}
.bb-circle:nth-of-type(1) { background: var(--bb-glow-1); animation: bbOrbit 8s linear infinite; }
.bb-circle:nth-of-type(2) { background: var(--bb-glow-2); animation: bbOrbit 10s linear infinite; }

.bb-spacebtn:hover { transform: scale(1.1); }
.bb-spacebtn:hover .bb-stars-box { z-index: 1; background-color: var(--bb-btn-bg); }

.bb-spacebtn:active {
  border: double 4px var(--bb-btn-2);
  background-origin: border-box;
  background-clip: content-box, border-box;
  animation: none;
}
.bb-spacebtn:active .bb-circle { background: var(--bb-btn-2); }

/* --------------------------------------------------------------------------
   9. APPLY THE SAME TREATMENT TO THE APP'S OWN PRIMARY CTA (.holo-button)
   The bundle's .holo-button is the real 280x80 GENERATE action and it cannot
   be rebuilt, so the space-button look is layered on with CSS only:
     - gradient border + 300% sweep  -> the button's own background layers
     - star field                    -> ::after (its ::before is already used
                                        by the bundle for the inner well, so
                                        ::after is the only free channel)
     - orbiting glow                 -> the bundle's existing .holo-glow child
   No node is added, removed or re-parented, so React re-renders are safe.
   -------------------------------------------------------------------------- */
:root .holo-button {
  border: double 4px transparent !important;
  border-radius: 5rem !important;
  background-image:
    linear-gradient(#000c1f, #000c1f),
    linear-gradient(137.48deg, var(--vb-cyan) 10%, #08506b 45%, #000 67%, #001233 87%) !important;
  background-origin: border-box !important;
  background-clip: content-box, border-box !important;
  background-size: 300% 300% !important;
  animation: bbGradient 5s ease infinite !important;
  transition: transform .35s ease, color .2s ease, text-shadow .2s ease !important;
  overflow: hidden;
}
:root .holo-button::after {
  content: "";
  position: absolute;
  top: -10rem;
  left: -100rem;
  width: 200rem;
  height: 200rem;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(#fff 1px, transparent 1%);
  background-size: 50px 50px;
  opacity: .35;
  animation: bbStarRotate 90s linear infinite;
}
:root .holo-button:hover {
  transform: scale(1.06);
  color: #fff !important;
  box-shadow: 0 0 34px rgba(0, 255, 255, .45) !important;
}
:root .holo-button:active {
  animation: none !important;
  border: double 4px #08506b !important;
}

/* --------------------------------------------------------------------------
   10. SECONDARY CHROME — pills, chips and small controls inherit the
   landing's cyan hairline + gold hover so the overhaul reads consistently.
   Deliberately limited to colour/border/glow: no layout is touched.
   -------------------------------------------------------------------------- */
:root button:not([disabled]) {
  transition: color .22s, background-color .22s, border-color .22s, box-shadow .22s, transform .22s;
}
:root [class*="rounded-full"][class*="border-cyan"] {
  border-color: rgba(0, 255, 255, .30) !important;
  box-shadow: var(--vb-glow-cyan);
}

/* --------------------------------------------------------------------------
   11. MOTION SAFETY — the overlay adds a live backdrop and two long-running
   animations. Honour the OS preference (ui-polish.css also collapses
   animations globally; this keeps the *backdrop* static rather than absent).
   -------------------------------------------------------------------------- */
@keyframes bbOrbit {
  from { transform: rotate(0deg) translateX(100px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(100px) rotate(-360deg); }
}
@keyframes bbStar {
  from { transform: translateY(0); }
  to   { transform: translateY(-135rem); }
}
@keyframes bbStarRotate {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0); }
}
@keyframes bbGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .bitty-starfield::before,
  .bitty-starfield::after,
  body::before,
  .bb-stars::before,
  .bb-stars::after,
  .bb-circle,
  .bb-spacebtn,
  :root .holo-button,
  :root .holo-button::after {
    animation: none !important;
  }
  body::before { opacity: .35; top: 40%; }
}

/* --------------------------------------------------------------------------
   12. REFERENCE-MARKUP COMPATIBILITY
   So the supplied button can also be pasted verbatim (bare ids intact) and
   still style correctly, the reference's id/class hooks resolve to the same
   rules when they appear inside a .bb-spacebtn. Scoped under .bb-spacebtn so
   the page's own #stars (owned by .bitty-starfield) is never affected.
   -------------------------------------------------------------------------- */
.bb-spacebtn #container-stars {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: .5s;
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  border-radius: 5rem;
  pointer-events: none;
}
.bb-spacebtn #stars {
  position: relative;
  width: 200rem;
  height: 200rem;
  background: transparent;
}
.bb-spacebtn #stars::before {
  content: "";
  position: absolute;
  top: 0;
  left: -50%;
  width: 170%;
  height: 500%;
  background-image: radial-gradient(#fff 1px, transparent 1%);
  background-size: 50px 50px;
  opacity: .5;
  animation: bbStar 60s linear infinite;
}
.bb-spacebtn #stars::after {
  content: "";
  position: absolute;
  top: -10rem;
  left: -100rem;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#fff 1px, transparent 1%);
  background-size: 50px 50px;
  animation: bbStarRotate 90s linear infinite;
}
.bb-spacebtn #glow {
  position: absolute;
  display: flex;
  width: 12rem;
  pointer-events: none;
}
.bb-spacebtn .circle {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  filter: blur(2rem);
}
.bb-spacebtn .circle:nth-of-type(1) { background: var(--bb-glow-1); animation: bbOrbit 8s linear infinite; }
.bb-spacebtn .circle:nth-of-type(2) { background: var(--bb-glow-2); animation: bbOrbit 10s linear infinite; }
.bb-spacebtn:hover #container-stars { z-index: 1; background-color: var(--bb-btn-bg); }
.bb-spacebtn:active .circle { background: var(--bb-btn-2); }
