/* =========================================================
   Glitch transition layer (fx.js)
   ========================================================= */
.fx-backdrop { position: fixed; inset: 0; z-index: 0; background: #000; opacity: 0; pointer-events: none; }
.fx-backdrop.on { opacity: 1; }
.page.fx-full { will-change: transform, filter; }
.page.fx-lite { will-change: transform; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.page.fx-crt { position: relative; z-index: 1; }

.fx-layer { position: fixed; inset: 0; z-index: 9000; pointer-events: none; visibility: hidden; overflow: hidden; }
.fx-layer.on { visibility: visible; }
.fx-noise { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; }
.fx-scan {
  position: absolute; inset: 0; opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.38) 0 1px, transparent 1px 3px);
}
.fx-bars { position: absolute; inset: 0; }
.fx-bars i { position: absolute; display: block; }
.fx-bars b { position: absolute; left: -4%; right: -4%; display: block; }
.fx-line {
  position: absolute; left: -5%; right: -5%; top: 50%; height: 3px; margin-top: -1.5px; opacity: 0;
  background: #fff; box-shadow: 0 0 18px 6px rgba(255,255,255,.85), 0 0 70px 24px var(--accent);
}
.fx-flash { position: absolute; inset: 0; background: #fff; opacity: 0; mix-blend-mode: overlay; }

/* =========================================================
   Peek-in characters + agent speech bubbles
   ========================================================= */
.peek-clip {
  position: absolute; left: 0; right: 0; top: 0; bottom: calc(var(--avatar) / -2 - 4px);
  overflow: hidden; pointer-events: none; z-index: 5;
}
.peek { position: absolute; bottom: 0; opacity: 0; transition: transform .55s cubic-bezier(.2, 1.35, .4, 1), opacity .25s ease; }
.peek img { width: 100%; height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.peek-left { left: 0; width: calc(var(--avatar) * 1.15); transform-origin: 50% 100%; transform: translateX(-115%) rotate(-4deg); }
.peek-left.in { opacity: 1; transform: translateX(0%) rotate(-9deg); animation: peek-bob 1.1s ease-in-out .55s infinite alternate; }
.peek-right { right: 0; width: calc(var(--avatar) * 1.04); transform-origin: 100% 100%; transform: translateX(115%) rotate(6deg); }
.peek-right.in { opacity: 1; transform: translateX(8%) rotate(-3deg); }
@keyframes peek-bob { to { translate: 0 -4px; } }

.bubble {
  position: absolute; z-index: 7; max-width: min(62%, 236px); padding: 8px 11px 9px;
  border-radius: 12px; background: rgba(10, 12, 24, .93); color: #f4f1ea;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.75), 0 0 22px -8px var(--accent);
  font: 600 12.5px/1.38 var(--font-mono, ui-monospace, monospace); letter-spacing: 0;
  opacity: 0; transform: translateY(8px) scale(.9); transition: opacity .2s ease, transform .3s cubic-bezier(.2, 1.4, .4, 1);
  pointer-events: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.bubble.in { opacity: 1; transform: none; }
.bubble::after {
  content: ""; position: absolute; bottom: -6px; width: 11px; height: 11px; transform: rotate(45deg);
  background: inherit; border: inherit; border-top: 0; border-left: 0;
}
.bubble-left { left: 10px; bottom: 54px; transform-origin: 20% 100%; }
.bubble-left::after { left: 26px; }
.bubble-right { right: 10px; bottom: 70px; text-align: left; transform-origin: 80% 100%; }
.bubble-right::after { right: 30px; }
.bubble .who {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font: 700 9.5px/1 var(--font-mono, ui-monospace, monospace); letter-spacing: .12em; text-transform: uppercase; color: #e58a66;
}
.bubble .who i { width: 7px; height: 7px; border-radius: 2px; background: #da7756; box-shadow: 0 0 8px #da7756; }
.bubble-right .who { color: #f6b62f; }
.bubble-right .who i { border-radius: 50%; background: #f6b62f; box-shadow: 0 0 8px #f6b62f; }
.bubble .caret { display: inline-block; width: 7px; height: 13px; margin-left: 2px; vertical-align: -2px; background: currentColor; animation: fx-blink .9s steps(1) infinite; }
.bubble.typing .txt::before { content: "● ● ●"; letter-spacing: .1em; opacity: .7; animation: fx-think .6s ease-in-out infinite alternate; }
.bubble.typing .caret { display: none; }
@keyframes fx-blink { 50% { opacity: 0; } }
@keyframes fx-think { from { opacity: .3; } to { opacity: .9; } }

/* theme button Claude is pointing at */
.theme-seg button { transition: none !important; }
.theme-seg button.fx-target { animation: fx-target .7s ease-in-out infinite alternate; }
@keyframes fx-target { to { box-shadow: 0 0 0 2px var(--accent), 0 0 18px 2px var(--accent); color: var(--ink); } }

/* auto-cycle pause / play */
.fx-toggle {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: var(--card-bg); color: var(--ink-dim); font: 700 10px/1 var(--font-body); letter-spacing: -.05em;
  display: grid; place-items: center;
}
@media (hover: hover) { .fx-toggle:hover { color: var(--ink); border-color: var(--accent); } }
.fx-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root[data-theme="terminal"] .fx-toggle { border-radius: 2px; }

@media (min-width: 960px) {
  .bubble { font-size: 13px; }
  .bubble-right { bottom: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  .peek, .bubble { display: none; }
}

/* =========================================================
   Fly-by: a jet (LateB), a Cessna (Vice) or a light cycle (Dev)
   tows a "Scroll down for latest video!" sign across the banner,
   behind the banner titles and behind the round avatar.
   Train height ~ avatar; its centre sits 10px below the avatar's top.
   ========================================================= */
.lb-title, .lb-prompt, .art-terminal pre { position: relative; z-index: 2; }
.lb-title, .lb-prompt { position: absolute; }
/* keep the big title readable while the sign passes behind it */
.flyby.go ~ * .lb-title, .lb-title { text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 0 2px rgba(12,13,29,.9), 0 0 14px rgba(12,13,29,.6); }
.flyby {
  --fb-h: var(--avatar);
  position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none;
  height: var(--fb-h); top: calc(var(--banner-h) - var(--avatar) / 2 + 10px - var(--fb-h) / 2);
}
.fb-track { position: absolute; inset: 0; transform: translateX(0); }
.fb-train {
  position: absolute; left: 100%; top: 0; height: 100%;
  display: flex; flex-direction: row-reverse; align-items: center; gap: 0; /* craft | rope | sign */
}
/* fx.js adds .go for one pass, right to left (the sign then reads like a ticker). Both layers move
   together: track 0 -> -100% of the banner, train 0 -> -100% of itself = fully off-right to fully off-left. */
.flyby:not(.go) { visibility: hidden; }
.flyby.go .fb-track { animation: fb-track var(--fb-dur, 6.4s) linear 1 both; }
.flyby.go .fb-train { animation: fb-train var(--fb-dur, 6.4s) linear 1 both; }
@keyframes fb-track { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes fb-train { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.fb-sign {
  position: relative; flex: none; height: calc(var(--fb-h) * .6); display: flex; align-items: center;
  padding: 0 20px 0 22px; pointer-events: auto; cursor: pointer;
  font: 400 clamp(19px, 5.6vw, 25px)/1 "Anton", "Impact", sans-serif; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
  color: #fff; background-color: #e8263a;
  border-left: 4px solid #f6b62f; border-right: 6px solid #f6b62f;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  box-shadow: 0 6px 14px -6px rgba(0,0,0,.7), inset 0 0 0 1px rgba(0,0,0,.12);
  transform-origin: 0% 50%; animation: fb-wave 1.1s ease-in-out infinite alternate;
  /* fabric folds */
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 2px, transparent 2px 46px), linear-gradient(180deg, rgba(255,255,255,.35), rgba(0,0,0,.08));
}
@keyframes fb-wave { from { transform: skewY(-1.4deg) scaleY(.97); } to { transform: skewY(1.4deg) scaleY(1.02); } }
.fb-rope { flex: none; transform: scaleX(-1); width: 34px; height: calc(var(--fb-h) * .6); overflow: visible; }
.fb-rope path { fill: none; stroke: rgba(240,236,224,.8); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.fb-craft { display: none; flex: none; transform: scaleX(-1); /* art faces right; fly left */ height: calc(var(--fb-h) * .82); width: auto; max-width: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.45)); }
:root[data-theme="late-build"] .fb-jet,
:root[data-theme="vice-city"] .fb-cessna,
:root[data-theme="terminal"] .fb-cycle { display: block; }
:root[data-theme="nodal"] .fb-jet, :root[data-theme="studio-light"] .fb-jet { display: block; }
.fb-jet { margin-right: -6px; animation: fb-bob 1.6s ease-in-out infinite alternate; }
.fb-cessna { height: calc(var(--fb-h) * .9); margin-right: -4px; animation: fb-bob 1.2s ease-in-out infinite alternate; }
@keyframes fb-bob { from { translate: 0 -3px; rotate: -1deg; } to { translate: 0 3px; rotate: 1deg; } }

/* Vice: classic beach-banner look */
:root[data-theme="vice-city"] .fb-sign {
  font-family: "Rubik", sans-serif; font-weight: 800; font-size: clamp(17px, 5vw, 23px); letter-spacing: .01em;
  color: #ff2d95; background-color: #fff8fb; border-left-color: #22e4ff; border-right-color: #ff8a3d;
  text-shadow: 0 1px 0 #fff;
}
/* Dev: the light cycle projects a holographic sign and leaves a light trail instead of a rope */
:root[data-theme="terminal"] .flyby { --fb-dur: 5.6s; }
:root[data-theme="terminal"] .fb-sign {
  font: 700 clamp(15px, 4.6vw, 20px)/1 var(--font-mono); text-transform: none; letter-spacing: 0;
  color: #39ff88; background: rgba(4, 20, 10, .78); border: 1.5px solid #39ff88; border-left-width: 1.5px;
  box-shadow: 0 0 14px rgba(57,255,136,.55), inset 0 0 18px rgba(57,255,136,.18);
  text-shadow: 0 0 8px rgba(57,255,136,.8); animation: fb-holo 1.4s steps(2) infinite;
  background-image: repeating-linear-gradient(0deg, rgba(57,255,136,.10) 0 1px, transparent 1px 4px);
}
:root[data-theme="terminal"] .fb-sign::before { content: "> "; opacity: .7; white-space: pre; }
@keyframes fb-holo { 50% { opacity: .86; } }
:root[data-theme="terminal"] .fb-rope { width: 60px; }
:root[data-theme="terminal"] .fb-rope path { d: path("M0 30 L40 30"); stroke: #39ff88; stroke-width: 3; filter: drop-shadow(0 0 4px #39ff88); }
:root[data-theme="terminal"] .fb-cycle { height: calc(var(--fb-h) * .86); margin-right: -6px; }

@media (prefers-reduced-motion: reduce) { .flyby { display: none; } }
