/* screens.css — Spark + the Room. Creation flow lives in create.css. */

/* ── Maestro creator figure (real transparent SVG + soft aura) ─────────── */
.maestro { position: relative; width: var(--mw); max-width: 80vw; aspect-ratio: 150/195; display: flex; align-items: center; justify-content: center; }
.maestro-img { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 2; filter: drop-shadow(0 10px 34px rgba(251,191,36,.34)); }
.m-aura { position: absolute; inset: -8%; z-index: 0; border-radius: 50%; background: radial-gradient(circle, rgba(251,191,36,.30), rgba(245,158,11,.14) 48%, transparent 72%); filter: blur(18px); animation: pulse 5s var(--ease) infinite; }

/* Maestro-3D-style aura rings — slow, morphing, gold (the Chamber vibe). */
.m-orbit { position: absolute; left: 50%; top: 47%; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%); z-index: 0; pointer-events: none; }
.m-orbit i { position: absolute; inset: 0; margin: auto; border: 1.5px solid rgba(251,191,36,.22); border-radius: 44% 56% 53% 47% / 50% 46% 54% 50%; }
.m-orbit i:nth-child(1) { animation: orbit 20s linear infinite; }
.m-orbit i:nth-child(2) { inset: 9%; border-color: rgba(251,191,36,.16); animation: orbit 28s linear infinite reverse; }
.m-orbit i:nth-child(3) { inset: 18%; border-color: rgba(245,158,11,.13); animation: orbit 36s linear infinite; }
.m-orbit i:nth-child(4) { inset: 27%; border-color: rgba(245,158,11,.10); animation: orbit 44s linear infinite reverse; }
@keyframes orbit { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.05); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes pulse { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: .9; transform: scale(1.06); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ── Spark ─────────────────────────────────────────────────────────────── */
#screen-spark { align-items: center; justify-content: center; text-align: center; padding: 2rem 1.4rem 3.6rem; position: relative; }

/* Environment badge + credit (v1 parity: prod shows PostgreSQL, dev "Local DB") */
.spark-foot { position: absolute; left: 0; right: 0; bottom: calc(.85rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; gap: 1rem; font-size: .88rem; color: var(--faint); }
.db-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .34rem .85rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700; }
.db-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.db-pill.pg { color: var(--ok); border-color: rgba(143,214,165,.4); }
.db-pill.pg i { background: var(--ok); box-shadow: 0 0 8px rgba(143,214,165,.8); }
.db-pill.local i { background: var(--gold); }
.powered { color: var(--faint); text-decoration: none; }
.powered b { color: var(--violet); font-weight: 800; }
.powered u { text-decoration: none; color: var(--gold); font-weight: 800; }
.powered:hover u, .powered:active u { text-decoration: underline; }
.spark-maestro { position: relative; animation: float 6s var(--ease) infinite; margin-bottom: 1.4rem; }
#screen-spark .tagline { font-size: clamp(1.5rem, 5.2vw, 2.15rem); max-width: 16ch; margin-bottom: 1rem; font-weight: 600;
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 45%, #f59e0b 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--gold); }
#screen-spark .sub { color: var(--text); opacity: .9; font-size: clamp(1.02rem, 4.2vw, 1.22rem); max-width: 34ch; margin-bottom: 2.2rem; line-height: 1.62; }
#screen-spark .btn { max-width: 360px; font-size: 1.22rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; padding: 1.2rem 1.5rem; }
.hl-gold { color: var(--gold); font-weight: 700; }

/* Quick-tour button — bordered square, violet, doesn't compete with the gold CTA */
#screen-spark .btn-tour { margin-top: 1.9rem; background: transparent; border: 2px solid var(--violet); color: var(--violet); font-weight: 700; font-size: .98rem; padding: .72rem 1.4rem; border-radius: 14px; letter-spacing: .02em; transition: background .15s var(--ease); }
#screen-spark .btn-tour:active { background: rgba(185,140,255,.14); }
#screen-spark #spark-continue { margin-top: .85rem; }

/* Mobile: shrink Maestro + trim margins so the Spark fits without scrolling */
@media (max-width: 819px) {
  #screen-spark { padding-top: 1.4rem; padding-bottom: 1.4rem; }
  #screen-spark .spark-maestro .maestro { width: 156px; }
  .spark-maestro { margin-bottom: .55rem; }
  #screen-spark .tagline { margin-bottom: .7rem; }
  #screen-spark .sub { margin-bottom: 1.5rem; }
}

/* ── The Room ──────────────────────────────────────────────────────────── */
#screen-room { background: linear-gradient(180deg, var(--bg-2), var(--bg)); }
.room-top { display: flex; align-items: center; gap: .75rem; padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem; border-bottom: 1px solid var(--line); }
.room-top .mini { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex: none; background: var(--surface-2); }
.mini-ava { width: 100%; height: 100%; object-fit: cover; }
.room-top .who { flex: 1; min-width: 0; }
.room-top .who b { display: block; font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gold); }
.room-top .who small { color: var(--ok); font-size: .76rem; }
.chamber-btn { flex: none; min-width: 50px; height: 48px; padding: 4px 8px; border-radius: 12px; border: 1.5px solid var(--ok); color: var(--ok); background: rgba(143,214,165,.08); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.chamber-btn .cb-ic { font-size: 1rem; line-height: 1; }
.chamber-btn .cb-lbl { font-size: .58rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.chamber-btn:active { background: rgba(143,214,165,.2); }
.chamber-btn.muted { color: var(--muted); border-color: var(--line); }

/* Mobile: reserve room on the right so the fixed language pill never overlaps
   the Mute/Home buttons. Must live here (after .room-top's padding shorthand). */
@media (max-width: 819px) {
  .room-top { padding-right: 116px; }
}

.stage {
  display: flex; align-items: center; justify-content: center;
  height: 40vh; min-height: 240px; position: relative; transition: filter .5s var(--ease);
}
.stage::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 78%; height: 78%; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(251,191,36,.28), transparent 68%); filter: blur(26px);
  transition: opacity .5s var(--ease), background .6s var(--ease);
}
.portrait { width: min(62vw, 260px); position: relative; z-index: 1; animation: float 6s var(--ease) infinite; }

/* Round portrait with a soft gold ring — matches the little header avatar. */
.room-ava {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 50%; display: block;
  transform-origin: 50% 60%; will-change: transform;
  box-shadow: 0 0 0 3px rgba(251,191,36,.55), 0 16px 44px rgba(251,191,36,.30);
  animation: breathe 4.6s var(--ease) infinite;
  transition: box-shadow .6s var(--ease), filter .6s var(--ease);
}
/* breathing + a gentle head-sway — clearly alive, never a frozen photo */
@keyframes breathe {
  0%, 100% { transform: scale(1) translateY(0) rotate(0deg); }
  35%      { transform: scale(1.045) translateY(-1.6%) rotate(.8deg); }
  70%      { transform: scale(1.02) translateY(-0.6%) rotate(-.5deg); }
}

/* ── Avatar life overlays (pure JS/CSS, no new art, no identity drift).
   No fake blink — without eye landmarks it reads as a dark band (Owner QA);
   a real blink waits for face-locked art/animation. ── */
.portrait .blush { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 2; }
/* blush: soft pink over the cheeks, fades in on warm moods */
.portrait .blush { opacity: 0; mix-blend-mode: soft-light; filter: blur(9px); transition: opacity .8s var(--ease);
  background: radial-gradient(circle at 30% 62%, rgba(255,105,128,.6), transparent 34%),
              radial-gradient(circle at 70% 62%, rgba(255,105,128,.6), transparent 34%); }

/* ── Mood — a coloured HALO RING around the face is the clear, visible cue ── */
#screen-room[data-mood="idle"]      .room-ava { box-shadow: 0 0 0 3px rgba(251,191,36,.5),  0 16px 44px rgba(251,191,36,.28); }
#screen-room[data-mood="listening"] .stage::before { opacity: 1; background: radial-gradient(circle, rgba(126,214,192,.34), transparent 68%); }
#screen-room[data-mood="listening"] .room-ava { box-shadow: 0 0 0 3px rgba(126,214,192,.85), 0 0 42px rgba(126,214,192,.55), 0 16px 44px rgba(126,214,192,.3); }
#screen-room[data-mood="thinking"]  .stage::before { opacity: .5; }
#screen-room[data-mood="thinking"]  .room-ava { box-shadow: 0 0 0 3px rgba(251,191,36,.28), 0 12px 34px rgba(251,191,36,.14); filter: saturate(.9) brightness(.95); }
#screen-room[data-mood="speaking"]  .stage::before { opacity: 1; animation: pulse 1.3s var(--ease) infinite; }
#screen-room[data-mood="speaking"]  .room-ava { animation: breathe 4.6s var(--ease) infinite, speakpulse 1.25s var(--ease) infinite; }
@keyframes speakpulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(251,191,36,.7), 0 0 30px rgba(251,191,36,.45), 0 16px 44px rgba(251,191,36,.32); }
  50%      { box-shadow: 0 0 0 5px rgba(251,191,36,1),  0 0 60px rgba(251,191,36,.75), 0 18px 50px rgba(251,191,36,.42); }
}
#screen-room[data-mood="happy"]     .stage::before { opacity: 1; }
#screen-room[data-mood="happy"]     .room-ava { box-shadow: 0 0 0 3px rgba(251,191,36,.95), 0 0 52px rgba(251,191,36,.62), 0 16px 46px rgba(251,191,36,.38); filter: brightness(1.06) saturate(1.12); }
#screen-room[data-mood="happy"]     .blush { opacity: .5; }
#screen-room[data-mood="tender"]    .stage::before { opacity: 1; background: radial-gradient(circle, rgba(255,140,160,.3), transparent 68%); }
#screen-room[data-mood="tender"]    .room-ava { box-shadow: 0 0 0 3px rgba(255,132,152,.9), 0 0 46px rgba(255,132,152,.55), 0 16px 46px rgba(255,132,152,.32); filter: brightness(1.03) saturate(1.08); }
#screen-room[data-mood="tender"]    .blush { opacity: 1; }
#screen-room[data-mood="sad"]       .stage { filter: saturate(.82) brightness(.92); }
#screen-room[data-mood="sad"]       .stage::before { opacity: .55; background: radial-gradient(circle, rgba(150,170,210,.24), transparent 68%); }
#screen-room[data-mood="sad"]       .room-ava { box-shadow: 0 0 0 3px rgba(150,170,210,.75), 0 0 34px rgba(150,170,210,.4), 0 14px 40px rgba(150,170,210,.24); filter: saturate(.84) brightness(.93); }

/* NOTE: we intentionally do NOT honor prefers-reduced-motion here — Windows
   "animation effects off" is common and silently froze the avatar for those
   users; the companion's subtle breathing IS the product (Owner call). */

.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1rem 1.4rem; display: flex; flex-direction: column; gap: .55rem; }
.msg { max-width: 80%; padding: .7rem 1rem; border-radius: var(--radius); line-height: 1.45; font-size: 1.02rem; animation: rise .3s var(--ease); }
.msg.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 6px; }
.msg.you { align-self: flex-end; background: var(--bubble-you); color: var(--accent-ink); border-bottom-right-radius: 6px; font-weight: 500; }
.msg.them.typing::after { content: "▍"; animation: caret 1s steps(1) infinite; color: var(--accent); }
@keyframes caret { 50% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dock-wrap { border-top: 1px solid var(--line); background: var(--bg-2); padding: .7rem .8rem calc(.55rem + env(safe-area-inset-bottom)); }
.dock { display: flex; gap: .6rem; align-items: flex-end; }
.dock-mic { width: 48px; height: 48px; border-radius: 50%; background: transparent; border: 1.5px solid var(--gold); color: var(--gold); flex: none; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; transition: all .2s var(--ease); }
.dock-mic:active { background: rgba(251,191,36,.12); }
.dock-mic.on { border-color: var(--ok); color: var(--ok); background: rgba(126,214,192,.16); animation: pulse 1.1s var(--ease) infinite; }
.dock-mic.off, .dock-mic:disabled { opacity: .38; cursor: default; }
.dock-hint { text-align: center; font-size: .7rem; color: var(--faint); margin-top: .5rem; }
.dock-hint kbd { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: .66rem; color: var(--muted); }
.dock textarea { flex: 1; resize: none; max-height: 120px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 22px; padding: .8rem 1.1rem; font-size: 1.05rem; line-height: 1.35; color: var(--text); }
.dock textarea:focus { outline: none; border-color: var(--accent); }
.dock .send { width: 48px; height: 48px; border-radius: 50%; background: var(--bubble-you); color: var(--accent-ink); flex: none; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.dock .send:disabled { filter: grayscale(.6) brightness(.6); }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: none; }
.sheet-backdrop.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; transform: translateY(100%); background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 1.2rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom)); transition: transform .3s var(--ease); }
.sheet.open { transform: none; }
.sheet button { display: block; width: 100%; text-align: left; padding: 1rem; border-radius: 12px; color: var(--text); font-size: 1.02rem; }
.sheet button:active { background: var(--surface-2); }

@media (min-width: 820px) {
  #app { max-width: 480px; margin: 0 auto; box-shadow: var(--shadow); }
  body { display: block; }
}
