/* PLG Funnel — Cosmic Design System */
/* TMNT Swarm Design: Raphael */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --space: #050814;
  --surface: #0A0F24;
  --surface-hover: #111833;
  --aurora: #00E5FF;
  --borealis: #00FFA3;
  --nebula: #8B5CF6;
  --red-dwarf: #FF0055;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --border: #1E293B;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.plg {
  background: var(--space);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; }

/* ── Layout ── */
.plg-container {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ── State Machine ── */
.state-view {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  position: absolute;
  width: 100%;
  max-width: 800px;
  pointer-events: none;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px;
}
.state-view.active {
  opacity: 1;
  transform: translateY(0);
  position: relative;
  pointer-events: auto;
  display: flex;
}

/* ── IDLE: Hero ── */
.hero-headline {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--aurora));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 40px;
}

/* Search Bar */
.hero-search {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: hsla(0,0%,100%,0.03);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid hsla(0,0%,100%,0.08);
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 0 0 1px hsla(0,0%,100%,0.05), 0 8px 16px -4px rgba(0,0,0,0.4), 0 20px 40px -8px rgba(0,0,0,0.6);
  transition: all 0.4s cubic-bezier(0.16,1,0.3,1);
  display: flex;
  align-items: center;
}
.hero-search:focus-within {
  border-color: var(--aurora);
  box-shadow: 0 0 0 1px var(--aurora), 0 0 0 4px hsla(187,100%,50%,0.1), 0 24px 48px -12px rgba(0,0,0,0.8);
  transform: translateY(-2px) scale(1.01);
}
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  padding: 18px 24px;
  font-family: 'Inter', sans-serif;
}
.search-input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.search-submit {
  background: var(--aurora);
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  margin-right: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.search-submit:hover { opacity: 0.85; transform: scale(1.05); }
.search-submit:disabled { opacity: 0.3; cursor: default; transform: none; }
.search-submit svg { width: 20px; height: 20px; stroke: var(--space); stroke-width: 2.5; fill: none; }

/* Prayer Bubbles */
.bubble-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.prayer-bubble {
  position: absolute;
  padding: 10px 20px;
  background: hsla(0,0%,100%,0.03);
  backdrop-filter: blur(8px);
  border: 1px solid hsla(0,0%,100%,0.06);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, opacity;
  mask-image: linear-gradient(to top, transparent, black 20%, black 80%, transparent);
  -webkit-mask-image: linear-gradient(to top, transparent, black 20%, black 80%, transparent);
}
.prayer-bubble:nth-child(1)  { --drift: 30px;  --dur: 14s; --delay: 0s;  left: 5%;  }
.prayer-bubble:nth-child(2)  { --drift:-20px;  --dur: 18s; --delay: 2s;  left: 15%; }
.prayer-bubble:nth-child(3)  { --drift: 45px;  --dur: 15s; --delay: 4s;  left: 55%; }
.prayer-bubble:nth-child(4)  { --drift:-35px;  --dur: 20s; --delay: 1s;  left: 70%; }
.prayer-bubble:nth-child(5)  { --drift: 25px;  --dur: 16s; --delay: 6s;  left: 25%; }
.prayer-bubble:nth-child(6)  { --drift:-15px;  --dur: 13s; --delay: 3s;  left: 80%; }
.prayer-bubble:nth-child(7)  { --drift: 40px;  --dur: 19s; --delay: 5s;  left: 40%; }
.prayer-bubble:nth-child(8)  { --drift:-30px;  --dur: 17s; --delay: 7s;  left: 60%; }
.prayer-bubble:nth-child(9)  { --drift: 20px;  --dur: 14s; --delay: 8s;  left: 10%; }
.prayer-bubble:nth-child(10) { --drift:-40px;  --dur: 16s; --delay: 9s;  left: 45%; }
.prayer-bubble { animation: float-ascend var(--dur) linear var(--delay) infinite; opacity: 0; }

@keyframes float-ascend {
  0%   { transform: translateY(100vh) translateX(0); opacity: 0; }
  10%  { opacity: 0.5; }
  50%  { transform: translateY(50vh) translateX(var(--drift)); opacity: 0.35; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-100px) translateX(calc(var(--drift) * -0.5)); opacity: 0; }
}

/* ── SEARCHING: Questions ── */
.question-progress {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}
.progress-dot.active { background: var(--aurora); transform: scale(1.3); }
.progress-dot.done { background: var(--borealis); }

.question-text {
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-bottom: 28px;
  line-height: 1.5;
  min-height: 2.8em;
}
.question-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}
.option-card {
  padding: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.option-card:hover { border-color: var(--aurora); background: var(--surface-hover); }
.option-card.selected { border-color: var(--aurora); background: hsla(187,100%,50%,0.1); }

.question-freetext {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}
.question-freetext:focus { border-color: var(--aurora); }
.question-freetext::placeholder { color: var(--text-secondary); opacity: 0.5; }

.calibrating-text {
  color: var(--nebula);
  font-size: 0.9rem;
  margin-top: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}
.calibrating-text.visible { opacity: 1; }

.skip-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.skip-btn:hover { color: var(--text-primary); }

.next-btn {
  background: var(--aurora);
  color: var(--space);
  border: none;
  border-radius: 12px;
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.next-btn:hover { opacity: 0.85; transform: scale(1.02); }
.next-btn:disabled { opacity: 0.3; cursor: default; transform: none; }

/* ── Spinner (Eyris-style) ── */
.plg-spinner {
  display: inline-block;
  vertical-align: middle;
  animation: plg-spin 0.8s linear infinite;
  margin-right: 6px;
}
@keyframes plg-spin { to { transform: rotate(360deg); } }

/* ── LOADING ── */
.forge-progress-wrap, .progress-wrap {
  width: 100%;
  max-width: 500px;
  margin-bottom: 32px;
}
.forge-progress-track, .progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.forge-progress-fill, .progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--aurora), var(--borealis));
  transition: width 1s ease-out;
}
.forge-progress-meta, .progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.loading-subtask {
  color: var(--text-secondary);
  font-size: 1rem;
  transition: opacity 0.4s ease, transform 0.4s ease;
  min-height: 1.5em;
}

/* ── DASHBOARD: Gold custom pack ── */
.bottery-card.custom-pack {
  border: 1px solid hsla(42, 100%, 55%, 0.4);
  background: linear-gradient(135deg, hsla(42, 100%, 55%, 0.06), var(--surface));
  grid-column: 1 / -1;
  padding: 28px 32px;
}
.bottery-card.custom-pack .card-name {
  color: #FFD700;
  font-size: 1.15rem;
}
.bottery-card.custom-pack .card-badge {
  background: hsla(42, 100%, 55%, 0.12);
  color: #FFD700;
  border-color: hsla(42, 100%, 55%, 0.25);
}
.card-caps {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card-caps li {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* ── Slack Demo ── */
.slack-demo {
  width: 100%;
  max-width: 640px;
  background: #1a1d21;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 32px;
  border: 1px solid #797c814d;
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.slack-header {
  background: #1a1d21;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #797c814d;
}
.slack-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.slack-dot.y { background: #ffbd2e; }
.slack-dot.g { background: #28c840; }
.slack-channel {
  color: #d1d2d3;
  font-size: 15px;
  font-weight: 900;
  margin-left: 10px;
}
.slack-messages { padding: 8px 0; }
.slack-msg {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.slack-msg:hover { background: #22252a; }
.slack-msg.visible { opacity: 1; transform: translateY(0); }
.slack-avatar {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
}
.slack-avatar.user { background: #4a154b; }
.slack-avatar.agent { background: linear-gradient(135deg, #003B73, #008CBA); }
.slack-msg-body { flex: 1; min-width: 0; }
.slack-msg-name {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
}
.slack-msg-name strong {
  font-size: 15px; font-weight: 900; color: #f8f8f8;
  cursor: pointer;
}
.slack-msg-name strong:hover { text-decoration: underline; }
.slack-msg-name time {
  font-size: 12px; color: #ABABAD; font-weight: 400;
  cursor: pointer;
}
.slack-msg-name time:hover { text-decoration: underline; }
.slack-msg-text {
  font-size: 15px; color: #d1d2d3; line-height: 1.46668;
  white-space: pre-wrap; word-break: break-word;
}
.slack-typing {
  color: #ABABAD; font-size: 13px;
  padding: 4px 20px 8px 64px;
  opacity: 0; transition: opacity 0.3s;
}
.slack-typing.visible { opacity: 1; }
.slack-typing-dots { display: inline-flex; gap: 3px; margin-right: 6px; }
.slack-typing-dots span {
  width: 4px; height: 4px; border-radius: 50%; background: #ABABAD;
  animation: slack-bounce 1.4s infinite;
}
.slack-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.slack-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes slack-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
.slack-btn-row {
  display: flex; gap: 8px; margin-top: 8px;
}
.slack-btn {
  font-size: 13px; font-weight: 700; padding: 4px 12px;
  border-radius: 6px; border: 1px solid #797c814d;
  cursor: default;
}
.slack-btn.primary { background: #007a5a; color: #fff; border-color: #007a5a; }
.slack-btn.secondary { background: transparent; color: #d1d2d3; }
.bottery-card.custom-pack::before {
  background: linear-gradient(135deg, #FFD700, transparent, #FFD700) !important;
}
.custom-tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 99px;
  background: hsla(42, 100%, 55%, 0.15);
  color: #FFD700;
  margin-left: 8px;
  vertical-align: middle;
}

.upgrade-banner {
  width: 100%;
  padding: 12px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, hsla(180, 100%, 45%, 0.08), hsla(160, 100%, 45%, 0.04));
  border: 1px solid hsla(180, 100%, 45%, 0.15);
  color: var(--aurora);
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: upgradePulse 3s ease-in-out infinite;
}
@keyframes upgradePulse {
  0%, 100% { border-color: hsla(180, 100%, 45%, 0.15); }
  50% { border-color: hsla(180, 100%, 45%, 0.35); }
}

/* ── DASHBOARD ── */
.dashboard-headline {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 8px;
}
.dashboard-sub {
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 700px;
  margin-bottom: 40px;
}
.bottery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  position: relative;
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transition: opacity 650ms cubic-bezier(0.19,1,0.22,1), transform 650ms cubic-bezier(0.19,1,0.22,1);
}
.bottery-card.revealed { opacity: 1; transform: translateY(0) scale(1); }
.bottery-card:nth-child(1) { transition-delay: 0ms; }
.bottery-card:nth-child(2) { transition-delay: 80ms; }
.bottery-card:nth-child(3) { transition-delay: 160ms; }
.bottery-card:nth-child(4) { transition-delay: 240ms; }
.bottery-card:nth-child(5) { transition-delay: 320ms; }

.bottery-card.active::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--aurora), transparent, var(--aurora));
  opacity: 0;
  animation: card-breathe 3s ease-in-out infinite;
  z-index: -1;
}
@keyframes card-breathe {
  0%   { opacity: 0.15; }
  50%  { opacity: 0.4; }
  100% { opacity: 0.15; }
}
.card-name { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.card-desc { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.4; }
.card-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.card-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 99px;
  background: hsla(187,100%,50%,0.08);
  color: var(--aurora);
  border: 1px solid hsla(187,100%,50%,0.15);
}

.deploy-section { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 24px; }
.deploy-btn {
  padding: 12px 28px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deploy-btn:hover { border-color: var(--aurora); background: var(--surface-hover); }
.deploy-btn svg { width: 18px; height: 18px; }

.trust-line {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 16px;
}

/* ── Logo ── */
.plg-logo {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.plg-logo img { height: 28px; }
.plg-logo span { color: var(--text-primary); font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.1rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero-headline { font-size: 1.8rem; }
  .search-input { font-size: 1rem; padding: 14px 16px; }
  .question-text { font-size: 1.1rem; }
  .prayer-bubble { font-size: 11px; padding: 8px 14px; }
  .skeleton-grid, .pack-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .prayer-bubble { animation: none; opacity: 0.3; }
  .skeleton-card::after { animation: none; }
  .bottery-card.active::before { animation: none; opacity: 0.25; }
}

/* ── Demo Preview ── */
.demo-preview {
  width: 100%;
  max-width: 600px;
  margin: 32px auto;
  opacity: 0;
  transform: translateY(12px);
}
.demo-preview.fade-in {
  animation: fade-up 0.6s ease-out forwards;
}
@keyframes fade-up {
  to { opacity: 1; transform: translateY(0); }
}
.demo-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.demo-conversation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: left;
}
.demo-msg { margin-bottom: 16px; }
.demo-msg:last-child { margin-bottom: 0; }
.demo-role {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.demo-user .demo-role { color: var(--text-secondary); }
.demo-bot .demo-role { color: var(--aurora); }
.demo-user span:last-child { color: var(--text-secondary); font-size: 0.95rem; }
.demo-bot span:last-child { color: var(--text-primary); font-size: 0.95rem; line-height: 1.5; white-space: pre-line; }

/* ── Error State ── */
#state-error .next-btn { margin-top: 8px; }
