/* D-425: the demo menu (bottom-left) and the missed-call cost calculator.
 *
 * The menu stays on the physical left in every language, RTL included: the Chat
 * App bubble is pinned bottom-right by its own loader, and the two must never
 * meet. Its z-index sits under the Chat App's (2147483000), so an open chat
 * panel covers the menu rather than the other way round.
 */

/* ---------------- demo menu ---------------- */

.dbub {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 70;
  /* Never wider than the space left of the Chat App launcher (≈ 80 px). */
  max-width: calc(100vw - 112px);
}

.dbub-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-height: 52px;
  padding: 7px 18px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--txt);
  font: 600 14px/1.2 var(--font-b);
  box-shadow: var(--shadow);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dbub-launch:hover {
  box-shadow: var(--glow-violet);
}

.dbub-launch:focus-visible,
.dbub-opt:focus-visible,
.dbub-x:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.dbub-orb {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 18px -4px rgba(124, 92, 255, 0.8);
  animation: dbub-pulse 3.2s ease-in-out infinite;
}

.dbub-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dbub.open .dbub-orb {
  animation: none;
}

/* D-440: the SNS mark beside "Try the demo" (decorative; the label names the button). */
.dbub-logo {
  flex: none;
  width: 30px;
  height: 30px;
}

@keyframes dbub-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.dbub-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: min(340px, calc(100vw - 32px));
  max-height: min(70vh, 600px); /* D-440: room for the call item; was 520px */
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  background-color: var(--ink);
  color: var(--txt);
  box-shadow: var(--shadow-lg);
}

.dbub-panel[hidden] {
  display: none;
}

.dbub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.dbub-head h2 {
  margin: 0;
  font: 700 16px/1.3 var(--font-d);
}

.dbub-x {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--txt-2);
  cursor: pointer;
}

.dbub-x:hover {
  background: var(--line);
  color: var(--txt);
}

.dbub-x svg,
.dbub-ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dbub-ico svg path[d^="M8 5.5"],
.dbub-ico svg path[d^="M4 5h"] {
  fill: currentColor;
  stroke: none;
}

.dbub-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.dbub-list li[hidden] {
  display: none;
}

.dbub-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.dbub-opt:hover {
  border-color: var(--line);
  background: var(--brand-soft);
}

.dbub-opt b {
  display: block;
  font-size: 14px;
}

.dbub-opt small {
  display: block;
  margin-top: 2px;
  color: var(--txt-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.dbub-ico {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--cyan);
}

.dbub-start {
  display: flex;
  justify-content: center;
  width: 100%;
}

@media (max-width: 640px) {
  .dbub-launch {
    min-height: 44px;
    padding: 5px 14px 5px 5px;
    font-size: 13px;
  }

  .dbub-orb {
    width: 32px;
    height: 32px;
  }

  .dbub-logo {
    width: 26px;
    height: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dbub-orb {
    animation: none;
  }
}

/* ---------------- missed-call cost ---------------- */

.cs {
  --cs-heat: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.cs-result {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
}

/* A glow that grows with the loss: decoration only, aria-hidden by being a pseudo-element. */
.cs-result::before {
  content: "";
  position: absolute;
  inset: auto -20% -60% -20%;
  height: 120%;
  background: radial-gradient(closest-side, rgba(255, 61, 154, 0.35), rgba(124, 92, 255, 0.2) 55%, transparent);
  opacity: calc(0.25 + var(--cs-heat) * 0.75);
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cs-result > * {
  position: relative;
}

.cs-logo {
  width: 132px;
  height: auto;
  margin-bottom: 8px;
}

.cs-label {
  margin: 0;
  color: var(--txt-2);
  font-size: 14px;
}

.cs-loss {
  margin: 0;
  font: 700 clamp(34px, 5vw, 54px)/1.1 var(--font-d);
  letter-spacing: -0.02em;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  overflow-wrap: anywhere;
}

.cs-lost {
  margin: 0;
  font-size: 15px;
}

.cs-lost b {
  font-family: var(--font-m);
}

.cs-summary {
  margin: 0;
  color: var(--txt-2);
  font-size: 14px;
}

.cs-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.cs-inputs {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
}

.cs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.cs-row label {
  font-weight: 600;
  font-size: 14.5px;
}

.cs-tag {
  flex: none;
  padding: 2px 9px;
  border: 1px dashed var(--gold);
  border-radius: 999px;
  color: var(--warn-ink);
  font-size: 11.5px;
  white-space: nowrap;
}

.cs-tag.is-yours {
  border-style: solid;
  border-color: var(--mint);
  color: var(--ok-ink);
}

.cs-ctl {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cs-ctl input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--violet);
}

.cs-ctl output {
  min-width: 56px;
  font-family: var(--font-m);
  text-align: end;
}

.cs-money input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt);
  font: 500 16px var(--font-m);
}

.cs-money input:focus-visible,
.cs-ctl input[type="range"]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.cs-note,
.cs-formula {
  margin: 0;
  color: var(--txt-2);
  font-size: 12.5px;
  line-height: 1.55;
}

.cs-inputs .btn-mini {
  align-self: flex-start;
}

@media (max-width: 860px) {
  .cs {
    grid-template-columns: minmax(0, 1fr);
  }

  .cs-result,
  .cs-inputs {
    padding: 20px;
  }
}
