/* AniTech Chat Experience — Rina x ZiN | styles.css */

:root {
  --lavender-base: #C6CBE9;
  --accent-mid: #7A82C0;
  --accent-dark: #4C5391;
  --bubble-in: #FFFFFF;
  --text-dark: #2A2A35;
  --text-muted: #8A8DA6;
  --bg-overlay: rgba(10, 10, 25, .25);
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-display: 'Baloo 2', cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0A0A19;
  font-family: var(--font-body);
  color: var(--text-dark);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
img { display: block; max-width: 100%; }

/* ============ LOADING SCREEN ============ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background-image:
    linear-gradient(rgba(10, 10, 25, .45), rgba(10, 10, 25, .7)),
    url('assets/images/bg-mobile.jpg');
  background-size: cover;
  background-position: center;
  transition: opacity .4s ease, transform .4s ease;
}
#loading-screen.fade-out { opacity: 0; transform: scale(1.03); pointer-events: none; }

.loading-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  color: #fff;
  letter-spacing: .02em;
  animation: logoPulse 1.2s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { transform: scale(1); opacity: .85; }
  50% { transform: scale(1.05); opacity: 1; }
}

.loading-dots { display: flex; gap: 6px; }
.loading-dots .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,.85);
  animation: dotBounce 1s ease-in-out infinite;
}
.loading-dots .dot:nth-child(2) { animation-delay: .15s; }
.loading-dots .dot:nth-child(3) { animation-delay: .3s; }
@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.loading-caption {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  letter-spacing: .02em;
}

/* ============ DESKTOP BACKDROP (>=1024px only) ============ */
#desktop-backdrop { display: none; }

@media (min-width: 1024px) {
  #desktop-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image: url('assets/images/bg-desktop.jpg');
    background-size: cover;
    background-position: center;
    overflow: hidden;
  }
  #desktop-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
  }
  .desktop-left-col {
    position: absolute;
    left: 6%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: #fff;
    max-width: 320px;
  }
  .desktop-left-col .desktop-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 3.6rem);
    letter-spacing: .02em;
  }
  .desktop-left-col .desktop-tagline {
    margin-top: 10px;
    font-size: 14px;
    color: rgba(255,255,255,.75);
  }
  .desktop-marquee {
    position: absolute;
    top: 12%;
    left: 0;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    z-index: 0;
    opacity: .1;
    pointer-events: none;
  }
  .desktop-marquee span {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #fff;
    animation: marqueeScroll 75s linear infinite;
  }
  @keyframes marqueeScroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
  }
}

/* ============ PHONE MOCKUP (shared mobile/desktop shell) ============ */
#phone-mockup {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}

@media (min-width: 1024px) {
  #phone-mockup {
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 390px;
    height: 800px;
    border-radius: 44px;
    border: 9px solid #1A1A22;
    box-shadow: 0 40px 90px rgba(0,0,0,.55), 0 0 0 2px rgba(255,255,255,.04) inset;
    z-index: 2;
  }
  #phone-mockup::before {
    /* screen glare */
    content: '';
    position: absolute;
    top: 0; left: -20%;
    width: 60%; height: 34%;
    background: linear-gradient(120deg, rgba(255,255,255,.08), rgba(255,255,255,0) 70%);
    mix-blend-mode: overlay;
    opacity: .5;
    transform: skewX(-18deg);
    pointer-events: none;
    z-index: 50;
  }
}

/* ============ STATUS BAR ============ */
#status-bar {
  flex-shrink: 0;
  height: 32px;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--accent-dark);
  color: #fff;
  position: relative;
  z-index: 20;
}
.status-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-notch {
  position: absolute;
  left: 50%; top: 6px;
  transform: translateX(-50%);
  width: 84px; height: 16px;
  background: #000;
  border-radius: 10px;
}
.status-icons { display: flex; align-items: center; gap: 5px; }
.status-icons svg { display: block; }

/* ============ CHAT HEADER ============ */
#chat-header {
  flex-shrink: 0;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--accent-dark);
  color: #fff;
  position: relative;
  z-index: 20;
}
.header-back { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; opacity: .9; }
.header-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.8);
  background: #E9EBF7;
  /* full-body PNG: crop to head region (falls back to full body if unsupported) */
  object-view-box: inset(0% 38% 83% 38%);
}
.header-info { flex: 1; min-width: 0; }
.header-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.header-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: rgba(255,255,255,.75); }
.header-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #3ED598; }
#close-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  flex-shrink: 0;
}
#close-btn svg { width: 16px; height: 16px; }

/* ============ NOTICE STRIP ============ */
#notice-strip {
  flex-shrink: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dark);
  background: rgba(198, 203, 233, .85);
  position: relative;
  z-index: 15;
}

/* ============ CHAT BODY ============ */
#chat-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background-image: url('assets/images/wallpaper-chat.jpg');
  background-repeat: repeat;
  background-size: 320px auto;
  overflow-y: auto;
  padding: 14px 12px 24px;
  -webkit-overflow-scrolling: touch;
}
#chat-body.locked { overflow: hidden; touch-action: none; }
#chat-body::-webkit-scrollbar { display: none; }

#bubbles-container { display: flex; flex-direction: column; }

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 14px;
}
.bubble-row.same-sender { margin-top: 6px; }
.bubble-row.zin { justify-content: flex-start; }
.bubble-row.rina { justify-content: flex-end; }

.bubble-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #E9EBF7;
  object-view-box: inset(0% 38% 83% 38%);
}
.bubble-row.same-sender .bubble-avatar { visibility: hidden; }

.bubble {
  max-width: 75%;
  padding: 9px 12px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.42;
  position: relative;
  opacity: 0;
  transform: translateY(8px) scale(.97);
  transition: opacity .2s ease-out, transform .2s ease-out;
}
.bubble.bubble-enter-active { opacity: 1; transform: translateY(0) scale(1); }
.bubble.no-anim { opacity: 1; transform: none; transition: none; }

.bubble--zin { background: var(--bubble-in); color: var(--text-dark); border-bottom-left-radius: 4px; }
.bubble--rina { background: var(--accent-mid); color: #fff; border-bottom-right-radius: 4px; }

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-size: 10px;
  opacity: .65;
}
.bubble--zin .bubble-meta { color: var(--text-muted); }
.bubble--rina .bubble-meta { color: rgba(255,255,255,.8); }

.tick-svg { width: 13px; height: 8px; }
.tick-svg path { stroke: currentColor; transition: stroke .3s ease; }
.bubble-meta.read .tick-svg path { stroke: #53BDEB; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}
.typing-bubble .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1s ease-in-out infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: .15s; }
.typing-bubble .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Voice bubble */
.bubble--voice { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 190px; border-radius: 22px; }
.voice-controls { display: flex; align-items: center; gap: 10px; }
.voice-play-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bubble--rina .voice-play-btn { background: rgba(255,255,255,.25); color: #fff; }
.bubble--zin .voice-play-btn { background: rgba(76,83,145,.14); color: var(--accent-dark); }
.voice-play-btn .icon-pause { display: none; }
.bubble--voice.playing .icon-play { display: none; }
.bubble--voice.playing .icon-pause { display: block; }

.voice-waveform { position: relative; width: 88px; height: 22px; flex-shrink: 0; }
.wf-bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.wf-bars span { flex: 1; border-radius: 2px; }
.wf-progress { clip-path: inset(0 100% 0 0); }
.bubble--rina .wf-base span { background: rgba(255,255,255,.35); }
.bubble--rina .wf-progress span { background: rgba(255,255,255,.95); }
.bubble--zin .wf-base span { background: rgba(76,83,145,.22); }
.bubble--zin .wf-progress span { background: rgba(76,83,145,.9); }

.voice-duration { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .85; flex-shrink: 0; }

/* VN wait-gate hint ("dengerin dulu ya") */
.vn-hint {
  font-size: 12px;
  padding-left: 2px;
  opacity: 0;
  transition: opacity .4s ease;
}
.bubble--rina .vn-hint { color: rgba(255,255,255,.75); }
.bubble--zin .vn-hint { color: var(--text-muted); }
.vn-hint.visible { opacity: 1; animation: hintPulse 1.8s ease-in-out infinite; }
@keyframes hintPulse {
  0%, 100% { opacity: .55; }
  50% { opacity: .95; }
}
@media (prefers-reduced-motion: reduce) {
  .vn-hint.visible { animation: none; opacity: .85; }
}

/* Image bubble */
.bubble--image { padding: 0; overflow: hidden; width: 210px; max-width: 75%; border-radius: 18px; cursor: zoom-in; }
.bubble--image img { width: 100%; display: block; }
.bubble--image .image-caption {
  padding: 8px 12px 6px;
  font-size: 13px;
  line-height: 1.4;
  background: var(--accent-mid);
  color: #fff;
}

/* ============ SHARE + CTA SECTION ============ */
#share-section { margin-top: 22px; padding-bottom: 8px; }
#share-section[hidden] { display: none; }

.share-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: .3em;
  margin-bottom: 16px;
  opacity: 0;
  transition: opacity .4s ease;
}
.share-divider.visible { opacity: .8; }

.share-copy {
  text-align: center;
  font-size: 13px;
  color: var(--text-dark);
  background: rgba(255,255,255,.75);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .4s ease, transform .4s ease;
}
.share-copy.visible { opacity: 1; transform: none; }

.share-row { display: flex; justify-content: center; gap: 18px; margin-bottom: 18px; }
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .4s ease, transform .4s ease;
}
.share-btn.visible { opacity: 1; transform: none; }
.share-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-dark);
}
.share-label { font-size: 10px; color: var(--text-muted); }

.cta-card {
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent-mid), var(--accent-dark));
  padding: 14px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .4s ease, transform .4s ease;
}
.cta-card.visible { opacity: 1; transform: none; }
.cta-banner-img { width: 100%; border-radius: 14px; margin-bottom: 12px; }
.cta-body { display: flex; align-items: center; gap: 10px; }
.cta-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.8); flex-shrink: 0; background: #E9EBF7; object-view-box: inset(2% 34% 82% 38%); }
.cta-headline {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  line-height: 1.3;
}
.cta-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
#cta-button {
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.cta-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
  color: #fff;
  letter-spacing: .02em;
}

.footer-mini {
  text-align: center;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0;
  transition: opacity .4s ease;
}
.footer-mini.visible { opacity: .85; }
.footer-mini .footer-wordmark { font-family: var(--font-display); font-weight: 700; color: var(--text-dark); }

/* ============ WATERMARK ============ */
.watermark {
  position: absolute;
  right: 12px;
  bottom: 72px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  opacity: .35;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
  z-index: 25;
  pointer-events: none;
}

/* ============ INPUT BAR ============ */
#input-bar {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(198, 203, 233, .5);
  position: relative;
  z-index: 15;
}
.input-pill {
  flex: 1;
  height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  padding: 0 14px;
}
#mic-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-dark);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ============ HOME INDICATOR ============ */
#home-indicator {
  flex-shrink: 0;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(198, 203, 233, .5);
}
#home-indicator .bar { width: 120px; height: 5px; border-radius: 999px; background: var(--text-dark); opacity: .35; }

/* ============ LIGHTBOX ============ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* ============ SPEED BADGE ============ */
#speed-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
#speed-badge.visible { opacity: 1; }

/* ============ TOAST ============ */
#toast {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(20,20,30,.9);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90%;
  text-overflow: ellipsis;
  overflow: hidden;
}
#toast.visible { opacity: 1; }

/* ============ ACCESSIBILITY ============ */
@media (prefers-reduced-motion: reduce) {
  .loading-logo { animation: none; }
  .desktop-marquee span { animation: none; }
  .loading-dots .dot, .typing-bubble .dot { animation: none; }
  .bubble { transition: none; }
}
