/* ============================================================
   GRID+CLUB, the Race Control chat bar (scripts/rcchat.js)

   Volt is ours (focus, the send button). WhatsApp green is only on
   WhatsApp things: the mark, the outgoing bubble and the hand-off
   pill, in WhatsApp's own dark theme colours so it sits on the
   #0a0a0a ground. The orb is where the two meet.
   ============================================================ */

.rcc {
  --wa: #25d366;
  --wa-out: #005c4b;
  --wa-in: #1f2c33;
  --wa-ink: #e9edef;
  --wa-meta: rgba(233, 237, 239, 0.6);
  --wa-read: #53bdeb;
  --rcc-glass: rgba(244, 244, 237, 0.045);
  --rcc-edge: rgba(244, 244, 237, 0.13);
  display: grid;
  gap: 0.85rem;
  margin-top: 1.6rem;
  max-width: 34rem;
}

/* ---------- head: the mark ---------- */
.rcc__head { display: flex; align-items: center; gap: 0.8rem; }
.rcc__badge {
  position: relative;
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.1);
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.28);
}
.rcc__mark { width: 1.75rem; height: 1.75rem; overflow: visible; }
.rcc__ring { fill: none; stroke: var(--wa); stroke-width: 2.2; stroke-linejoin: round; }
.rcc__handset { fill: var(--wa); stroke: var(--wa); transform-box: fill-box; transform-origin: center; }
.rcc__handset rect { stroke: none; }
.rcc__who { display: grid; gap: 0.15rem; line-height: 1.1; }
.rcc__who strong { font-family: var(--display-face, var(--font-display)); font-weight: 700; text-transform: uppercase; font-size: 1.05rem; color: var(--ink); }
.rcc__who .mono { color: var(--wa); }

/* ---------- thread ---------- */
.rcc__thread {
  position: relative;
  display: flex; flex-direction: column; gap: 0.4rem;
  min-height: 2.9rem;
}
.rcc__msg {
  position: relative;
  max-width: 85%;
  padding: 0.45rem 0.6rem 0.4rem 0.7rem;
  border-radius: 0.6rem;
  font: 400 0.9rem/1.35 var(--font-body);
  color: var(--wa-ink);
  display: flex; flex-wrap: wrap; align-items: flex-end; column-gap: 0.6rem;
  overflow-wrap: anywhere;
}
.rcc__msg--in  { align-self: flex-start; background: var(--wa-in); border-top-left-radius: 0.15rem; }
.rcc__msg--out { align-self: flex-end;   background: var(--wa-out); border-top-right-radius: 0.15rem; }
.rcc__txt { white-space: pre-wrap; }
.rcc__meta {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 0.2rem;
  font: 400 0.68rem/1 var(--font-body);
  color: var(--wa-meta);
  transform: translateY(0.1rem);
}
.rcc__ticks { width: 1.05rem; height: 0.65rem; color: var(--wa-meta); transition: color var(--d2, 240ms); }
.rcc__msg.is-read .rcc__ticks { color: var(--wa-read); }

.rcc__typing {
  position: absolute; left: 0; top: 0;
  display: none; gap: 0.25rem; align-items: center;
  padding: 0.75rem 0.8rem; border-radius: 0.6rem; border-top-left-radius: 0.15rem;
  background: var(--wa-in);
}
.rcc__typing i { width: 0.38rem; height: 0.38rem; border-radius: 50%; background: var(--wa-meta); }

/* ---------- the bar ---------- */
.rcc__bar {
  display: flex; align-items: flex-end; gap: 0.65rem;
  padding: 0.3rem 0.3rem 0.3rem 0.35rem;
  border-radius: 1.6rem;
  background: var(--rcc-glass);
  border: 1px solid var(--rcc-edge);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  transition: border-color var(--d2, 240ms) var(--ease-out), box-shadow var(--d2, 240ms) var(--ease-out);
}
.rcc__bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}
.rcc__field { position: relative; flex: 1; min-width: 0; align-self: center; }
.rcc__field textarea {
  display: block; width: 100%;
  max-height: 8.5rem; overflow-y: auto;
  resize: none; border: 0; outline: 0; background: transparent;
  padding: 0.55rem 0; margin: 0;
  font: 400 1rem/1.4 var(--font-body);       /* 16px stops iOS zooming on focus */
  color: var(--ink);
  caret-color: var(--accent);
}
.rcc__ph {
  position: absolute; left: 0; right: 0; top: 0.55rem;
  height: 1.4em; overflow: hidden; pointer-events: none;
  font: 400 1rem/1.4 var(--font-body); color: var(--muted);
}
.rcc__ph > span { position: absolute; left: 0; top: 0; white-space: nowrap; }
.rcc__ph > .is-in  { animation: rcc-ph-in 520ms var(--ease-out) both; }
.rcc__ph > .is-out { animation: rcc-ph-out 520ms var(--ease-out) both; }
.rcc__field textarea:not(:placeholder-shown) + .rcc__ph { visibility: hidden; }

.rcc__send {
  flex: none;
  display: grid; place-items: center;
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 1px solid var(--rcc-edge);
  background: rgba(244, 244, 237, 0.06);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--d2, 240ms) var(--ease-out), color var(--d2, 240ms), transform var(--d1, 120ms), box-shadow var(--d2, 240ms);
}
.rcc__send svg { width: 1.15rem; height: 1.15rem; }
.rcc__send:disabled { cursor: default; opacity: 0.7; }
.rcc__send:not(:disabled) {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 22px -4px color-mix(in srgb, var(--accent) 55%, transparent);
}
.rcc__send:not(:disabled):hover { transform: translateX(2px); }
.rcc__send:not(:disabled):active { transform: scale(0.94); }
.rcc__send:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- chips ---------- */
.rcc__chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.rcc__chip {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--rcc-edge);
  background: transparent;
  color: var(--ink);
  font: 500 0.8rem/1.2 var(--font-body);
  cursor: pointer;
  transition: border-color var(--d2, 240ms), background var(--d2, 240ms), color var(--d2, 240ms);
}
.rcc__chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.rcc__chip:active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rcc__chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rcc__note { min-height: 1em; margin: 0; color: var(--muted); }
.rcc__note:empty { display: none; }

.rcc__sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- the orb ----------
   The 21st.dev "Siri Orb" (pure CSS), ported from React: six conic
   gradients turning on a registered --angle, blurred and pushed
   through contrast, under a dot screen. Size-dependent values come
   from orbVars() in rcchat.js as inline custom properties.
   Palette: volt for us, WhatsApp green for where it goes, a cool
   white teal to keep it reading as light rather than lime. The top
   layer (c3) dominates, so the accent goes there; volt or green on
   top swamped the other two (dev/rcchat.html has the tries). */
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.rcc-orb {
  --bg: #0a0a0a;
  --c1: #25d366;   /* WhatsApp, the bottom layers */
  --c2: var(--accent);   /* the world accent: volt here, pink on Girl+Grid */
  --c3: #7ff0e0;   /* white teal, the top layers, so it reads as light */
  --animation-duration: 20s;
  flex: none;
  display: grid;
  grid-template-areas: "stack";
  overflow: hidden;
  border-radius: 50%;
  position: relative;
  background: var(--bg);
  transition: transform 420ms var(--ease-out), filter 420ms var(--ease-out), box-shadow 420ms var(--ease-out);
}
.rcc-orb::before,
.rcc-orb::after {
  content: "";
  display: block;
  grid-area: stack;
  width: 100%; height: 100%;
  border-radius: 50%;
  transform: translateZ(0);
}
.rcc-orb::before {
  background:
    conic-gradient(from calc(var(--angle) * 2) at 25% 70%, var(--c3), transparent 20% 80%, var(--c3)),
    conic-gradient(from calc(var(--angle) * 2) at 45% 75%, var(--c2), transparent 30% 60%, var(--c2)),
    conic-gradient(from calc(var(--angle) * -3) at 80% 20%, var(--c1), transparent 40% 60%, var(--c1)),
    conic-gradient(from calc(var(--angle) * 2) at 15% 5%, var(--c2), transparent 10% 90%, var(--c2)),
    conic-gradient(from calc(var(--angle) * 1) at 20% 80%, var(--c1), transparent 10% 90%, var(--c1)),
    conic-gradient(from calc(var(--angle) * -2) at 85% 10%, var(--c3), transparent 20% 80%, var(--c3));
  box-shadow: inset var(--bg) 0 0 var(--shadow-spread) calc(var(--shadow-spread) * 0.2);
  filter: blur(var(--blur-amount)) contrast(var(--contrast-amount));
  animation: rcc-orb-spin var(--animation-duration) linear infinite;
}
.rcc-orb::after {
  background-image: radial-gradient(circle at center, var(--bg) var(--dot-size), transparent var(--dot-size));
  background-size: calc(var(--dot-size) * 2) calc(var(--dot-size) * 2);
  -webkit-backdrop-filter: blur(calc(var(--blur-amount) * 2)) contrast(calc(var(--contrast-amount) * 2));
  backdrop-filter: blur(calc(var(--blur-amount) * 2)) contrast(calc(var(--contrast-amount) * 2));
  mix-blend-mode: overlay;
  -webkit-mask-image: radial-gradient(black var(--mask-radius), transparent 75%);
  mask-image: radial-gradient(black var(--mask-radius), transparent 75%);
}
.rcc-orb--bar { margin-bottom: 1px; }

/* States. Idle is the slow default above. */
.rcc[data-typing]:not([data-orb]) .rcc-orb {           /* listening */
  --animation-duration: 6s;
  transform: scale(1.08);
  filter: brightness(1.2) saturate(1.25);
  box-shadow: 0 0 18px -3px color-mix(in srgb, var(--accent) 45%, transparent);
}
.rcc[data-orb="thinking"] .rcc-orb {
  --animation-duration: 2.4s;
  filter: brightness(1.3) saturate(1.3);
  box-shadow: 0 0 24px -3px color-mix(in srgb, var(--accent) 50%, transparent);
}
.rcc[data-orb="answered"] .rcc-orb {
  --animation-duration: 10s;
  box-shadow: 0 0 0 1.5px rgba(37, 211, 102, 0.55), 0 0 22px -4px rgba(37, 211, 102, 0.6);
}

/* ---------- the reply ---------- */
.rcc__reply { align-self: flex-start; display: flex; align-items: flex-end; gap: 0.6rem; max-width: 94%; }
.rcc__stack { display: grid; gap: 0.45rem; justify-items: start; min-width: 0; }
.rcc__reply .rcc__msg { max-width: 100%; }

.rcc__go {
  position: relative;
  overflow: hidden;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.85rem 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.14);
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.45);
  color: var(--wa-ink);
  font: 600 0.8rem/1 var(--font-body);
}
.rcc__go-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--wa); }
.rcc__go-n {
  min-width: 2.4ch;
  font: 500 0.75rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--wa);
}
.rcc__go-bar {
  position: absolute; left: 0; bottom: 0;
  width: 100%; height: 2px;
  background: var(--wa);
  transform-origin: left center;
  transform: scaleX(0);
}
.rcc__go.is-done .rcc__go-bar { transform: none; }

/* ============================================================
   Motion. Default state is the finished, static component, so
   reduced motion and hidden tabs need nothing. JS arms the intro
   (data-intro="armed") and an observer plays it.
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .rcc[data-intro="armed"] .rcc__ring { stroke-dasharray: 1; stroke-dashoffset: 1; }
  .rcc[data-intro="armed"] .rcc__handset { opacity: 0; }
  .rcc[data-intro="armed"] .rcc__thread > .rcc__msg--in { opacity: 0; }

  .rcc[data-intro="play"] .rcc__ring {
    stroke-dasharray: 1;
    animation: rcc-draw 1100ms var(--ease-io) both;
  }
  .rcc[data-intro="play"] .rcc__handset { animation: rcc-ring 700ms var(--ease-out) 850ms both; }
  .rcc[data-intro="play"] .rcc__typing { display: flex; animation: rcc-typing 1400ms linear 600ms both; }
  .rcc[data-intro="play"] .rcc__typing i { animation: rcc-dot 700ms ease-in-out 600ms 2 both; }
  .rcc[data-intro="play"] .rcc__typing i:nth-child(2) { animation-delay: 750ms; }
  .rcc[data-intro="play"] .rcc__typing i:nth-child(3) { animation-delay: 900ms; }
  .rcc[data-intro="play"] .rcc__thread > .rcc__msg--in { animation: rcc-pop 420ms var(--ease-out) 2000ms both; }

  .rcc__msg--out { animation: rcc-pop 360ms var(--ease-out) both; transform-origin: right bottom; }
  .rcc__reply .rcc__msg { animation: rcc-pop 300ms var(--ease-out) both; transform-origin: left bottom; }
  .rcc__go { animation: rcc-pop 320ms var(--ease-out) both; transform-origin: left center; }
  .rcc__go-bar { animation: rcc-fill var(--go-ms, 1200ms) linear both; }
  .rcc__go-dot { animation: rcc-blink 520ms ease-in-out infinite alternate; }
  .rcc[data-orb="thinking"] .rcc-orb { animation: rcc-orb-pulse 620ms ease-in-out infinite alternate; }
}

@media (prefers-reduced-motion: reduce) {
  .rcc-orb::before { animation: none; }
  .rcc-orb { transition: none; }
  .rcc[data-typing]:not([data-orb]) .rcc-orb { transform: none; }
}

@keyframes rcc-orb-spin { to { --angle: 360deg; } }
@keyframes rcc-orb-pulse {
  from { transform: scale(0.94); }
  to   { transform: scale(1.1); }
}
@keyframes rcc-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rcc-blink { from { opacity: 0.35; } to { opacity: 1; } }

@keyframes rcc-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes rcc-ring {
  0% { opacity: 0; transform: scale(0.4) rotate(-20deg); }
  55% { opacity: 1; transform: scale(1.08) rotate(8deg); }
  75% { transform: scale(1) rotate(-5deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes rcc-typing { 0%, 99% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@keyframes rcc-dot { 0%, 100% { opacity: 0.35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes rcc-pop { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes rcc-ph-in  { from { opacity: 0; transform: translateY(70%); } to { opacity: 1; transform: none; } }
@keyframes rcc-ph-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-70%); } }
