/* ============================================================
   StockCall — Siri-style voice call widget
   Self-contained. No framework. Shadow-DOM-safe class prefixes.
   ============================================================ */

.sc-root {
  --sc-a: #6ee7ff;   /* cyan   */
  --sc-b: #7c5cff;   /* violet */
  --sc-c: #ff5cf0;   /* magenta*/
  --sc-d: #4ade80;   /* green  */
  --sc-bg: #0b0f1a;
  --sc-panel: rgba(16, 20, 34, .82);
  --sc-text: #eef2ff;
  --sc-muted: #8a94b3;
  --sc-radius: 26px;
  position: fixed;
  /* A phone with a home indicator or a curved corner will happily put its own
     furniture on top of a fixed element. The insets are zero everywhere else,
     so this costs nothing on a desktop. */
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sc-root.sc-left { right: auto; left: calc(24px + env(safe-area-inset-left)); }

/* ---------------------------- launcher button ---------------------------- */

.sc-launcher {
  position: relative;
  width: 68px; height: 68px;
  border: 0; padding: 0; cursor: pointer;
  border-radius: 50%;
  background: transparent;
  display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.2,.9,.3,1.4);
}
.sc-launcher:hover { transform: scale(1.06); }
.sc-launcher:active { transform: scale(.94); }
.sc-launcher:focus-visible { outline: 3px solid var(--sc-a); outline-offset: 6px; border-radius: 50%; }

.sc-orb {
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, var(--sc-a), transparent 60%),
    radial-gradient(circle at 70% 35%, var(--sc-c), transparent 60%),
    radial-gradient(circle at 50% 75%, var(--sc-b), transparent 65%),
    linear-gradient(135deg, var(--sc-b), var(--sc-a));
  box-shadow: 0 10px 34px -6px rgba(124, 92, 255, .65), 0 0 0 1px rgba(255,255,255,.12) inset;
  animation: sc-breathe 3.6s ease-in-out infinite, sc-hue 12s linear infinite;
}
@keyframes sc-breathe {
  0%,100% { transform: scale(1); filter: saturate(1); }
  50%     { transform: scale(1.06); filter: saturate(1.25); }
}
@keyframes sc-hue { to { filter: hue-rotate(360deg); } }

/* emanating rings */
.sc-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(124, 92, 255, .55);
  animation: sc-pulse 2.8s cubic-bezier(.2,.7,.3,1) infinite;
}
.sc-ring:nth-child(2) { animation-delay: .9s; border-color: rgba(110, 231, 255, .5); }
.sc-ring:nth-child(3) { animation-delay: 1.8s; border-color: rgba(255, 92, 240, .4); }
@keyframes sc-pulse {
  0%   { transform: scale(1); opacity: .85; }
  100% { transform: scale(2.15); opacity: 0; }
}

.sc-phone { position: relative; width: 28px; height: 28px; color: #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.sc-launcher .sc-phone { animation: sc-shake 3.6s ease-in-out infinite; }
@keyframes sc-shake {
  0%, 72%, 100% { transform: rotate(0); }
  76% { transform: rotate(-14deg); } 80% { transform: rotate(12deg); }
  84% { transform: rotate(-9deg); }  88% { transform: rotate(7deg); }  92% { transform: rotate(0); }
}

.sc-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--sc-d); color: #05230f;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  padding: 3px 7px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  animation: sc-blink 2s ease-in-out infinite;
}
@keyframes sc-blink { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

.sc-tip {
  position: absolute; right: 84px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: rgba(11,15,26,.92); color: var(--sc-text);
  padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 26px -8px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) inset;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.sc-root.sc-left .sc-tip { right: auto; left: 84px; }
.sc-launcher:hover + .sc-tip, .sc-tip.sc-show { opacity: 1; }

/* -------------------------------- panel ---------------------------------- */

.sc-panel {
  position: absolute; right: 0; bottom: 0;
  width: 340px; height: 560px;
  border-radius: var(--sc-radius);
  background: var(--sc-panel);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.1) inset;
  color: var(--sc-text);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(.92); opacity: 0; pointer-events: none;
  transform-origin: bottom right;
  transition: transform .34s cubic-bezier(.2,.9,.3,1.2), opacity .24s;
}
.sc-root.sc-left .sc-panel { right: auto; left: 0; transform-origin: bottom left; }
.sc-panel.sc-open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

/* the launcher gets out of the way while the panel is up */
.sc-root.sc-panel-open .sc-launcher,
.sc-root.sc-panel-open .sc-tip { opacity: 0; pointer-events: none; transform: scale(.6); transition: opacity .2s, transform .2s; }

.sc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px;
}
.sc-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sc-b), var(--sc-a));
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.18) inset;
}
.sc-who { flex: 1; min-width: 0; }
.sc-name {
  font-size: 14px; font-weight: 650; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sc-sub {
  font-size: 11.5px; color: var(--sc-muted); display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden;
}
.sc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sc-muted); }
.sc-dot.sc-live { background: var(--sc-d); box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: sc-live 1.8s infinite; }
@keyframes sc-live {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,.6) }
  70% { box-shadow: 0 0 0 8px rgba(74,222,128,0) }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0) }
}
.sc-timer { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--sc-muted); }
.sc-x {
  background: rgba(255,255,255,.07); border: 0; color: var(--sc-text);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1;
}
.sc-x:hover { background: rgba(255,255,255,.15); }

/* visualiser stage */
.sc-stage { position: relative; height: 194px; display: grid; place-items: center; flex: none; }
.sc-canvas { width: 100%; height: 100%; display: block; }
.sc-state {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center;
  font-size: 11.5px; letter-spacing: 1.2px; color: var(--sc-muted);
  text-transform: uppercase; font-weight: 700;
  padding: 14px 0 7px;
  background: linear-gradient(to top, rgba(16,20,34,.75), rgba(16,20,34,.35) 55%, rgba(16,20,34,0));
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}

/* captions / transcript */
.sc-log {
  flex: 1; overflow-y: auto; padding: 10px 16px 8px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sc-log::-webkit-scrollbar { width: 5px; }
.sc-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.sc-bubble {
  max-width: 88%; padding: 9px 13px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.45; word-wrap: break-word;
  animation: sc-in .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes sc-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.sc-bubble.sc-agent { align-self: flex-start; background: rgba(124,92,255,.22); border: 1px solid rgba(124,92,255,.3); border-bottom-left-radius: 5px; }
.sc-bubble.sc-user { align-self: flex-end; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12); border-bottom-right-radius: 5px; }
.sc-bubble.sc-sys { align-self: center; background: transparent; color: var(--sc-muted); font-size: 11.5px; text-align: center; }

/* controls */
.sc-controls {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 16px 18px;
}
.sc-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--sc-text);
  background: rgba(255,255,255,.09);
  transition: transform .15s, background .15s;
}
.sc-btn:hover { background: rgba(255,255,255,.17); }
.sc-btn:active { transform: scale(.9); }
.sc-btn.sc-on { background: rgba(255,92,92,.25); color: #ff9d9d; }
.sc-btn svg { width: 20px; height: 20px; }

.sc-call {
  width: 62px; height: 62px;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  box-shadow: 0 8px 26px -6px rgba(34,197,94,.7);
}
.sc-call:hover { background: linear-gradient(135deg, #16a34a, #22c55e); }
.sc-call.sc-hang {
  background: linear-gradient(135deg, #ef4444, #f87171);
  box-shadow: 0 8px 26px -6px rgba(239,68,68,.7);
}
.sc-call.sc-hang svg { transform: rotate(135deg); }
.sc-call.sc-ringing { animation: sc-ringbtn .9s ease-in-out infinite; }
@keyframes sc-ringbtn { 0%,100% { transform: scale(1) } 50% { transform: scale(1.09) } }

.sc-typebar { display: flex; gap: 8px; padding: 0 16px 14px; }
.sc-typebar input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: var(--sc-text); border-radius: 999px; padding: 11px 14px; outline: none;
  /* 16px is not a style choice. Safari on iOS zooms the entire page when a
     focused input is smaller than this, and the farmer is then left pinching
     his way back out mid-call. */
  font-size: 16px;
}
.sc-typebar input:focus-visible { border-color: var(--sc-a); }
.sc-typebar input::placeholder { color: var(--sc-muted); }
.sc-typebar button {
  background: rgba(124,92,255,.35); border: 0; color: #fff; border-radius: 999px;
  padding: 0 18px; min-height: 44px; cursor: pointer; font-size: 15px; font-weight: 600;
  flex: 0 0 auto;
}
.sc-typebar button:active { transform: scale(.96); }

.sc-foot { text-align: center; font-size: 10.5px; color: var(--sc-muted); padding-bottom: 10px; }

/* ========================= EVERY OTHER DEVICE =============================
   The call has to work on a five-year-old Android held sideways in a field,
   on a tablet at the counter, and on a laptop in the office. Everything below
   is about the panel staying usable rather than looking clever.
   ========================================================================= */

/* phones */
@media (max-width: 480px) {
  .sc-root {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .sc-root.sc-left { left: calc(12px + env(safe-area-inset-left)); }
  .sc-panel {
    width: calc(100vw - 24px);
    /* dvh, not vh. On mobile Chrome the address bar is part of vh, so a panel
       sized in vh is taller than the screen and the hang-up button sits below
       the fold — exactly where you need it in a hurry. */
    height: min(78vh, 620px);
    height: min(78dvh, 620px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  }
  .sc-tip { display: none; }
  .sc-head { padding: 14px 16px 10px; }
  .sc-controls { padding: 10px 14px 16px; gap: 14px; }
}

/* narrow phones — 320px is still out there in rural UP */
@media (max-width: 360px) {
  .sc-panel { width: calc(100vw - 16px); }
  .sc-root { right: 8px; bottom: 8px; }
  .sc-call { width: 56px; height: 56px; }
  .sc-btn { width: 44px; height: 44px; }
  .sc-name { font-size: 13px; }
}

/* a phone held sideways: almost no height, plenty of width */
@media (max-height: 480px) and (orientation: landscape) {
  /* The panel is positioned FROM the root, so its own height has to leave room
     for the root's offset too — otherwise the top of the card is off screen
     and the caller cannot see who he is talking to. */
  .sc-root {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .sc-root.sc-left { left: calc(8px + env(safe-area-inset-left)); }
  .sc-panel {
    height: calc(100dvh - 16px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
    max-height: calc(100dvh - 16px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
    width: min(460px, calc(100vw - 24px));
  }
  .sc-stage { min-height: 0; }
  .sc-canvas { max-height: 84px; }
  .sc-log { max-height: 30dvh; }
  .sc-controls { padding: 8px 14px 10px; }
  .sc-foot { display: none; }
  .sc-root.sc-fullscreen .sc-canvas { max-height: 40dvh; }
  .sc-root.sc-fullscreen .sc-log { max-height: 28dvh; }
}

/* tablets and up: a bigger card, not a stretched phone one */
@media (min-width: 700px) {
  .sc-panel { width: 380px; height: 600px; }
}

/* a real pointer gets hover; a finger should never get a sticky hover state */
@media (hover: none) {
  .sc-launcher:hover { transform: none; }
  .sc-btn:hover { background: rgba(255,255,255,.09); }
  .sc-launcher:hover + .sc-tip { opacity: 0; }
}

/* Touch targets. Anything you press during a call is at least 44px, which is
   the smallest a thumb reliably hits — and the farmer may be wearing gloves
   or standing in the sun. */
.sc-btn, .sc-call, .sc-x, .sc-typebar button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sc-btn { min-width: 44px; min-height: 44px; }

/* Keyboard users, and anyone on a TV or kiosk with a remote. */
.sc-btn:focus-visible, .sc-call:focus-visible, .sc-x:focus-visible,
.sc-typebar button:focus-visible, .sc-unblock:focus-visible {
  outline: 3px solid var(--sc-a);
  outline-offset: 3px;
}

/* Scrolling the transcript must not drag the page behind it. */
.sc-log {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* The page behind a full-screen call should not scroll or rubber-band. */
html.sc-locked, body.sc-locked {
  overflow: hidden;
  overscroll-behavior: none;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .sc-orb, .sc-ring, .sc-phone, .sc-badge, .sc-call.sc-ringing { animation: none !important; }
  .sc-panel { transition: opacity .01s; }
  * { scroll-behavior: auto !important; }
}

/* Someone who has asked their system for more contrast is usually reading in
   sunlight, which is most of this audience. */
@media (prefers-contrast: more) {
  .sc-root {
    --sc-panel: rgba(8, 11, 20, .97);
    --sc-muted: #b8c0d8;
  }
  .sc-panel { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .sc-bubble { border: 1px solid rgba(255,255,255,.28); }
}

/* Printing a call log should not print a dark rectangle. */
@media print { .sc-root { display: none !important; } }

/* Shown only when the browser refuses to play sound without another tap. */
.sc-unblock {
  margin: 0 16px 8px; padding: 10px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255,186,73,.55); background: rgba(255,186,73,.18);
  color: var(--sc-text); font: 600 13px inherit; text-align: center;
}
.sc-unblock:hover { background: rgba(255,186,73,.28); }

/* =========================== FULL-SCREEN MODE =============================
   For a page whose whole job is the call — a kiosk at the counter, a phone
   held up to a farmer, or a landing page with nothing else on it. The panel
   stops being a floating card and becomes the page.
   ========================================================================= */
.sc-root.sc-fullscreen {
  position: fixed; inset: 0;
  right: 0; bottom: 0; left: 0; top: 0;
  display: block;
}
.sc-root.sc-fullscreen .sc-launcher,
.sc-root.sc-fullscreen .sc-tip { display: none; }

.sc-root.sc-fullscreen .sc-panel {
  position: fixed; inset: 0;
  width: 100%; height: 100%; height: 100dvh;
  max-width: none; max-height: none;
  border-radius: 0;
  transform: none; opacity: 1; pointer-events: auto;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  background: var(--sc-bg, #0b0f1a);
  box-shadow: none;
  /* the notch and the home bar */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Room to breathe: on a big screen the orb should not be lost in the middle
   of a 2000-pixel-wide wash of empty colour. */
.sc-root.sc-fullscreen .sc-head { padding: 20px 24px 14px; }
.sc-root.sc-fullscreen .sc-stage { flex: 1 1 auto; min-height: 0; }
.sc-root.sc-fullscreen .sc-log,
.sc-root.sc-fullscreen .sc-foot,
.sc-root.sc-fullscreen .sc-head,
.sc-root.sc-fullscreen .sc-typebar { max-width: 640px; margin-left: auto; margin-right: auto; width: 100%; }
.sc-root.sc-fullscreen .sc-orb { transform: scale(1.15); }

/* The state label sits UNDER the orb here, not over it — at this size the glow
   swallows anything laid on top of it. */
.sc-root.sc-fullscreen .sc-state {
  position: static;
  background: none;
  font-size: 13px; letter-spacing: 1.6px;
  color: var(--sc-text); opacity: .72;
  padding: 0 0 26px;
}
.sc-root.sc-fullscreen .sc-stage {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px;
}
.sc-root.sc-fullscreen .sc-canvas { flex: 1 1 auto; min-height: 0; }

/* Nothing to close back to when the call IS the page. */
.sc-root.sc-fullscreen .sc-x { display: none; }

/* The transcript should not shove the orb off-screen on a laptop. */
/* Before the call starts there is nothing to show — give that space to the orb
   instead of leaving a hole between the label and the controls. */
.sc-root.sc-fullscreen .sc-log { max-height: 34vh; flex: 0 1 auto; }
.sc-root.sc-fullscreen .sc-log:empty { display: none; }

@media (min-width: 900px) {
  .sc-root.sc-fullscreen .sc-orb { transform: scale(1.35); }
}
@media (max-height: 560px) {
  .sc-root.sc-fullscreen .sc-orb { transform: scale(.9); }
}
