/* =========================================================
   StarkLabs JARVIS Web UI — FULL app.css (drop-in)
   Glass + Orbs + Chat Animations + FIXED Thinking Bubble
   (No :has(), shimmer behind content, no clipping)
   ========================================================= */

:root{
  --bg: #0b0f14;
  --text: #eaf2ff;
  --muted: rgba(234,242,255,.70);

  --accent: rgba(74,163,255,1);
  --accentSoft: rgba(74,163,255,.22);
  --danger: rgba(255,74,106,1);
  --dangerSoft: rgba(255,74,106,.18);

  --glassBorder: rgba(255,255,255,.10);
  --innerBorder: rgba(255,255,255,.04);

  --shadow: 0 24px 90px rgba(0,0,0,.65);
  --shadowSoft: 0 14px 40px rgba(0,0,0,.28);

  /* Orb parallax vars (set by JS; harmless if JS isn't running) */
  --px: 0px;
  --py: 0px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: var(--bg);
  color: var(--text);
  overflow-x:hidden;
  position:relative;
}

/* =========================================================
   Animated Orb Background (CSS-only + parallax via vars)
   ========================================================= */

body::before,
body::after{
  content:"";
  position:fixed;
  inset:-20vh -20vw;
  pointer-events:none;
  background-repeat:no-repeat;
  transform: translate3d(0,0,0);
  will-change: transform, filter;
}

body::before{
  z-index:-2;
  opacity:.92;
  filter: blur(34px) saturate(155%);
  background-image:
    radial-gradient(520px 380px at 16% 18%, rgba(74,163,255,.30), transparent 62%),
    radial-gradient(560px 420px at 82% 14%, rgba(255,74,106,.20), transparent 64%),
    radial-gradient(620px 520px at 76% 86%, rgba(140,120,255,.18), transparent 62%),
    radial-gradient(620px 520px at 14% 84%, rgba(74,163,255,.14), transparent 60%);
  animation: orbDriftA 18s ease-in-out infinite alternate;
  transform: translate3d(calc(var(--px) * .35), calc(var(--py) * .35), 0);
}

body::after{
  z-index:-3;
  opacity:.80;
  filter: blur(56px) saturate(175%);
  background-image:
    radial-gradient(820px 620px at 42% 38%, rgba(74,163,255,.10), transparent 70%),
    radial-gradient(820px 620px at 54% 78%, rgba(255,74,106,.08), transparent 72%),
    radial-gradient(980px 700px at 92% 52%, rgba(255,255,255,.06), transparent 74%);
  animation: orbDriftB 26s ease-in-out infinite alternate;
  transform: translate3d(calc(var(--px) * -.20), calc(var(--py) * -.20), 0);
}

/* Vignette + sheen */
.wrap::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:-1;
  pointer-events:none;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(255,255,255,.06), transparent 55%),
    radial-gradient(1200px 700px at 50% 110%, rgba(0,0,0,.60), transparent 55%),
    radial-gradient(900px 700px at 0% 50%, rgba(0,0,0,.40), transparent 55%),
    radial-gradient(900px 700px at 100% 50%, rgba(0,0,0,.40), transparent 55%);
}

@keyframes orbDriftA{
  0%   { filter: blur(34px) saturate(150%); }
  100% { filter: blur(38px) saturate(185%); }
}
@keyframes orbDriftB{
  0%   { filter: blur(56px) saturate(170%); }
  100% { filter: blur(62px) saturate(205%); }
}

@media (prefers-reduced-motion: reduce){
  body::before, body::after{ animation:none !important; }
}

/* =========================================================
   Base Layout
   ========================================================= */

.wrap{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
  position:relative;
}

/* =========================================================
   Glass Card
   ========================================================= */

.card{
  width:min(920px, 100%);
  border-radius:22px;
  border:1px solid var(--glassBorder);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  box-shadow: var(--shadow), 0 0 0 1px var(--innerBorder) inset;
  overflow:hidden;

  backdrop-filter: blur(18px) saturate(155%);
  -webkit-backdrop-filter: blur(18px) saturate(155%);
  position:relative;
}

/* top gloss */
.card::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(920px 160px at 30% 0%, rgba(255,255,255,.10), transparent 62%),
    radial-gradient(920px 160px at 70% 0%, rgba(74,163,255,.10), transparent 66%);
  opacity:.55;
}

/* =========================================================
   Header
   ========================================================= */

.header{
  padding:18px 22px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;

  border-bottom:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.12);

  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

.brand{ display:flex; flex-direction:column; gap:2px; }
.brand .title{
  font-weight:900;
  letter-spacing:.8px;
  text-shadow: 0 12px 34px rgba(0,0,0,.45);
}
.brand .subtitle{
  color: var(--muted);
  font-size:13px;
}

.small{ color: var(--muted); font-size:12px; }

/* =========================================================
   Buttons
   ========================================================= */

.btn{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;

  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);

  box-shadow: var(--shadowSoft), 0 0 0 1px rgba(255,255,255,.04) inset;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 18px 48px rgba(0,0,0,.30), 0 0 0 1px rgba(255,255,255,.05) inset;
}
.btn:active{ transform: translateY(0) scale(.99); }

.btn.primary{
  background: var(--accentSoft);
  border-color: rgba(74,163,255,.42);
  box-shadow: 0 18px 50px rgba(74,163,255,.10), 0 0 0 1px rgba(74,163,255,.08) inset;
}
.btn.primary:hover{ background: rgba(74,163,255,.24); }

.btn.danger{
  background: var(--dangerSoft);
  border-color: rgba(255,74,106,.42);
}

/* =========================================================
   Content / Forms
   ========================================================= */

.content{ padding:18px 22px; }

.grid{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}
@media (min-width:820px){
  .grid{ grid-template-columns:1fr 1fr; }
}

.field label{
  display:block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size:13px;
}

.field input{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
  color: var(--text);
  outline:none;

  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);

  box-shadow: 0 12px 28px rgba(0,0,0,.20), 0 0 0 1px rgba(255,255,255,.03) inset;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.field input:focus{
  border-color: rgba(74,163,255,.55);
  background: rgba(0,0,0,.24);
  box-shadow:
    0 0 0 3px rgba(74,163,255,.14),
    0 18px 54px rgba(74,163,255,.10);
}

.note{
  color: var(--muted);
  font-size:13px;
  line-height:1.35;
}

.err{
  display:none;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,74,106,.45);
  background: rgba(255,74,106,.14);
  color: rgba(255,220,228,.98);

  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
}

/* =========================================================
   Chat Layout
   ========================================================= */

.chat{
  height: 66vh;
  min-height: 420px;
  display:grid;
  grid-template-rows: auto 1fr auto;
}

.messages{
  padding:18px 22px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:12px;

  scrollbar-width:thin;
  scrollbar-color: rgba(255,255,255,.18) rgba(0,0,0,.16);
}

.messages::-webkit-scrollbar{ width:10px; }
.messages::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.16);
  border-radius: 10px;
  border:2px solid rgba(0,0,0,.16);
}
.messages::-webkit-scrollbar-track{ background: rgba(0,0,0,.12); }

/* bubbles */
.bubble{
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  line-height: 1.35;
  white-space: pre-wrap;

  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);

  box-shadow: 0 12px 30px rgba(0,0,0,.18), 0 0 0 1px rgba(255,255,255,.02) inset;
}

/* entrance animation */
.bubble.in{ animation: bubbleIn .18s ease-out both; }
@keyframes bubbleIn{
  from{ opacity:0; transform: translateY(6px) scale(.985); }
  to  { opacity:1; transform: translateY(0) scale(1); }
}

.bubble.user{
  align-self:flex-end;
  border-color: rgba(74,163,255,.36);
  background: rgba(74,163,255,.11);
  box-shadow:
    0 18px 44px rgba(74,163,255,.10),
    0 0 0 1px rgba(74,163,255,.06) inset;
}

.bubble.jarvis{ align-self:flex-start; }

/* =========================================================
   THINKING BUBBLE — FIXED (NO TEXT CLIPPING)
   - inline-flex + align-items center prevents baseline clipping
   - shimmer behind content
   - dots stable in Firefox/Chromium
   ========================================================= */

.bubble.jarvis.thinking{
  position:relative;
  overflow:hidden;

  /* IMPORTANT: prevents the "Thinking" text getting clipped */
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;

  /* Safety net: tiny minimum height so fonts never clip */
  min-height: 40px;

  border-color: rgba(74,163,255,.48);

  background:
    linear-gradient(90deg,
      rgba(74,163,255,.11),
      rgba(255,255,255,.06),
      rgba(74,163,255,.11)
    ),
    rgba(0,0,0,.18);
  background-size: 220% 100%;
  background-position: 0% 0%;

  /* Slightly tighter line-height helps some fonts on Linux/Firefox */
  line-height: 1.1;

  animation:
    thinkPulse 1.10s ease-in-out infinite,
    thinkSheen 2.30s linear infinite,
    thinkBreathe 1.60s ease-in-out infinite;
}

/* shimmer overlay BEHIND content */
.bubble.jarvis.thinking::after{
  content:"";
  position:absolute;
  inset:-40% -40%;
  z-index: 1;
  background: linear-gradient(
    120deg,
    transparent 40%,
    rgba(74,163,255,.14) 50%,
    transparent 60%
  );
  transform: translateX(-55%) translateY(12%) rotate(8deg);
  animation: jarvisScan 1.25s ease-in-out infinite;
  pointer-events:none;
  mix-blend-mode: screen;
  opacity: .85;
}

/* content above shimmer */
.bubble.jarvis.thinking > *{
  position:relative;
  z-index: 2;
}

/* label */
.bubble .thinkingLabel{
  color: rgba(234,242,255,.92);
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
}

/* dots */
.bubble .dots{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  line-height: 1;
  vertical-align: middle;
}

.bubble .dots span{
  display:inline-block;
  width:7px;
  height:7px;
  border-radius:999px;
  background: rgba(231,238,252,.80);
  box-shadow: 0 0 12px rgba(74,163,255,.14);
  animation: dotBounce 1.0s ease-in-out infinite;
  transform: translateZ(0);
}
.bubble .dots span:nth-child(2){ animation-delay:.12s; opacity:.85; }
.bubble .dots span:nth-child(3){ animation-delay:.24s; opacity:.70; }

@keyframes dotBounce{
  0%,100%{ transform: translateY(0); opacity:.65; }
  50%    { transform: translateY(-5px); opacity:1; }
}

@keyframes jarvisScan{
  0%   { transform: translateX(-55%) translateY(12%) rotate(8deg); opacity:.55; }
  50%  { opacity:.95; }
  100% { transform: translateX(55%) translateY(-12%) rotate(8deg); opacity:.55; }
}

@keyframes thinkSheen{
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

@keyframes thinkBreathe{
  0%,100%{ transform: translateY(0); }
  50%    { transform: translateY(-1px); }
}

@keyframes thinkPulse{
  0%,100%{
    box-shadow:
      0 0 0 1px rgba(74,163,255,.10) inset,
      0 12px 30px rgba(0,0,0,.18),
      0 0 18px rgba(74,163,255,.10);
  }
  50%{
    box-shadow:
      0 0 0 1px rgba(74,163,255,.14) inset,
      0 12px 30px rgba(0,0,0,.18),
      0 0 34px rgba(74,163,255,.22);
  }
}

/* =========================================================
   Composer
   ========================================================= */

.composer{
  border-top: 1px solid rgba(255,255,255,.10);
  padding: 14px 16px;
  display:grid;
  grid-template-columns: 1fr auto;
  gap:10px;

  background: rgba(0,0,0,.12);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

.composer textarea{
  width:100%;
  resize:none;
  padding:12px 12px;
  border-radius:14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  color: var(--text);
  outline:none;
  min-height:44px;
  max-height:160px;

  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);

  box-shadow: 0 12px 28px rgba(0,0,0,.18), 0 0 0 1px rgba(255,255,255,.03) inset;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.composer textarea:focus{
  border-color: rgba(74,163,255,.55);
  background: rgba(0,0,0,.22);
  box-shadow:
    0 0 0 3px rgba(74,163,255,.14),
    0 18px 54px rgba(74,163,255,.10);
}
