/* ============================================================
   WhatsApp-style number popup (assets/wa-popup.js), long landing.
   Same design as Durham and Horizon; the /go flow carries its own
   copy in flow/src/flow/wa-popup.css.
   Colours follow WhatsApp's own UI, not the school palette:
   the parent should recognise the chat before reading it.
   ============================================================ */

.wa-pop {
  --wa-head: #008069;
  --wa-green: #25d366;
  --wa-green-dark: #1ebe5a;
  --wa-wall: #efeae2;
  --wa-in: #ffffff;
  --wa-out: #d9fdd3;
  --wa-ink: #111b21;
  --wa-meta: #667781;
  --wa-tick: #53bdeb;
  position: fixed;
  inset: 0;
  z-index: 1000; /* above the sticky bar (40) and the lightbox (100) */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wa-ink);
}

.wa-pop[dir="rtl"] {
  font-family: "Tajawal", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wa-pop[hidden],
.wa-pop [hidden] {
  display: none !important;
}

.wa-pop__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(11, 20, 26, 0.18);
  cursor: default;
  animation: wa-fade 180ms ease-out;
}

.wa-pop__panel {
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: 372px;
  max-height: min(560px, calc(100vh - 52px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: var(--wa-wall);
  box-shadow: 0 24px 70px rgba(11, 20, 26, 0.32), 0 2px 8px rgba(11, 20, 26, 0.12);
  transform-origin: bottom right;
  animation: wa-pop-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

[dir="rtl"] .wa-pop__panel {
  right: auto;
  left: 26px;
  transform-origin: bottom left;
}

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

.wa-pop__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--wa-head);
  color: #fff;
}

.wa-pop__avatar {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
}

.wa-pop__who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-pop__who strong {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.wa-pop__who small {
  font-size: 12.5px;
  line-height: 1.3;
  opacity: 0.85;
}

.wa-pop__close {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.wa-pop__close:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

.wa-pop__chat {
  flex: 1;
  min-height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px 14px;
  /* quiet doodle texture, like the WhatsApp wallpaper */
  background-color: var(--wa-wall);
  background-image:
    radial-gradient(rgba(17, 27, 33, 0.045) 1.2px, transparent 1.3px),
    radial-gradient(rgba(17, 27, 33, 0.03) 1px, transparent 1.1px);
  background-size: 22px 22px, 34px 34px;
  background-position: 0 0, 11px 17px;
}

.wa-bubble {
  position: relative;
  max-width: 84%;
  padding: 7px 9px 8px 10px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.38;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  animation: wa-bubble-in 200ms ease-out both;
}

.wa-bubble time {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 8px 0 -4px 10px;
  font-size: 11px;
  line-height: 1;
  color: var(--wa-meta);
  white-space: nowrap;
}

[dir="rtl"] .wa-bubble time {
  float: left;
  margin: 8px 10px -4px 0;
}

/* flex-start/end follow the text direction, so in RTL incoming sits right */
.wa-bubble--in {
  align-self: flex-start;
  background: var(--wa-in);
}

.wa-bubble--out {
  align-self: flex-end;
  background: var(--wa-out);
  font-variant-numeric: tabular-nums;
}

.wa-bubble--tail {
  margin-top: 6px;
}

.wa-bubble--in.wa-bubble--tail {
  border-top-left-radius: 0;
}

.wa-bubble--out.wa-bubble--tail {
  border-top-right-radius: 0;
}

.wa-bubble--in.wa-bubble--tail::before,
.wa-bubble--out.wa-bubble--tail::before {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
}

.wa-bubble--in.wa-bubble--tail::before {
  left: -8px;
  background: var(--wa-in);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.wa-bubble--out.wa-bubble--tail::before {
  right: -8px;
  background: var(--wa-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

[dir="rtl"] .wa-bubble--in.wa-bubble--tail {
  border-top-left-radius: 8px;
  border-top-right-radius: 0;
}

[dir="rtl"] .wa-bubble--in.wa-bubble--tail::before {
  left: auto;
  right: -8px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.wa-ticks {
  color: var(--wa-tick);
}

.wa-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}

.wa-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8696a0;
  animation: wa-dot 1s infinite ease-in-out;
}

.wa-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.wa-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

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

.wa-pop__composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 6px;
  background: var(--wa-wall);
}

.wa-pop__field {
  flex: 1;
  min-width: 0;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  transition: box-shadow 160ms ease;
}

.wa-pop__field.has-error {
  box-shadow: 0 0 0 2px #e5484d;
}

.wa-pop__avatar img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

/* The page's own dial-code picker (app.js wirePhone), restyled to sit inside
   the round WhatsApp field. It is not in a .field, so the form styles of
   style.css do not reach it; its narrow-screen wrap rule does, and is undone. */
.wa-pop .phone-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  min-height: 48px;
  padding: 0 14px 0 6px;
}

.wa-pop[dir="rtl"] .phone-group {
  padding: 0 6px 0 14px;
}

.wa-pop .phone-group select {
  flex: 0 0 auto;
  min-inline-size: 0;
  max-inline-size: 7rem;
  height: 40px;
  margin: 0;
  padding: 0 20px 0 8px;
  border: 0;
  border-radius: 20px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%23667781' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 6px center;
  font: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--wa-ink);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.wa-pop[dir="rtl"] .phone-group select {
  padding: 0 8px 0 20px;
  background-position: left 6px center;
}

.wa-pop .phone-group input {
  flex: 1 1 auto;
  min-inline-size: 0;
  height: 48px;
  margin: 0;
  padding: 0 0 0 6px;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--wa-ink);
  direction: ltr;
}

.wa-pop[dir="rtl"] .phone-group input {
  padding: 0 6px 0 0;
  text-align: right;
}

.wa-pop .phone-group select:focus-visible {
  outline: 2px solid var(--wa-head);
  outline-offset: -2px;
}

.wa-pop__field:not(.has-error):focus-within {
  box-shadow: 0 0 0 2px var(--wa-head);
}

.wa-pop__send {
  flex: none;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(18, 140, 75, 0.35);
  transition: background 140ms ease, transform 140ms ease;
}

.wa-pop__send:hover {
  background: var(--wa-green-dark);
}

.wa-pop__send:active {
  transform: scale(0.94);
}

[dir="rtl"] .wa-pop__send svg {
  transform: scaleX(-1);
}

.wa-pop__consent {
  margin: 0;
  padding: 2px 16px 12px;
  background: var(--wa-wall);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--wa-meta);
}

.wa-pop__consent a {
  color: inherit;
  text-decoration: underline;
}

.wa-pop__error {
  display: block;
  margin-bottom: 3px;
  font-size: 12.5px;
  font-weight: 600;
  color: #d13438;
}

/* ---------- mobile: bottom sheet ---------- */

@media (max-width: 768px) {
  .wa-pop__backdrop {
    background: rgba(11, 20, 26, 0.45);
  }

  .wa-pop__panel,
  [dir="rtl"] .wa-pop__panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--wa-wall);
    transform-origin: bottom center;
    animation: wa-sheet-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1);
  }
}

/* ---------- motion ---------- */

@keyframes wa-fade {
  from { opacity: 0; }
}

@keyframes wa-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
}

@keyframes wa-sheet-in {
  from { transform: translateY(100%); }
}

@keyframes wa-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
}

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

@media (prefers-reduced-motion: reduce) {
  .wa-pop__backdrop,
  .wa-pop__panel,
  .wa-bubble,
  .wa-typing i {
    animation: none !important;
  }
}
