/* ==========================================================================
   EPORTAL RETRO ANIMATION ENGINE — SHARED EFFECTS (Composio Bench Edition)
   ========================================================================== */

:root {
  --violet: #c4a6ef;
  --mint: #8bdbc4;
  --amber: #f0c27b;
  --panel: #17182b;
  --bg: #0d101c;
}

[data-reactive-scene] {
  position: relative;
  isolation: isolate;
}

.retro-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  image-rendering: pixelated;
  opacity: 0.98;
  mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
}

[data-reactive-scene] > * {
  position: relative;
  z-index: 1;
}

/* Hero Canvas Layering */
.hero .hero-bottom { position: absolute; z-index: 2; }
.hero .courtyard { object-position: 70% center; }
.hero .world-shade {
  background: linear-gradient(90deg, #0d101ce8 0%, #0d101caa 35%, #0d101c25 72%), linear-gradient(0deg, #0d101c, transparent 26%);
}
.hero .portal-light { right: 9%; top: 12%; width: 34%; height: 67%; opacity: 0.85; }

/* Header Controls & Telemetry Pills */
.effects-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
  z-index: 3;
}
.effects-controls button, .retro-btn {
  font: 10px/1.4 var(--mono, monospace);
  padding: 6px 10px;
  color: #c4b7d9;
  border: 1px solid #c4a6ef40;
  background: #17182be0;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-transform: uppercase;
}
.effects-controls button:hover, .effects-controls button[aria-pressed=true], .retro-btn:hover, .retro-btn.active {
  color: var(--mint);
  border-color: #8bdbc488;
  background: #1b2b31;
  box-shadow: 0 0 10px #8bdbc425;
}
.effects-controls button:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
.effects-controls button:disabled {
  color: #b8afc8;
  cursor: default;
}

.site-nav {
  height: auto;
  min-height: 82px;
  flex-wrap: wrap;
  padding-top: 15px;
  padding-bottom: 15px;
  gap: 12px;
}
.site-nav .effects-controls { margin-left: auto; }
.site-nav nav { gap: 18px; }
.site-nav .nav-badge { display: inline-flex; align-items: center; }
.site-nav .portal-utilities { margin-left: 0; }

/* Real-Time Telemetry HUD Readout */
.tracker-hud {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 10px/1 monospace;
  color: var(--mint);
  background: #090d19e0;
  border: 1px solid #8bdbc440;
  padding: 5px 10px;
  margin-top: 12px;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 12px #8bdbc412;
  letter-spacing: 0.5px;
}
.tracker-hud .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint);
  animation: hudPulse 1.6s ease-in-out infinite;
}
@keyframes hudPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.25); }
}
.tracker-hud span.muted {
  color: var(--muted);
}

/* Living Pixel Crew & Speech Bubbles */
.pixel-bubble {
  position: absolute !important;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translate(-50%, 6px);
  width: max-content;
  max-width: 240px;
  padding: 8px 12px !important;
  border: 1px solid var(--amber) !important;
  background: #151726f5 !important;
  color: #f1ebdf !important;
  font: 10px/1.4 var(--mono, monospace) !important;
  letter-spacing: 0 !important;
  white-space: normal !important;
  text-align: center;
  box-shadow: 4px 4px 0 #050813;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}
.pixel-bubble:after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  background: #151726;
  border-right: 1px solid var(--amber);
  border-bottom: 1px solid var(--amber);
  transform: rotate(45deg);
}

[data-agent], [data-character], .guide-character, .crew-member {
  position: relative;
  cursor: pointer;
}
[data-agent]:hover > .pixel-bubble, [data-agent]:focus-visible > .pixel-bubble, [data-agent].agent-celebrate > .pixel-bubble,
[data-character]:hover > .pixel-bubble, [data-character]:focus-visible > .pixel-bubble,
.guide-character:hover > .pixel-bubble, .crew-member:hover > .pixel-bubble {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Eye Tracking Pupils */
.sprite-eyes > rect, .keeper-eyes > rect {
  transform-box: fill-box;
  transition: transform 0.08s linear;
}
.character .sprite-eyes, .guide-character .sprite-eyes {
  transform-origin: center;
  transform-box: fill-box;
  animation: retro-blink 5.8s steps(1) infinite;
}
@keyframes retro-blink {
  0%, 92%, 96%, 100% { scale: 1 1; }
  94% { scale: 1 0.12; }
}

/* Interactive Bayer Dither Progress Bars */
canvas[data-dither], .bench-canvas {
  display: block;
  width: 100%;
  height: 14px;
  image-rendering: pixelated;
  background: #8bdbc40c;
  border-bottom: 1px solid #8bdbc425;
}

/* Composio-Inspired Benchmark Leaderboard Widget */
.benchmark-widget {
  margin: 24px 0;
  border: 1px solid #c4a6ef35;
  background: var(--panel);
  padding: 22px;
  box-shadow: 4px 4px #050814;
}
.bench-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid #c4a6ef20;
  padding-bottom: 14px;
}
.bench-title {
  font: 22px Pixelify, monospace;
  color: var(--violet);
  margin: 0;
}
.bench-tabs {
  display: flex;
  gap: 8px;
}
.bench-tab {
  background: #090d19;
  border: 1px solid #c4a6ef30;
  color: var(--muted);
  font: 10px monospace;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
}
.bench-tab:hover {
  color: var(--ink);
  border-color: var(--violet);
}
.bench-tab.active {
  background: #8bdbc418;
  border-color: var(--mint);
  color: var(--mint);
  box-shadow: 0 0 10px #8bdbc418;
}
.bench-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bench-row {
  display: grid;
  grid-template-columns: 200px 1fr 90px;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: #0d101c80;
  border: 1px solid #c4a6ef18;
  transition: all 0.18s ease;
  cursor: default;
}
.bench-row:hover {
  background: #c4a6ef12;
  border-color: var(--violet);
  transform: translateX(3px);
  box-shadow: 0 0 16px #c4a6ef12;
}
.bench-name {
  font: 12px monospace;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bench-tag {
  font: 9px monospace;
  padding: 2px 4px;
  border: 1px solid #8bdbc450;
  color: var(--mint);
}
.bench-canvas-wrap {
  height: 14px;
  position: relative;
  width: 100%;
}
.bench-score {
  font: 11px monospace;
  color: var(--mint);
  text-align: right;
  tabular-nums: true;
}

/* Sections & Hall Styling */
.explanation {
  background: linear-gradient(#0d101c88, #0d101ccf), url('/assets/handover-islands.webp') center/cover;
  min-height: 520px;
  margin-top: 34px;
  border: 1px solid #c4a6ef35;
  padding-top: 65px;
  padding-bottom: 65px;
}
.explanation-grid article { padding: 22px; background: #0d101ce8; border: 1px solid #c4a6ef35; }
.explanation .principle { background: #0d101ce8; padding: 17px 22px; }

.architecture {
  position: relative;
  background: linear-gradient(#0d101cb3, #0d101cf2), url('/assets/relay-courtyard.webp') center 65%/cover;
}
.architecture-grid { background: #131525ef; }
.architecture-grid article { background: transparent; }

.workspace-main { position: relative; isolation: isolate; background: #0d101c; }
.workspace-banner {
  min-height: 230px;
  padding: 30px 36px 23px;
  overflow: hidden;
  border-bottom: 1px solid #c4a6ef38;
  display: flex;
  align-items: flex-end;
  background: #111323;
  position: relative;
}
.workspace-banner:before {
  content: '';
  position: absolute;
  inset: -10px;
  background: linear-gradient(90deg, #0d101cec, #0d101c65), linear-gradient(0deg, #0d101caa, transparent), url('/assets/collaboration-hall.webp') center 61%/cover;
  transform: translate(var(--scene-x, 0px), var(--scene-y, 0px));
  z-index: -1;
  image-rendering: pixelated;
}
.workspace-banner-copy { position: relative; z-index: 1; max-width: 480px; }
.workspace-banner h2 { font: 38px/1.1 Pixelify, monospace; margin: 10px 0; color: #f1ebdf; }
.workspace-banner p { font: 11px/1.8 monospace; color: #c1b9ce; }
.workspace-banner .eyebrow { color: var(--mint); font-size: 8px; letter-spacing: 1.5px; }
.workspace-banner .micro-label { border: 1px solid #c4a6ef40; background: #101221d9; padding: 5px 8px; color: #d3c0ea; }

.sample-progress { margin-top: 18px; padding-top: 15px; border-top: 1px solid #c4a6ef25; }
.sample-progress-label { display: flex; justify-content: space-between; font: 9px/1.5 monospace; color: #c7bad8; margin-bottom: 9px; gap: 12px; }

/* Interactive Hover Glow on Cards & Rows */
.run-item, .check-row, .crew-card, .connection-card, .task-card, .card, article {
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}
.crew-card:hover, .task-card:hover, .connection-card:hover, .card:hover {
  border-color: #c4a6ef88;
  box-shadow: 0 0 28px #c4a6ef15, 4px 4px #060914;
  transform: translateY(-2px);
}
.run-item:hover, .run-item:focus-within, .check-row:hover { background: #c4a6ef0e; }
.run-item.active {
  position: relative;
  outline: 1px solid #8bdbc466;
  outline-offset: 4px;
  box-shadow: 0 0 22px #8bdbc412;
}
.run-item.active:after {
  content: '';
  position: absolute;
  right: -5px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--mint);
  border-right: 2px solid var(--mint);
}

/* CRT Phosphor Scanlines & Screen Curvature Overlay */
body.crt-mode:before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px),
              linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 3px, 6px 100%;
}
body.crt-mode:after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 65%, rgba(6, 8, 18, 0.45) 100%);
  box-shadow: inset 0 0 120px #06081388;
}

.motion-paused .retro-canvas { opacity: 0.65; }
.motion-paused .workspace-banner:before { transform: none !important; }
.motion-paused .sprite-eyes > rect { transform: none !important; transition: none; }

/* Responsive adjustments */
@media(max-width: 1000px) {
  .site-nav nav { margin-left: auto; }
  .site-nav .effects-controls { margin-left: 0; }
  .workspace-banner { min-height: 215px; }
  .bench-row { grid-template-columns: 140px 1fr 70px; }
}
@media(max-width: 650px) {
  .effects-controls button { font-size: 8px; padding: 6px; }
  .site-nav nav { margin-left: 0; }
  .hero .courtyard { object-position: 68% center; opacity: 0.88; }
  .explanation { margin-top: 15px; min-height: 0; padding-top: 40px; padding-bottom: 40px; }
  .explanation-grid article { padding: 18px; }
  .workspace-banner { min-height: 200px; padding: 26px 20px; }
  .workspace-banner h2 { font-size: 31px; }
  .pixel-bubble { max-width: 160px; font-size: 8px !important; }
  .bench-row { grid-template-columns: 1fr; gap: 6px; }
  .bench-score { text-align: left; }
}

@media(prefers-reduced-motion: reduce) {
  .retro-canvas { opacity: 0.65; }
  .sprite-eyes > rect { transform: none !important; transition: none !important; }
  .pixel-bubble { transition: none; }
  .workspace-banner:before { transform: none !important; }
}

@media print {
  .retro-canvas, .effects-controls { display: none !important; }
  body.crt-mode:before, body.crt-mode:after { display: none !important; }
}
