/* =============================================================
   Optimizate Labs — Entrevista de descubrimiento
   Tokens y lenguaje visual portados de optimizate-labs-3.0
   ============================================================= */
:root {
  --bg:        #0a0b0f;
  --bg-2:      #12141a;
  --bg-3:      #181b22;
  --ink:       #f4f5f7;
  --ink-soft:  #d6dae1;
  --mute:      #9aa1ad;
  --accent:    #5b8cff;
  --accent-2:  #8b5cf6;
  --grad-1:    #3a86ff;
  --grad-2:    #8b5cf6;
  --grad-3:    #22d3ee;
  --line:      rgba(244,245,247,0.12);
  --line-soft: rgba(244,245,247,0.07);

  --serif:  "Space Grotesk", system-ui, sans-serif;
  --sans:   "Inter", system-ui, -apple-system, sans-serif;
  --mono:   "JetBrains Mono", ui-monospace, "Courier New", monospace;

  --pad: clamp(1.1rem, 5vw, 2.4rem);
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --r:   14px;
  --r-lg: 22px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
input, textarea { font: inherit; color: inherit; }
h1, h2, h3 {
  font-family: var(--serif);
  color: var(--ink);
  text-wrap: balance;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 600;
}
::selection { background: var(--accent); color: #06070a; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* --- Fondo con gradiente reactivo (estático, sutil) --- */
.bg-gradient {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60vw 60vw at 15% 0%, rgba(58,134,255,0.18), transparent 60%),
    radial-gradient(55vw 55vw at 100% 20%, rgba(139,92,246,0.16), transparent 60%),
    radial-gradient(50vw 50vw at 50% 100%, rgba(34,211,238,0.10), transparent 60%);
  filter: saturate(1.1);
}

/* --- Topbar --- */
.topbar {
  position: fixed; top: 0; inset-inline: 0; z-index: 20;
  display: flex; align-items: center;
  padding: 1rem var(--pad);
}
.brand { display: inline-flex; align-items: center; color: var(--ink); }
.brand-text { font-family: var(--serif); font-weight: 700; font-size: 1.18rem; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent); }

/* --- Stage / pantallas --- */
.stage { position: relative; min-height: 100dvh; }
.screen {
  position: absolute; inset: 0;
  display: none;
  opacity: 0;
  transition: opacity .5s var(--ease-out);
}
.screen.is-active { display: flex; opacity: 1; }

.kicker {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

/* =============================================================
   Pantalla 1 — Bienvenida
   ============================================================= */
.screen--welcome {
  align-items: center; justify-content: center;
  padding: 6rem var(--pad) 3rem;
}
.welcome-inner {
  width: 100%; max-width: 560px;
  animation: rise .7s var(--ease-out) both;
}
.welcome-title {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}
.welcome-lead { color: var(--mute); font-size: 1.05rem; max-width: 52ch; }
.welcome-lead strong { color: var(--ink-soft); font-weight: 600; }

.welcome-form { margin-top: 2.2rem; display: flex; flex-direction: column; gap: 1rem; }
.welcome-foot { margin-top: 1.4rem; color: var(--mute); font-size: .85rem; }

/* --- Campos flotantes --- */
.field { position: relative; }
.input {
  width: 100%;
  padding: 1.15rem 1.1rem .5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  transition: border-color .3s var(--ease-out), background-color .3s var(--ease-out);
}
.input:hover { border-color: rgba(91,140,255,.4); }
.input:focus { outline: none; border-color: var(--accent); background: rgba(91,140,255,.06); }
.label {
  position: absolute; left: 1.1rem; top: .95rem;
  color: var(--mute); pointer-events: none;
  transition: transform .25s var(--ease-out), color .25s var(--ease-out), font-size .25s var(--ease-out);
}
.input:focus + .label,
.input:not(:placeholder-shown) + .label {
  transform: translateY(-.7rem);
  font-size: .72rem;
  color: var(--accent);
  letter-spacing: .02em;
}
[data-input-code] { text-transform: uppercase; letter-spacing: .12em; }

.form-note {
  color: #ffb4b4; font-size: .9rem; margin: -.2rem 0 .2rem;
}

/* --- Botones --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .95rem 1.6rem;
  border-radius: 100px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform .35s var(--ease-soft), box-shadow .35s var(--ease-soft), background-color .3s, opacity .3s;
}
.btn-primary {
  background: var(--accent); color: #06070a;
  box-shadow: 0 8px 24px -8px rgba(91,140,255,.55);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -10px rgba(91,140,255,.6); }
.btn-primary:active { transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* =============================================================
   Pantalla 2 — Conversación
   ============================================================= */
.screen--chat { flex-direction: column; padding: 4.5rem 0 0; }

.chat-progress {
  position: relative; height: 3px; margin: 0 var(--pad);
  background: var(--line-soft); border-radius: 100px; overflow: hidden;
  flex-shrink: 0;
}
.chat-progress-bar {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--grad-1), var(--grad-2), var(--grad-3));
  border-radius: 100px;
  transition: width .8s var(--ease-out);
}

.chat-log {
  flex: 1; overflow-y: auto;
  padding: 1.6rem var(--pad) 1.2rem;
  display: flex; flex-direction: column; gap: 1rem;
  max-width: 780px; width: 100%; margin-inline: auto;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 84%;
  padding: .85rem 1.1rem;
  border-radius: var(--r-lg);
  animation: rise .45s var(--ease-out) both;
  white-space: pre-wrap; word-wrap: break-word;
}
.bubble--bot {
  align-self: flex-start;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  color: var(--ink-soft);
}
.bubble--me {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(58,134,255,.22), rgba(139,92,246,.22));
  border: 1px solid rgba(91,140,255,.35);
  border-bottom-right-radius: 6px;
  color: var(--ink);
}
.bubble--typing { display: inline-flex; gap: 5px; align-items: center; }
.bubble--typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--mute);
  animation: blink 1.2s infinite ease-in-out;
}
.bubble--typing i:nth-child(2) { animation-delay: .2s; }
.bubble--typing i:nth-child(3) { animation-delay: .4s; }

/* --- Composer --- */
.composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: rgba(10,11,15,0.7);
  backdrop-filter: blur(10px);
  padding: .9rem var(--pad) 1.2rem;
}
.composer-inner {
  display: flex; align-items: flex-end; gap: .6rem;
  max-width: 780px; margin-inline: auto;
}
.composer-text { flex: 1; }
.composer-input {
  width: 100%;
  resize: none;
  max-height: 160px;
  padding: .85rem 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  line-height: 1.5;
  transition: border-color .3s var(--ease-out);
}
.composer-input::placeholder { color: var(--mute); }
.composer-input:focus { outline: none; border-color: var(--accent); }

.mic {
  position: relative;
  flex-shrink: 0;
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: background-color .3s, border-color .3s, transform .2s, color .3s;
}
.mic:hover { border-color: var(--accent); color: var(--accent); }

/* Barra de grabación tipo nota de voz */
.recorder {
  display: flex; align-items: center; gap: .8rem;
  max-width: 780px; margin-inline: auto;
  padding: .55rem .7rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(91,140,255,.35);
  border-radius: 100px;
}
.recorder[hidden] { display: none; }
.rec-cancel, .rec-send {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s, background-color .3s, color .3s;
}
.rec-cancel { color: var(--mute); border: 1px solid var(--line); }
.rec-cancel:hover { color: var(--bad, #ff6b6b); border-color: var(--bad, #ff6b6b); }
.rec-send { background: var(--accent); color: #06070a; margin-left: auto; box-shadow: 0 8px 24px -10px rgba(91,140,255,.6); }
.rec-send:hover { transform: translateY(-2px); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff5c5c; flex-shrink: 0; animation: recpulse 1.2s infinite var(--ease-out); }
.recorder.is-ready .rec-dot { background: var(--accent); animation: none; }
.rec-time { font-family: var(--mono); font-size: .95rem; color: var(--ink); min-width: 44px; }
.rec-hint { color: var(--mute); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bubble--voice { font-style: italic; }
@keyframes recpulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }

.send {
  flex-shrink: 0;
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #06070a;
  box-shadow: 0 8px 24px -10px rgba(91,140,255,.6);
  transition: transform .25s var(--ease-soft), box-shadow .25s, opacity .3s;
}
.send:hover { transform: translateY(-2px); }
.send[disabled] { opacity: .4; pointer-events: none; }

.composer-row {
  display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap;
  max-width: 780px; margin: .8rem auto 0;
}
.chip {
  font-family: var(--mono);
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .45rem .9rem; border-radius: 100px;
  border: 1px solid var(--line); color: var(--mute);
  transition: color .3s, border-color .3s, background-color .3s;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip--finish { color: var(--accent); border-color: rgba(91,140,255,.4); }
.chip--finish:hover { background: rgba(91,140,255,.1); }

.finish-confirm {
  max-width: 780px; margin: .8rem auto 0;
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  padding: .9rem 1rem; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(91,140,255,.05);
  animation: rise .3s var(--ease-out) both;
}
.finish-confirm[hidden] { display: none; }
.finish-confirm-msg { font-size: .9rem; color: var(--ink); text-align: center; margin: 0; }
.finish-confirm-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

/* =============================================================
   Pantalla 3 — Cierre
   ============================================================= */
.screen--done { align-items: center; justify-content: center; padding: 5rem var(--pad); text-align: center; }
.done-inner { max-width: 480px; animation: rise .7s var(--ease-out) both; }
.done-check {
  width: 76px; height: 76px; margin: 0 auto 1.6rem;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #06070a;
  background: linear-gradient(135deg, var(--grad-1), var(--grad-3));
  box-shadow: 0 14px 40px -12px rgba(91,140,255,.6);
}
.done-title { font-size: clamp(1.8rem, 5vw, 2.6rem); margin-bottom: 1rem; }
.done-lead { color: var(--mute); font-size: 1.05rem; }

/* =============================================================
   Animaciones
   ============================================================= */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes pulse { 0% { opacity: .7; transform: scale(1); } 100% { opacity: 0; transform: scale(1.5); } }

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 560px) {
  .bubble { max-width: 90%; }
  .mic, .send { width: 46px; height: 46px; }
}

/* =============================================================
   Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .bg-gradient { filter: none; }
}
