/* ============ WHATSAPP DOST — chat edition ============ */

:root {
  --wa-green: #008069;
  --wa-green-dark: #006b58;
  --wa-send: #00a884;
  --wa-bg: #ece5dd;
  --wa-out: #d9fdd3;
  --wa-in: #ffffff;
  --wa-text: #111b21;
  --wa-time: #667781;
  --wa-tick: #53bdeb;
  --bezel: #17171a;
}

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

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #b8bfae;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* sage backdrop + grain, same family as the street edition */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 130% 90% at 50% -20%, #c6cdbb 0%, #b8bfae 60%, #a9b19d 100%);
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page-title {
  position: relative;
  z-index: 1;
  font-family: "Yatra One", serif;
  font-weight: 400;
  font-size: clamp(28px, 4.5vw, 44px);
  color: #fdf6e6;
  text-shadow: 0 3px 0 rgba(120, 26, 18, 0.45), 0 8px 20px rgba(0, 0, 0, 0.2);
  transform: rotate(-1deg);
}

.page-sub {
  position: relative;
  z-index: 1;
  font-size: 13px;
  color: #5c6353;
  letter-spacing: 0.03em;
}

/* ---------- phone mockup ---------- */

.phone {
  position: relative;
  z-index: 1;
  width: 392px;
  height: min(780px, calc(100dvh - 140px));
  min-height: 480px;
  background: var(--bezel);
  border-radius: 46px;
  padding: 10px;
  box-shadow:
    0 40px 80px -24px rgba(20, 20, 15, 0.55),
    0 12px 28px -12px rgba(20, 20, 15, 0.4),
    inset 0 0 0 2px #2c2c30;
}

.phone-notch {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #000;
  box-shadow: inset 0 0 0 3px #0a0a0c, 0 0 0 2px rgba(255,255,255,0.05);
  z-index: 10;
}

.phone-btn {
  position: absolute;
  right: -3px;
  width: 3px;
  border-radius: 2px;
  background: #2c2c30;
}
.phone-btn--power { top: 150px; height: 64px; }
.phone-btn--vol { top: 235px; height: 96px; }

.screen {
  position: relative; /* anchors the media viewer overlay */
  width: 100%;
  height: 100%;
  border-radius: 37px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg);
}

/* ---------- status bar ---------- */

.statusbar {
  background: var(--wa-green);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 22px 2px;
}

.sb-icons {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ---------- wa header ---------- */

.wa-header {
  background: var(--wa-green);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.hd-back {
  position: relative;
  background: none;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 4px 2px 4px 6px;
  cursor: default;
}

.hd-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--wa-green);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hd-avatar img {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.hd-meta { flex: 1; min-width: 0; }

.hd-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hd-status {
  font-size: 12.5px;
  opacity: 0.85;
  min-height: 15px;
}

.hd-status.typing {
  font-style: italic;
}

.hd-icons {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-right: 6px;
}

/* ---------- chat area ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  padding: 12px 12px 10px;
  overflow: hidden;
  position: relative;
  /* doodle pattern */
  background-color: var(--wa-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23d9cfc2' stroke-width='1.4' stroke-linecap='round' opacity='0.55'%3E%3Cpath d='M22 24 l4 4 M26 24 l-4 4'/%3E%3Ccircle cx='86' cy='36' r='4'/%3E%3Cpath d='M140 22 q4 -8 8 0 q8 -4 0 4 q4 8 -4 4 q-8 4 -4 -4 q-8 0 0 -4z'/%3E%3Cpath d='M30 88 h10 M35 83 v10'/%3E%3Cpath d='M150 90 l6 -3 v10 l-6 -3 z M138 88 a5 5 0 1 0 0 8'/%3E%3Cpath d='M84 96 q3 -6 6 0 q6 3 0 6 q-3 6 -6 0 q-6 -3 0 -6z'/%3E%3Cpath d='M24 148 c0 -5 8 -5 8 0 c0 5 -8 8 -8 8 c0 0 -8 -3 -8 -8 c0 -5 8 -5 8 0z' transform='translate(8 -6)'/%3E%3Cpath d='M92 152 l14 -6 -6 14 -3 -5 z'/%3E%3Ccircle cx='150' cy='150' r='5'/%3E%3Cpath d='M148 148 l4 4'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.date-chip {
  align-self: center;
  background: #fff;
  color: #667781;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  margin-bottom: 4px;
}

/* ---------- bubbles ---------- */

.msg {
  position: relative;
  max-width: 78%;
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  animation: msgIn 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.18);
}

@keyframes msgIn {
  from { opacity: 0; transform: scale(0.75) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.msg.in {
  align-self: flex-start;
  background: var(--wa-in);
  border-top-left-radius: 2px;
  transform-origin: bottom left;
}

.msg.out {
  align-self: flex-end;
  background: var(--wa-out);
  border-top-right-radius: 2px;
  transform-origin: bottom right;
}

/* tails */
.msg.in::before,
.msg.out::before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-top: 9px solid;
  border-top-color: inherit;
}
.msg.in::before {
  left: -7px;
  border-top-color: var(--wa-in);
  border-left: 8px solid transparent;
}
.msg.out::before {
  right: -7px;
  border-top-color: var(--wa-out);
  border-right: 8px solid transparent;
}

.msg-text {
  padding: 7px 10px 8px;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--wa-text);
}

.msg-meta {
  float: right;
  margin: 6px 2px -4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--wa-time);
  white-space: nowrap;
}

.ticks svg { display: block; }
.ticks.read path { stroke: var(--wa-tick); }

/* media bubble */
.msg.media {
  padding: 4px;
  max-width: 84%;
}

.fwd-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-style: italic;
  color: #8696a0;
  padding: 3px 6px 5px;
}

.media-wrap {
  position: relative;
  border-radius: 7px;
  overflow: hidden;
}

.media-wrap img {
  display: block;
  width: min(258px, 62vw);
  aspect-ratio: 1 / 1; /* the collection is square 1200x1200 — never crop the suvichar text */
  object-fit: cover;
  background: #ddd5c8;
}

.media-time {
  position: absolute;
  right: 7px;
  bottom: 6px;
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.media-wrap img { cursor: pointer; }

/* ---------- media viewer (tap to enlarge) ---------- */

.viewer {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #0c1317;
  display: flex;
  flex-direction: column;
  animation: viewerIn 0.16s ease;
}

.viewer[hidden] { display: none; }

@keyframes viewerIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.viewer-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 12px 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
  color: #fff;
}

.viewer-back {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
}

.viewer-meta { flex: 1; min-width: 0; }

.viewer-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-time {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}

.viewer-dl {
  padding: 6px;
  display: flex;
  text-decoration: none;
}

.viewer-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-out;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  animation: viewerZoom 0.18s ease;
}

@keyframes viewerZoom {
  from { transform: scale(0.82); opacity: 0.4; }
  to   { transform: scale(1); opacity: 1; }
}

.media-caption {
  padding: 6px 6px 7px;
  font-size: 13.5px;
  color: var(--wa-text);
}

/* forward shortcut beside media bubble */
.fwd {
  position: absolute;
  right: -42px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* typing indicator */
.msg.typing {
  padding: 12px 14px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.msg.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa8b0;
  animation: dotBounce 1.1s ease-in-out infinite;
}
.msg.typing i:nth-child(2) { animation-delay: 0.15s; }
.msg.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- composer ---------- */

.composer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px 10px;
  background: transparent;
}

.compose-pill {
  flex: 1;
  min-width: 0; /* let the pill shrink; without this a long phrase shoves the send button off-screen */
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.cp-text {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  color: var(--wa-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--wa-send);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 100, 80, 0.35);
  transition: transform 0.1s ease;
  flex-shrink: 0;
}

.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(0.92); }

/* ---------- small screens: chat fills phone-less viewport ---------- */

@media (max-width: 560px), (max-height: 640px) {
  body { gap: 0; }
  .page-title, .page-sub { display: none; }
  .phone {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: none;
  }
  .phone-notch, .phone-btn { display: none; }
  .screen { border-radius: 0; }
  .statusbar { padding-top: max(8px, env(safe-area-inset-top)); }
  .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  /* real phones get real WhatsApp proportions — bigger bubbles, bigger type */
  .msg { max-width: 85%; }
  .msg-text { font-size: 16px; }
  .msg-meta { font-size: 11.5px; }
  .media-wrap img { width: min(78vw, 340px); }
  .media-caption { font-size: 15px; }
  .fwd-label { font-size: 12.5px; }
  .cp-text { font-size: 16px; }
  .hd-name { font-size: 17.5px; }
  .hd-status { font-size: 13px; }
  .hd-avatar img { width: 42px; height: 42px; }
  .date-chip { font-size: 12.5px; }
  .send-btn { width: 50px; height: 50px; }
}
