/* Jarvis voice assistant — launcher orb + full-screen overlay.
   Breakpoints match style.css (900px tablet, 600px phone). */

.jv-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  bottom: calc(var(--jv-offset-bottom, 20px) + env(safe-area-inset-bottom));
  z-index: 900;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle at 35% 30%, #5be7ff, #1b6fd8 55%, #0b1f4a);
  box-shadow: 0 6px 22px rgba(20, 110, 220, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.jv-launcher.jv-dragging { cursor: grabbing; transition: none; }
.jv-launcher:hover { transform: scale(1.06); }
.jv-launcher:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.jv-launcher-core {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.15);
  animation: jv-spin 4s linear infinite;
}
.jv-launcher.jv-wake-on { box-shadow: 0 0 0 3px rgba(91, 231, 255, 0.5), 0 6px 22px rgba(20, 110, 220, 0.55); }
body.jv-open .jv-launcher { display: none; }
@keyframes jv-spin { to { transform: rotate(360deg); } }
@media (pointer: coarse) { .jv-launcher { width: 60px; height: 60px; } }
@media (max-width: 600px) { .jv-launcher { right: 14px; } }
@media (prefers-reduced-motion: reduce) { .jv-launcher-core { animation: none; } }

.jv-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  color: #e8f6ff;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(24, 80, 170, 0.35), transparent 60%),
    rgba(3, 8, 22, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.25s ease;
  font-family: var(--font-ui);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.jv-overlay.jv-visible { opacity: 1; }

.jv-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
}
.jv-chip {
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(140, 210, 255, 0.35);
  background: rgba(60, 130, 220, 0.14);
  color: #cfeaff;
  font: 500 13px var(--font-ui);
  cursor: pointer;
}
.jv-chip:hover { background: rgba(60, 130, 220, 0.28); }
.jv-close {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e8f6ff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.jv-close:hover { background: rgba(255, 255, 255, 0.18); }

.jv-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center; /* falls back to top-aligned + scrolling when a confirm card makes it taller than the screen */
  gap: 10px;
  padding: 0 20px 12px;
  overflow-y: auto;
  text-align: center;
}
.jv-orb-btn {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.jv-orb {
  display: block;
  width: min(78vw, 46vh, 460px);
  height: min(78vw, 46vh, 460px);
}
.jv-status {
  min-height: 22px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7fd0ff;
}
.jv-overlay[data-state="thinking"] .jv-status { color: #b79bff; }
.jv-you {
  min-height: 24px;
  max-width: 760px;
  font-size: 16px;
  color: rgba(207, 234, 255, 0.6);
}
.jv-reply {
  max-width: 760px;
  max-height: 22vh;
  overflow-y: auto;
  font-size: 20px;
  line-height: 1.45;
  color: #f3fbff;
}

.jv-type {
  display: flex;
  gap: 8px;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 10px 16px 18px;
  box-sizing: border-box;
}
.jv-type input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(140, 210, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #f3fbff;
  font: 16px var(--font-ui); /* 16px stops iOS zooming the page on focus */
}
.jv-type input::placeholder { color: rgba(207, 234, 255, 0.45); }
.jv-type input:focus { outline: 2px solid #5be7ff; outline-offset: 1px; }
.jv-send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #1b6fd8;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .jv-reply { font-size: 18px; max-height: 26vh; }
  .jv-orb { width: min(86vw, 40vh); height: min(86vw, 40vh); }
}
/* Phone held sideways: shrink the orb so captions and input stay on screen. */
@media (max-height: 480px) {
  .jv-orb { width: 34vh; height: 34vh; }
  .jv-reply { max-height: 18vh; font-size: 16px; }
}

/* Confirmation card + tap-only action buttons (Gmail draft, file chooser). */
.jv-confirm {
  width: min(100%, 520px);
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 196, 92, 0.45);
  background: rgba(255, 196, 92, 0.08);
  text-align: left;
  box-sizing: border-box;
}
.jv-confirm[hidden] { display: none; }
.jv-confirm-title { font-size: 16px; font-weight: 600; color: #ffe2a8; margin-bottom: 8px; }
.jv-confirm-details { margin: 0 0 12px; display: grid; gap: 4px; font-size: 14px; }
.jv-confirm-details > div { display: flex; gap: 10px; }
.jv-confirm-details dt { flex: 0 0 34%; color: rgba(207, 234, 255, 0.6); }
.jv-confirm-details dd { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; color: #f3fbff; }
.jv-confirm-btns, .jv-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.jv-confirm-btns { justify-content: flex-start; }
.jv-confirm-hint, .jv-hint { width: 100%; margin-top: 8px; font-size: 12px; color: rgba(207, 234, 255, 0.55); }
.jv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(140, 210, 255, 0.4);
  background: rgba(255, 255, 255, 0.07);
  color: #e8f6ff;
  font: 600 15px var(--font-ui);
  text-decoration: none;
  cursor: pointer;
}
.jv-btn:hover { background: rgba(255, 255, 255, 0.16); }
.jv-btn-go { background: #1b6fd8; border-color: #1b6fd8; color: #fff; }
.jv-btn-go:hover { background: #2a82f0; }
@media (max-width: 600px) {
  .jv-confirm-details dt { flex-basis: 40%; }
  .jv-confirm-btns .jv-btn { flex: 1; }
}
/* Shrink the orb while a confirmation or action button is on screen so the
   card and its buttons stay reachable on short screens. */
.jv-overlay.jv-has-panel .jv-orb { width: min(40vw, 24vh, 220px); height: min(40vw, 24vh, 220px); }
.jv-orb-btn, .jv-status, .jv-you, .jv-reply, .jv-confirm, .jv-actions { flex-shrink: 0; }

/* Live-conversation layout: text block, dock button, and the shrunk (docked)
   mode that leaves the app visible and clickable while Jarvis keeps listening. */
.jv-text { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.jv-icon {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); color: #e8f6ff; font-size: 18px; line-height: 1; cursor: pointer;
}
.jv-icon:hover { background: rgba(255, 255, 255, 0.18); }
.jv-top .jv-icon { margin-left: auto; }
.jv-top .jv-icon + .jv-close { margin-left: 0; }
.jv-chip { white-space: nowrap; }
.jv-top { flex-wrap: wrap; }

.jv-overlay { transition: opacity 0.25s ease, inset 0.25s ease; }
.jv-overlay.jv-docked {
  inset: auto 16px 16px auto;
  inset-block-end: calc(16px + env(safe-area-inset-bottom));
  width: min(400px, calc(100vw - 32px));
  max-height: 70vh;
  padding: 0;
  border-radius: 20px;
  border: 1px solid rgba(140, 210, 255, 0.35);
  background: rgba(5, 12, 30, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: hidden;
}
.jv-docked .jv-top { padding: 8px 10px 0; }
.jv-docked .jv-top .jv-chip, .jv-docked #jvDock { display: none; }
.jv-docked .jv-top .jv-close { margin-left: auto; width: 32px; height: 32px; font-size: 22px; }
.jv-docked .jv-stage {
  flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start;
  gap: 12px; padding: 0 14px 14px; text-align: left; overflow-y: auto;
}
.jv-docked .jv-orb { width: 84px; height: 84px; }
.jv-docked .jv-text { flex: 1; align-items: flex-start; gap: 4px; }
.jv-docked .jv-status { font-size: 11px; min-height: 14px; }
.jv-docked .jv-you { font-size: 13px; min-height: 0; }
.jv-docked .jv-reply { font-size: 15px; max-height: 24vh; }
.jv-docked .jv-type { display: none; }
.jv-docked .jv-confirm, .jv-docked .jv-actions { width: 100%; }
@media (max-width: 600px) {
  .jv-overlay.jv-docked { inset: auto 10px 10px 10px; width: auto; }
  .jv-top .jv-chip { flex: 0 0 auto; }
}

/* Wake-word status: the orb only glows while the microphone is really
   capturing; a warning ring and a pill explain when it is not. */
.jv-launcher.jv-wake-warn { box-shadow: 0 0 0 3px rgba(240, 160, 40, 0.75), 0 6px 22px rgba(200, 120, 20, 0.5); }
.jv-pill {
  position: fixed;
  right: 88px;
  bottom: 30px;
  bottom: calc(var(--jv-offset-bottom, 20px) + 10px + env(safe-area-inset-bottom));
  z-index: 900;
  max-width: min(320px, calc(100vw - 120px));
  padding: 8px 14px;
  border: 1px solid rgba(140, 210, 255, 0.4);
  border-radius: 999px;
  background: rgba(5, 12, 30, 0.94);
  color: #e8f6ff;
  font: 500 13px var(--font-ui);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.jv-pill[hidden] { display: none; }
.jv-pill[data-warn] { border-color: rgba(240, 160, 40, 0.8); }
body.jv-open .jv-pill { display: none; }
@media (max-width: 600px) { .jv-pill { right: 84px; bottom: 26px; } }
