/* ─────────────────────────────────────────
   Imisi · Mobile UI (Girl Experience)
   Renders as a full-screen mobile app
───────────────────────────────────────── */

/* ── Reset & root ── */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  height: 100dvh; /* dynamic viewport — handles mobile browser chrome */
}

body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #0D1A14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  margin: 0;
}

/* ── Background ── */
.mobile-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 15% 8%,  rgba(15,110,86,0.22) 0%, transparent 55%),
    radial-gradient(ellipse 50% 70% at 85% 85%, rgba(249,115,22,0.08) 0%, transparent 55%),
    #0D1A14;
  z-index: 0;
  pointer-events: none;
}

/* ── Outer layout ── */
.mobile-layout {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  gap: 2rem;
}

/* ── Device frame ── */
.device-frame {
  /* Fixed phone proportions on desktop, full-screen on mobile */
  width: 375px;
  height: min(812px, calc(100dvh - 3rem));
  flex-shrink: 0;

  background: #111;
  border-radius: 50px;
  padding: 14px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 50px 100px rgba(0,0,0,0.7),
    inset 0 0 0 1px rgba(255,255,255,0.04);

  /* Critical: flex column so screen fills the frame */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* clip the rounded corners only */
}

/* ── Notch ── */
.device-notch {
  width: 120px;
  height: 26px;
  background: #0a0a0a;
  border-radius: 0 0 18px 18px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}
.device-notch-cam {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #222;
}
.device-notch-speaker {
  width: 40px; height: 4px;
  border-radius: 4px;
  background: #1a1a1a;
}

/* ── Screen — the key container ── */
.device-screen {
  flex: 1;           /* fill remaining frame height */
  min-height: 0;     /* allow flex child to shrink below content size */
  background: #0a120d;
  border-radius: 36px;
  overflow: hidden;  /* clip rounded corners */

  /* Flex column: fixed bars top & bottom, chat feed fills middle */
  display: flex;
  flex-direction: column;
}

/* ── Status bar ── */
.status-bar {
  flex-shrink: 0;
  background: #0a120d;
  padding: 8px 20px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
}
.status-time { font-weight: 600; }
.status-icons { display: flex; align-items: center; gap: 4px; }

/* ── App header ── */
.app-header {
  flex-shrink: 0;
  background: var(--green-700);
  padding: 10px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-back {
  color: rgba(255,255,255,0.7);
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  transition: color 0.15s;
  text-decoration: none;
}
.app-back:hover { color: var(--white); }
.app-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-300), var(--ember-500));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.app-header-info { flex: 1; min-width: 0; }
.app-name { font-size: 0.875rem; font-weight: 700; color: var(--white); }
.app-status {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.65);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}
.app-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #86efac;
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
.app-header-actions { display: flex; gap: 6px; }
.app-header-btn {
  color: rgba(255,255,255,0.65);
  font-size: 1rem;
  padding: 4px;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.15s;
  line-height: 1;
}
.app-header-btn:hover { color: var(--white); }

/* ── Language bar ── */
.lang-bar {
  flex-shrink: 0;
  background: rgba(15,110,86,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 5px 10px;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.lang-bar::-webkit-scrollbar { display: none; }
.lang-btn {
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.66rem;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  background: transparent;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.lang-btn.active,
.lang-btn:hover {
  background: var(--green-700);
  border-color: var(--green-300);
  color: var(--white);
}

/* ── Chat feed — THE scrollable area ── */
.chat-feed {
  flex: 1;           /* take all remaining vertical space */
  min-height: 0;     /* CRITICAL — without this flex won't constrain height */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;

  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 7px;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(93,202,165,0.25) transparent;
}
.chat-feed::-webkit-scrollbar { width: 3px; }
.chat-feed::-webkit-scrollbar-track { background: transparent; }
.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(93,202,165,0.25);
  border-radius: 3px;
}

/* Push messages to bottom when feed is not full */
.chat-feed::before {
  content: '';
  flex: 1;
}

.chat-date-label {
  text-align: center;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.22);
  margin: 2px 0 4px;
  flex-shrink: 0;
}

/* ── Chat bubbles ── */
.chat-bubble {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.775rem;
  line-height: 1.55;
  word-break: break-word;
  animation: msgIn 0.25s ease both;
  flex-shrink: 0;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-bubble.ai {
  background: rgba(15,110,86,0.28);
  color: #d1fae5;
  border: 1px solid rgba(93,202,165,0.18);
  border-radius: 4px 16px 16px 16px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: var(--ember-500);
  color: var(--white);
  border-radius: 16px 4px 16px 16px;
  align-self: flex-end;
}
.chat-bubble.system {
  background: rgba(15,110,86,0.12);
  border: 1px solid rgba(93,202,165,0.2);
  border-radius: 10px;
  align-self: center;
  text-align: center;
  font-size: 0.67rem;
  color: var(--green-300);
  max-width: 94%;
}

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  gap: 3px;
  align-items: center;
  padding: 3px 2px;
}
.typing-indicator span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green-300);
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Curiosity card ── */
.curiosity-card {
  flex-shrink: 0;
  margin: 0 10px 6px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(93,202,165,0.13);
  border-radius: 10px;
  padding: 8px 10px;
}
.curiosity-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--green-300);
  margin-bottom: 6px;
}
.curiosity-pulse {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
.curiosity-bars { display: flex; flex-direction: column; gap: 4px; }
.curiosity-row { display: flex; align-items: center; gap: 7px; }
.curiosity-label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.38);
  width: 58px;
  flex-shrink: 0;
}
.curiosity-track {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.curiosity-fill { height: 100%; border-radius: 3px; }
.curiosity-pct {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--green-300);
  width: 26px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Quick replies ── */
.quick-replies {
  flex-shrink: 0;
  padding: 5px 10px;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply {
  padding: 4px 11px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid rgba(93,202,165,0.22);
  color: var(--green-300);
  background: rgba(15,110,86,0.08);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.18s;
}
.quick-reply:hover,
.quick-reply:active {
  background: var(--green-700);
  border-color: var(--green-300);
  color: var(--white);
}

/* ── Input bar ── */
.input-bar {
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #0a120d;
}
.input-bar input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 8px 14px;
  color: var(--white);
  font-size: 0.78rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.input-bar input:focus {
  border-color: var(--green-500);
  background: rgba(255,255,255,0.08);
}
.input-bar input::placeholder { color: rgba(255,255,255,0.28); }
.input-bar input:disabled { opacity: 0.5; cursor: not-allowed; }

.send-button {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ember-500);
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: var(--white);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.send-button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 14px rgba(249,115,22,0.5);
}
.send-button:active { transform: scale(0.95); }
.send-button:disabled {
  background: rgba(249,115,22,0.35);
  cursor: not-allowed;
  transform: none;
}

/* ── Home indicator ── */
.home-indicator {
  flex-shrink: 0;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a120d;
}
.home-bar {
  width: 110px; height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
}

/* ── Side info panel (desktop only) ── */
.side-panel {
  position: relative;
  z-index: 1;
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.side-panel::-webkit-scrollbar { width: 3px; }
.side-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.side-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 1.125rem;
}
.side-card-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  margin-bottom: 0.75rem;
}
.side-eyebrow {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ember-500);
  margin-bottom: 0.4rem;
}
.side-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--white);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}
.side-title .hi { color: var(--green-300); }
.side-body {
  font-size: 0.775rem;
  color: rgba(255,255,255,0.42);
  line-height: 1.7;
}

.lesson-matched {
  background: linear-gradient(135deg, rgba(15,110,86,0.18), rgba(15,110,86,0.06));
  border: 1px solid rgba(15,110,86,0.28);
  border-radius: 10px;
  padding: 0.875rem;
}
.lesson-matched-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(15,110,86,0.2);
  color: #d1fae5;
  border-radius: 50px;
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.lesson-matched-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 0.2rem;
}
.lesson-matched-meta {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.32);
  margin-bottom: 0.5rem;
}
.lesson-matched-preview {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.52);
  line-height: 1.6;
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.2);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
}

/* ── Animations ── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.8); }
}

/* ── Full-screen on real mobile devices ── */
@media (max-width: 520px) {
  body { background: #0a120d; }
  .mobile-bg { display: none; }

  .mobile-layout {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .device-frame {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: #0a120d;
  }

  .device-notch { display: none; }

  .device-screen {
    border-radius: 0;
    height: 100dvh;
  }

  .side-panel { display: none; }
}

/* ── Hide side panel on medium screens ── */
@media (max-width: 900px) {
  .side-panel { display: none; }
  .mobile-layout { padding: 1rem; }
}

/* ── Landscape on small screens ── */
@media (max-height: 600px) and (max-width: 900px) {
  .device-frame {
    height: 100dvh;
    border-radius: 0;
    padding: 0;
  }
  .device-notch { display: none; }
  .device-screen { border-radius: 0; }
  .curiosity-card { display: none; }
}
