/* jabbachat — light, bubblegum, mobile-first. */

:root {
  --pink: #ff8fc7;
  --pink-deep: #ff5fae;
  --violet: #a78bfa;
  --sky: #7fd3ff;
  --mint: #7ff0c0;
  --sun: #ffd66b;
  --ink: #2b2440;
  --ink-soft: #6b6386;
  --paper: #fff7fc;
  --card: #ffffff;
  --line: #f0e3f0;
  --on: #35d07f;
  --off: #c9c3d6;
  --shadow: 0 10px 30px rgba(160, 80, 160, 0.15);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff0f8 0%, #f3f0ff 45%, #ecfbff 100%);
}

body { overflow: hidden; }

.app {
  /* Height is driven by JS from window.visualViewport so the composer + live
     bubbles stay above the mobile keyboard instead of hiding behind it. */
  height: var(--app-h, 100dvh);
  max-width: 480px;
  margin: 0 auto;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

/* ---- screens ---- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.screen.is-active { display: flex; }

/* ---- onboarding ---- */
.hero { text-align: center; margin-top: 18vh; }
.logo {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(90deg, var(--pink-deep), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo span { color: var(--sun); -webkit-text-fill-color: var(--sun); }
.tagline { color: var(--ink-soft); font-weight: 600; margin-top: -4px; }

.card {
  background: var(--card);
  margin: 32px 24px;
  padding: 24px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card label { font-weight: 800; font-size: 14px; color: var(--ink-soft); }

input[type="text"] {
  font: inherit;
  font-weight: 700;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
input[type="text"]:focus { border-color: var(--pink); }

/* ---- buttons ---- */
.btn {
  font: inherit;
  font-weight: 800;
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--pink-deep), var(--violet));
  box-shadow: 0 8px 20px rgba(255, 95, 174, 0.35);
}
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn.copied { background: linear-gradient(90deg, var(--mint), var(--sky)); color: var(--ink); box-shadow: 0 8px 20px rgba(127, 211, 255, .35); }
.btn-add {
  margin: 16px 20px 8px;
  color: var(--ink);
  background: #fff;
  border: 2px dashed var(--pink);
  box-shadow: var(--shadow);
}

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  min-height: 60px;
}
.me, .peer { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.me-handle, .peer-handle { font-size: 18px; }
.chat-top { justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.6); }

.icon-btn {
  border: none;
  background: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.nudge { background: linear-gradient(90deg, var(--sun), var(--pink)); }
#back-btn { font-size: 30px; font-weight: 900; color: var(--pink-deep); }

/* ---- presence dots ---- */
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--off); display: inline-block; }
.dot-on, .dot.on { background: var(--on); box-shadow: 0 0 0 3px rgba(53,208,127,.2); }

/* ---- friends list ---- */
.home-body { flex: 1; overflow-y: auto; }
.list-title { margin: 12px 20px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.friend-list { list-style: none; margin: 0; padding: 0 12px; }
.friend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 18px;
  margin: 8px 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s;
}
.friend-row:active { transform: scale(0.98); }
.friend-row .fr-handle { font-weight: 800; flex: 1; }
.friend-row .fr-status { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.friend-row.has-unread { background: #fff0f8; box-shadow: 0 0 0 2px var(--pink), var(--shadow); }
.friend-row.has-unread .fr-handle { font-weight: 900; }
.fr-badge {
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink-deep), var(--violet));
  color: #fff; font-weight: 800; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  animation: pop .18s ease;
}
.empty { text-align: center; color: var(--ink-soft); padding: 24px 32px; font-weight: 600; line-height: 1.5; }
.fr-clear {
  border: none; background: transparent; font-size: 16px;
  cursor: pointer; opacity: .45; padding: 6px; border-radius: 10px; line-height: 1;
}
.fr-clear:active { transform: scale(.9); opacity: 1; }
.btn-clear-all {
  display: block; margin: 18px auto 8px; padding: 8px 14px;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-soft); font-weight: 700; font-size: 13px; opacity: .75;
}
.btn-clear-all:active { transform: scale(.97); }
.hidden { display: none !important; }

/* ---- chat ---- */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 20px;
  font-weight: 600;
  line-height: 1.35;
  word-wrap: break-word;
  animation: pop .18s ease;
}
.msg.mine { align-self: flex-end; color: #fff; background: linear-gradient(90deg, var(--pink-deep), var(--violet)); border-bottom-right-radius: 6px; }
.msg.theirs { align-self: flex-start; background: #fff; color: var(--ink); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }

/* live as-you-type strip — two bubbles, both visible at once.
   Them on the left, you on the right, so concurrent typing is unmistakable. */
.live-strip { padding: 4px 12px; display: flex; flex-direction: column; gap: 4px; }
.live-bubble {
  max-width: 85%;
  padding: 6px 12px;
  border-radius: 16px;
  font-weight: 600;
  background: rgba(255,255,255,.8);
  display: none;
}
.live-bubble.show { display: block; animation: pop .15s ease; }
.live-bubble.theirs { align-self: flex-start; color: var(--ink-soft); border: 2px dashed var(--violet); border-bottom-left-radius: 4px; }
.live-bubble.mine { align-self: flex-end; color: var(--pink-deep); border: 2px dashed var(--pink); border-bottom-right-radius: 4px; }
.live-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 800; opacity: .65; margin-right: 6px; }
.caret { display: inline-block; width: 2px; height: 1em; vertical-align: text-bottom; background: currentColor; animation: blink 1s steps(1) infinite; }

/* reactions bar */
.reactions-bar { display: flex; gap: 6px; padding: 6px 12px; justify-content: center; }
.react {
  border: none; background: #fff; font-size: 22px;
  width: 46px; height: 46px; border-radius: 50%;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .08s;
}
.react:active { transform: scale(1.25); }

/* composer */
.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.7); border-top: 1px solid var(--line); }
.composer input { flex: 1; }
.btn-send {
  color: #fff; font-size: 18px; width: 52px;
  background: linear-gradient(90deg, var(--pink-deep), var(--violet));
}

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(43,36,64,.4); display: none; align-items: flex-end; justify-content: center; z-index: 50; }
.modal.show { display: flex; }
.modal-card {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 28px 28px 0 0; padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  animation: slideup .22s ease;
}
.modal-card h3 { margin: 0; font-size: 22px; }
.modal-sub { margin: 0; color: var(--ink-soft); font-weight: 600; line-height: 1.4; }

/* ---- first-time splash ---- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: #f4d877; /* matches the image backdrop so it blends */
  animation: fadein .25s ease;
  cursor: pointer;
}
.splash.show { display: flex; }
.splash.hide { animation: fadeout .4s ease forwards; }
.splash-img { max-width: 92%; max-height: 92%; object-fit: contain; }
.splash-x {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(43, 36, 64, .25);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  z-index: 1;
}
.splash-x:active { transform: scale(0.92); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; } }

/* ---- fx layer (flying reactions) ---- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fx-emoji { position: absolute; font-size: 42px; animation: floatup 1.6s ease-out forwards; }

/* ---- screen shake (nudge) ---- */
.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97) both; }

/* ---- keyframes ---- */
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes floatup {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  20% { opacity: 1; transform: translateY(-10px) scale(1.2); }
  100% { transform: translateY(-70vh) scale(1); opacity: 0; }
}
@keyframes shake {
  10%, 90% { transform: translate(-2px, 0); }
  20%, 80% { transform: translate(4px, 0); }
  30%, 50%, 70% { transform: translate(-8px, 0); }
  40%, 60% { transform: translate(8px, 0); }
}
