/*
  filename: autopilot.css
  description: Hero "Show me the magic" CTA + autopilot overlay (caption bar, progress dock, panel iframes, completion card, confetti). Desktop-only.
  Author: Rodrigo Careaga
  Date: 03-05-2026
*/

/* ============================================================ Hero CTA */
.autopilot-cta-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 18px 0 8px 0;
}

.autopilot-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 26px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font: 600 15.5px/1 "Inter", sans-serif;
  letter-spacing: 0.2px;
  color: var(--white);
  background: linear-gradient(135deg, var(--teal) 0%, var(--blue) 45%, var(--pink) 100%);
  background-size: 220% 220%;
  box-shadow:
    0 10px 30px rgba(27, 169, 245, 0.35),
    0 4px 12px rgba(240, 78, 152, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: ap-gradient 8s ease infinite;
  transition: transform 160ms var(--easing), box-shadow 160ms var(--easing);
}
.autopilot-cta:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 14px 38px rgba(27, 169, 245, 0.45),
    0 6px 18px rgba(240, 78, 152, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.autopilot-cta:active { transform: translateY(0) scale(0.99); }
.autopilot-cta:disabled { opacity: 0.7; cursor: progress; }

.autopilot-cta .ap-icon {
  font-size: 18px;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.45));
}
.autopilot-cta .ap-label { font-weight: 700; }
.autopilot-cta .ap-sub {
  margin-left: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font: 500 11px/1 "Inter", sans-serif;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.autopilot-cta.is-running { animation: ap-gradient 3s ease infinite, ap-pulse 1.4s ease-in-out infinite; }
@keyframes ap-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes ap-pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(27, 169, 245, 0.35), 0 4px 12px rgba(240, 78, 152, 0.25); }
  50% { box-shadow: 0 14px 44px rgba(27, 169, 245, 0.65), 0 6px 22px rgba(240, 78, 152, 0.5); }
}

.autopilot-hint {
  font: 500 12px/1.4 "Inter", sans-serif;
  color: var(--muted);
  max-width: 360px;
}

/* ============================================================ Caption bar */
.ap-caption-bar {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -28px);
  z-index: 9100;
  min-width: 320px;
  max-width: min(820px, 92vw);
  padding: 12px 22px;
  border-radius: 14px;
  background: rgba(20, 26, 36, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  color: #fff;
  font: 600 14.5px/1.4 "Inter", sans-serif;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms var(--easing), transform 280ms var(--easing);
}
.ap-caption-bar.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.ap-caption-bar .ap-cap-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ap-caption-bar .ap-cap-step {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #00BFB3, #1BA9F5);
  font: 700 11px/1.6 "Inter", sans-serif;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.ap-caption-bar .ap-cap-text { flex: 1; min-width: 0; }
.ap-caption-bar .ap-cap-stop {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255, 100, 100, 0.45);
  background: rgba(220, 38, 38, 0.18);
  color: #fecaca;
  font: 600 11px/1 "Inter", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.ap-caption-bar .ap-cap-stop:hover {
  background: rgba(220, 38, 38, 0.32);
  color: #ffffff;
}
.ap-caption-bar .ap-cap-sub {
  display: none;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font: 400 12.5px/1.5 "Inter", sans-serif;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.ap-caption-bar .ap-cap-sub.is-visible { display: block; }

/* ============================================================ Progress dock */
.ap-progress-dock {
  position: fixed;
  top: 96px;
  right: 22px;
  z-index: 9050;
  width: 220px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(20, 26, 36, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 280ms var(--easing), transform 280ms var(--easing);
  pointer-events: none;
}
.ap-progress-dock.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.ap-dock-title {
  font: 700 11px/1 "Inter", sans-serif;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ap-dock-count { color: #fff; font-weight: 800; }
.ap-dock-list { display: flex; flex-direction: column; gap: 6px; }
.ap-dock-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 12px/1.3 "Inter", sans-serif;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 200ms, color 200ms;
}
.ap-dock-step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.ap-dock-step.is-active {
  background: rgba(27, 169, 245, 0.14);
  color: #fff;
}
.ap-dock-step.is-active .num {
  background: linear-gradient(135deg, #00BFB3, #1BA9F5);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(27, 169, 245, 0.18);
}
.ap-dock-step.is-done {
  color: var(--ink-soft);
}
.ap-dock-step.is-done .num {
  background: var(--green);
  color: #1A1F26;
}
.ap-dock-step.is-failed .num {
  background: var(--red);
  color: #fff;
}

.ap-dock-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.ap-dock-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font: 600 11.5px/1 "Inter", sans-serif;
  cursor: pointer;
  transition: background 160ms;
}
.ap-dock-btn:hover { background: rgba(255, 255, 255, 0.1); }
.ap-dock-btn.danger { border-color: rgba(246, 102, 102, 0.45); color: #ffb4b4; }
.ap-dock-btn.danger:hover { background: rgba(246, 102, 102, 0.18); }

/* ============================================================ Panel stage
   The stage is a cinematic overlay (autopilot demo mode). It stays dark in
   both themes by design so iframes and panels read as a presenter view. We
   keep the dark scrim regardless of --scrim so the visuals stay consistent
   when judges watch the auto-driving sequence. */
.ap-stage {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: radial-gradient(ellipse at 30% 20%, rgba(27, 169, 245, 0.22), transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(240, 78, 152, 0.18), transparent 60%),
              rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--easing);
}
.ap-stage.is-visible { opacity: 1; pointer-events: auto; }

.ap-panel {
  position: absolute;
  top: 110px;
  bottom: 110px;
  left: 60px;
  right: 280px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.985) translateY(8px);
  transition: opacity 320ms var(--easing), transform 320ms var(--easing);
}
.ap-panel.is-visible { opacity: 1; transform: scale(1) translateY(0); }
.ap-panel.is-dragging { transition: none; user-select: none; }
.ap-panel.is-dragging iframe { pointer-events: none; }

.ap-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font: 600 12px/1 "Inter", sans-serif;
  color: var(--ink-soft);
  cursor: move;
  user-select: none;
}
.ap-panel-head .title { font-weight: 700; }
.ap-panel-head .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-panel-reset {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-soft);
  font: 600 10.5px/1 "Inter", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.ap-panel-reset:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.ap-panel-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.ap-panel-head .url { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11.5px; }
.ap-panel iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg);
}

/* ============================================================ Completion card */
.ap-complete {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 12px));
  z-index: 9200;
  width: min(560px, 92vw);
  padding: 28px 30px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(20, 26, 36, 0.96), rgba(34, 40, 52, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--easing), transform 320ms var(--easing);
}
.ap-complete.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.ap-complete h3 {
  margin: 0 0 6px 0;
  font-size: 22px;
  background: linear-gradient(135deg, #00BFB3, #1BA9F5, #F04E98);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ap-complete p { margin: 0 0 18px 0; color: var(--ink-soft); font-size: 14px; }
.ap-complete .ap-stat-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--muted);
}
.ap-complete .ap-stat strong { color: #fff; font-size: 16px; display: block; }
.ap-complete .ap-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.ap-complete .ap-btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: 600 13px/1 "Inter", sans-serif;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ap-complete .ap-btn:hover { background: rgba(255, 255, 255, 0.12); }
.ap-complete .ap-btn.primary {
  background: linear-gradient(135deg, #00BFB3, #1BA9F5);
  border: 0;
  box-shadow: 0 8px 24px rgba(27, 169, 245, 0.35);
}
.ap-complete .ap-btn.ap-btn-kibana {
  background: linear-gradient(135deg, #FEC514, #F04E98);
  border: 0;
  color: #07080c;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(254, 197, 20, 0.35);
  order: -1;
}
.ap-complete .ap-btn.ap-btn-kibana:hover { opacity: 0.9; background: linear-gradient(135deg, #FEC514, #F04E98); }

/* ============================================================ Confetti */
.ap-confetti-host {
  position: fixed;
  inset: 0;
  z-index: 9300;
  pointer-events: none;
  overflow: hidden;
}
.ap-confetti {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: ap-confetti-fall 1800ms ease-out forwards;
}
@keyframes ap-confetti-fall {
  0%   { opacity: 0; transform: translate(0, -10vh) rotate(0deg); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--ap-dx, 40px), 110vh) rotate(720deg); }
}

/* ============================================================ Top progress bar
   Thin, determinate progress bar mounted at the very top of the autopilot stage.
   Reuses the .progress-bar primitive from styles.css; this scopes positioning and
   adds a step-transition pulse. */
.ap-top-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9150;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 0;
}
.ap-top-progress .progress-bar-fill {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-soft);
  border-radius: 0;
}
.ap-top-progress.is-pulsing {
  animation: ap-progress-pulse 200ms ease-out;
}
@keyframes ap-progress-pulse {
  0%   { transform: scaleY(1); }
  50%  { transform: scaleY(1.02); }
  100% { transform: scaleY(1); }
}

/* ============================================================ Mobile */
@media (max-width: 768px) {
  .autopilot-cta-wrap { display: none !important; }
  .ap-stage, .ap-progress-dock, .ap-caption-bar { display: none !important; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .autopilot-cta,
  .autopilot-cta.is-running,
  .ap-confetti {
    animation: none !important;
  }
  .ap-top-progress,
  .ap-top-progress.is-pulsing {
    animation: none !important;
  }
}
