/* =========================================================
   PHONE / LIVE DEMO
   Shared phone chrome, chat bubbles, animations, and the
   split-bubble layout used in the hero + presence-first demo.
   ========================================================= */
.phone-stage {
  position: relative;
  display: grid; place-items: center;
  min-height: 680px;
}
@media (max-width: 980px) {
  /* ~20% smaller phone on small screens, with a shorter aspect ratio
     so the overall height is trimmed further at the expense of the
     chat bubbles (chat-area is flex:1 so it absorbs the difference). */
  .phone {
    width: 288px;
    max-width: 72vw;
    aspect-ratio: 9 / 14;
  }
  /* Drop the 680px floor so the phone-stage actually collapses to
     the (now shorter) phone instead of holding the layout open. */
  .phone-stage { min-height: 0; }
}
.phone-stage::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(420px 420px at 50% 40%, rgba(255,217,0,.16), transparent 60%),
    radial-gradient(620px 620px at 60% 75%, rgba(68,15,80,.20), transparent 70%);
  filter: blur(10px);
  z-index: 0;
}

.phone {
  position: relative;
  z-index: 1;
  width: 360px;
  max-width: 90vw;
  aspect-ratio: 9/19.5;
  border-radius: 48px;
  background: linear-gradient(180deg, #0a0a0a, #050505);
  border: 1.5px solid #1c1c1c;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 60px 120px -40px rgba(0,0,0,.85),
    0 30px 80px -20px rgba(59,130,246,.18);
  padding: 14px;
  overflow: hidden;
}
.phone::before {
  /* Notch */
  content: "";
  position: absolute;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 28px;
  border-radius: 16px;
  background: #000;
  z-index: 5;
}
.phone-screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 36px;
  background: #000;
  overflow: hidden;
  display: flex; flex-direction: column;
  isolation: isolate;
}

/* App header inside phone */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 38px 18px 14px;
  font-size: 14px;
}
.app-header .who {
  display: flex; align-items: center; gap: 10px;
}
.app-header .pet {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--g-rose);
  display: grid; place-items: center;
  font-size: 16px;
  box-shadow: 0 4px 12px -2px rgba(244,7,82,.5);
}
.app-header .meta { line-height: 1.1; }
.app-header .name { font-weight: 700; font-size: 14px; }
.app-header .status { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.app-header .status::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint);
}
.app-header .icon-btn {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-2);
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 8px 18px;
  gap: 12px;
  position: relative;
}

/* Message bubble — one big centered bubble per side */
.bubble {
  width: 100%;
  min-height: 52px;
  border-radius: 22px;
  padding: 14px 18px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  position: relative;
  display: flex; align-items: center;
  transition: transform .35s var(--ease), opacity .35s var(--ease), background .4s var(--ease), color .4s var(--ease);
}
.bubble.theirs {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.bubble.mine {
  background: var(--g-cyber);
  color: #fff;
  align-self: flex-end;
  text-shadow: 0 1px 2px rgba(0,0,0,.18);
  box-shadow: 0 12px 30px -8px rgba(33,12,174,.55);
}
.bubble.empty { opacity: 0; transform: scale(.95); pointer-events: none; min-height: 0; padding: 0; height: 0; margin: 0; border-width: 0; box-shadow: none; }

/* Word wrapper — keeps each word atomic so the line only ever breaks at
   the spaces between words, never inside one. */
.bubble .word {
  display: inline-block;
  white-space: nowrap;
}

/* Bouncing characters */
.bubble .ch {
  display: inline-block;
  transform-origin: center bottom;
  animation: chPop .42s var(--ease) both;
}
@keyframes chPop {
  0%   { transform: translateY(8px) scale(.6); opacity: 0; }
  60%  { transform: translateY(-3px) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.bubble .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s steps(2) infinite;
  border-radius: 1px;
  opacity: .85;
}
@keyframes blink {
  to { opacity: 0; }
}

/* Bottom bar */
.bottom-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.05);
}
.input-wrap {
  flex: 1;
  display: flex; align-items: center;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
  position: relative;
  overflow: hidden;
}
.input-wrap .ghost-text {
  color: var(--text-3);
}
.input-wrap .live-input {
  color: var(--text);
}
.zap-btn {
  width: 46px; height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FFF95B, #FF930F);
  display: grid; place-items: center;
  border: 0;
  box-shadow: 0 10px 24px -8px rgba(255,147,15,.7), 0 0 0 1px rgba(255,255,255,.08) inset;
  position: relative;
  transition: transform .15s var(--ease), box-shadow .25s var(--ease);
}
.zap-btn:hover { transform: translateY(-1px) scale(1.04); }
.zap-btn:active { transform: scale(.94); }
.zap-btn svg { width: 22px; height: 22px; color: #1a1100; filter: drop-shadow(0 1px 0 rgba(255,255,255,.3)); }
.zap-btn::before {
  /* glow */
  content: "";
  position: absolute; inset: -6px;
  border-radius: 18px;
  background: radial-gradient(20px 20px at 50% 50%, rgba(255,217,0,.5), transparent 70%);
  filter: blur(6px);
  z-index: -1;
}

/* Reaction overlay (full-screen flash inside the phone) */
.flash-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 4;
  border-radius: 36px;
  overflow: hidden;
}

/* "ZAP" big letters in overlay */
.zap-shout {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.6) rotate(-6deg);
  font-size: 96px;
  font-weight: 900;
  letter-spacing: -0.06em;
  background: linear-gradient(180deg, #FFF95B, #FF930F);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  opacity: 0;
  text-shadow: 0 4px 24px rgba(255,147,15,.4);
  filter: drop-shadow(0 0 18px rgba(255,217,0,.5));
}
.zap-shout.go {
  animation: zapShout .9s var(--ease) forwards;
}
@keyframes zapShout {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-6deg); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(-2deg); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1.1) rotate(-3deg); }
}

/* Phone shake when zapped */
.phone.shaking { animation: phoneShake .55s ease-out; }
@keyframes phoneShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-6px, -3px) rotate(-.6deg); }
  20% { transform: translate(7px, 4px) rotate(.6deg); }
  30% { transform: translate(-5px, 5px) rotate(-.4deg); }
  40% { transform: translate(6px, -4px) rotate(.4deg); }
  50% { transform: translate(-4px, 3px); }
  60% { transform: translate(4px, -2px); }
  70% { transform: translate(-3px, -3px); }
  80% { transform: translate(2px, 2px); }
  90% { transform: translate(-1px, 0); }
}

/* Floating side decorations */
.float-emoji {
  position: absolute;
  font-size: 38px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.5));
  z-index: 0;
  pointer-events: none;
  user-select: none;
  opacity: .9;
}
.float-emoji.f1 { left: -20px; top: 60px;  animation: bob1 7s ease-in-out infinite; }
.float-emoji.f2 { right: -14px; top: 130px; animation: bob2 9s ease-in-out infinite; }
.float-emoji.f3 { left: 12px; bottom: 80px; animation: bob3 8s ease-in-out infinite; }
.float-emoji.f4 { right: 0px; bottom: 30px; animation: bob1 10s ease-in-out infinite reverse; }
@keyframes bob1 {
  0%,100% { transform: translate(0,0) rotate(-6deg); }
  50%     { transform: translate(8px,-12px) rotate(6deg); }
}
@keyframes bob2 {
  0%,100% { transform: translate(0,0) rotate(8deg); }
  50%     { transform: translate(-10px,-14px) rotate(-4deg); }
}
@keyframes bob3 {
  0%,100% { transform: translate(0,0) rotate(0); }
  50%     { transform: translate(6px,-10px) rotate(10deg); }
}

/* Hero phone — citrus (inverted: light on top, dark on bottom) + plum */
#phone .bubble.theirs {
  background: linear-gradient(180deg, #FFF95B, #FF930F);
  color: #2A1500;
  text-shadow: 0 1px 1px rgba(255,255,255,.25);
}
#phone .bubble.theirs::before { border-bottom-color: #FFF95B; }
#phone .bubble.mine {
  background: var(--g-plum);
  color: #fff;
  box-shadow: 0 12px 30px -8px rgba(68,15,80,.55);
}
#phone .bubble.mine::after { border-top-color: #440F50; }

/* =========================================================
   SPLIT-BUBBLE UI — matches actual app layout
   ========================================================= */

/* Prevent the empty-state collapse rules from affecting phone bubbles */
.phone .bubble.empty {
  opacity: 1 !important;
  transform: none !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 22px 24px !important;
  margin: 0 !important;
  border-width: 0 !important;
  box-shadow: none !important;
}

.phone .chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 50px 4px 0; /* top padding clears the notch & exposes the tail */
  gap: 8px;
  overflow: visible;
}

.phone .bubble {
  flex: 1;
  width: 100%;
  min-height: 0 !important;
  max-height: none;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 18px;
  padding: 22px 24px !important;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  position: relative;
  display: flex;
  overflow: visible; /* keep visible so tail triangles show */
}

.phone .bubble .ph {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 100%;
}

/* THEIRS — deep blue, pet emoji centred, text centred */
.phone .bubble.theirs {
  background: #1D4ED8;
  color: #fff;
  align-items: center;
  justify-content: center;
  border-top-left-radius: 6px;
}
.phone .bubble.theirs::before {
  content: "";
  position: absolute;
  top: -10px; left: 14px;
  width: 0; height: 0;
  border-left: 0 solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 12px solid #1D4ED8;
}
.phone .bubble.theirs .pet-mark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 54px;
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.3s;
}
/* fully hidden the moment text starts appearing */
.phone .bubble.theirs:not(.empty) .pet-mark { opacity: 0; }

/* MINE — deep rose, text centred vertically */
.phone .bubble.mine {
  background: #BE123C;
  color: #fff;
  align-items: center;
  justify-content: center;
  border-bottom-right-radius: 6px;
}
.phone .bubble.mine::after {
  content: "";
  position: absolute;
  bottom: -10px; right: 14px;
  width: 0; height: 0;
  border-left: 11px solid transparent;
  border-right: 0 solid transparent;
  border-top: 12px solid #BE123C;
}

/* Bottom contact bar */
.phone .app-bar {
  display: flex;
  align-items: center;
  padding: 9px 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.55);
  flex-shrink: 0;
}
.phone .back-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  display: grid; place-items: center;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
  cursor: pointer;
}
.phone .contact-info { flex: 1; padding: 0 10px; line-height: 1.25; }
.phone .contact-name { font-weight: 700; font-size: 12px; color: #fff; }
.phone .contact-status {
  font-size: 10px; color: rgba(255,255,255,0.38);
  display: flex; align-items: center; gap: 4px;
}
.phone .contact-status .sdot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.3); display: inline-block;
}
.phone .app-actions { display: flex; gap: 14px; align-items: center; }
.phone .act-btn {
  background: none; border: none;
  color: rgba(255,255,255,0.65);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
}

/* =========================================================
   PHONE KEYBOARD — decorative iOS-style QWERTY
   ========================================================= */
.phone .app-bar { padding-bottom: 8px; }

.phone-keyboard {
  background: #2b2b2d;
  padding: 8px 3px 4px;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}
.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 9px;
}
.kb-row-2 { padding: 0 16px; }
.kb-row-bottom { margin-bottom: 4px; gap: 4px; }

.kb-key {
  flex: 1 1 0;
  min-width: 0;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: linear-gradient(180deg, #6c6c70, #5a5a5d);
  color: #fff;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 0 rgba(0,0,0,.55);
  text-transform: lowercase;
}
.kb-key.kb-mod {
  background: linear-gradient(180deg, #3a3a3d, #2f2f31);
  font-size: 13px;
}
.kb-key.kb-shift,
.kb-key.kb-back { flex: 1.45 1 0; font-size: 14px; }
.kb-key.kb-num { flex: 1.45 1 0; }
.kb-key.kb-globe,
.kb-key.kb-mic { flex: 0.9 1 0; font-size: 13px; }
.kb-key.kb-space { flex: 5 1 0; font-size: 13px; color: rgba(255,255,255,0.85); }
.kb-key.kb-return { flex: 1.7 1 0; font-size: 12px; }

.kb-home {
  height: 4px;
  width: 120px;
  background: #fff;
  border-radius: 999px;
  margin: 6px auto 4px;
  opacity: 0.55;
}

@media (max-width: 480px) {
  .kb-key { height: 32px; font-size: 15px; }
  .kb-row { gap: 4px; margin-bottom: 7px; }
  .kb-row-2 { padding: 0 12px; }
}
