/* Charlie Light: the minimalist landing page. Palette, type and the orb are
 * the ones the full Charlie site uses (static/brand-system.css and
 * static/style.css in the Voice Agent repo), so the two read as one product.
 */
:root {
  --blue: #250E62;
  --purple: #7734AC;
  --pink: #E31E79;
  --lilac: #E2D6F6;
  --paper: #FBFAFD;
  --muted-on-dark: #c8c3d8;
  --font-head: "Aptos Display", "Aptos", Arial, Helvetica, sans-serif;
  --font: Arial, Helvetica, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100svh;
  color: #fff;
  background:
    radial-gradient(70% 55% at 50% 0%, color-mix(in srgb, var(--purple) 45%, transparent), transparent 70%),
    radial-gradient(60% 45% at 50% 100%, color-mix(in srgb, var(--pink) 14%, transparent), transparent 70%),
    var(--blue);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page {
  min-height: 100svh;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(32px, 7vh, 72px) 16px clamp(24px, 4vh, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 3.5vh, 36px);
  text-align: center;
}

/* ---- Introduction ------------------------------------------------------ */

.kicker {
  margin: 0;
  color: var(--muted-on-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 18px 0 0;
  color: #fff;
  font-family: var(--font-head);
  font-size: clamp(48px, 9vw, 100px);
  font-weight: 780;
  line-height: 0.92;
  letter-spacing: -0.065em;
}

/* ---- Stage: the orb until Charlie's face arrives ----------------------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.frame {
  position: relative;
  width: min(84vw, 460px, calc((100svh - 300px) * 0.8));
  min-width: 220px;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  isolation: isolate;
  border-radius: 30px;
  background:
    linear-gradient(rgba(37, 14, 98, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 14, 98, 0.045) 1px, transparent 1px),
    radial-gradient(118% 78% at 50% 26%, #fff 0%, rgba(255, 255, 255, 0.72) 34%, rgba(255, 255, 255, 0) 68%),
    linear-gradient(180deg, #f4f2f8 0%, #ebe8f1 54%, #e2dded 86%, #d8d2e6 100%);
  background-size: 34px 34px, 34px 34px, auto, auto;
  box-shadow:
    0 50px 90px -40px rgba(10, 4, 30, 0.75),
    0 18px 36px -24px rgba(10, 4, 30, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: width 0.45s ease, box-shadow 0.4s ease, transform 0.3s ease;
}

/* The card is the only control on the page, so it answers a hover. */
.frame:has(.placeholder:hover:not(:disabled)) {
  transform: translateY(-4px);
  box-shadow:
    0 58px 96px -40px rgba(10, 4, 30, 0.8),
    0 22px 40px -24px rgba(10, 4, 30, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.frame video {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.frame[data-video="on"] video {
  opacity: 1;
}

/* Speaking: a soft pink glow that breathes, as on the full Charlie site. */
.frame[data-speaking="true"] {
  animation: speaking-glow 2.4s ease-in-out infinite;
}

@keyframes speaking-glow {
  0%, 100% {
    box-shadow:
      0 50px 90px -40px rgba(10, 4, 30, 0.75),
      0 0 0 3px rgba(227, 30, 121, 0.55),
      0 0 34px 2px rgba(227, 30, 121, 0.22);
  }
  50% {
    box-shadow:
      0 50px 90px -40px rgba(10, 4, 30, 0.75),
      0 0 0 3px rgba(227, 30, 121, 0.75),
      0 0 56px 8px rgba(227, 30, 121, 0.34);
  }
}

/* The fade behind the badge, so it reads on any frame Anam sends. */
.frame::after {
  content: "";
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 28%;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(18, 8, 48, 0.68), rgba(18, 8, 48, 0));
  transition: opacity 0.5s ease;
}

.frame[data-video="on"]::after {
  opacity: 1;
}

.badge {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: 16px;
  display: flex;
  justify-content: flex-end;
  color: #fff;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.4s ease 0.15s, transform 0.4s ease 0.15s;
}

.frame[data-video="on"] .badge {
  opacity: 1;
  transform: none;
}

.badge-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.25s ease;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}

.frame[data-muted="true"] .badge-dot {
  background: #f5c542;
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.25);
}

.badge-bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.badge-bars i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: bottom;
  animation: badge-bar 0.9s ease-in-out infinite;
}

.badge-bars i:nth-child(2) { animation-delay: -0.3s; }
.badge-bars i:nth-child(3) { animation-delay: -0.6s; }
.badge-bars i:nth-child(4) { animation-delay: -0.15s; }

@keyframes badge-bar {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

.badge-label { display: none; }
.frame[data-muted="false"]:not([data-speaking="true"]) .badge-label--live { display: inline; }
.frame[data-muted="true"]:not([data-speaking="true"]) .badge-label--muted { display: inline; }
.frame[data-speaking="true"] .badge-label--speaking { display: inline; }
.frame[data-speaking="true"] .badge-state { background: rgba(227, 30, 121, 0.85); }
.frame[data-speaking="true"] .badge-dot { display: none; }
.frame[data-speaking="true"] .badge-bars { display: inline-flex; }

.placeholder {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--blue);
  border: 0;
  border-radius: inherit;
  background: none;
  cursor: pointer;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.placeholder:disabled {
  cursor: wait;
}

.placeholder:hover:not(:disabled) .mark {
  transform: scale(1.04);
}

.placeholder:focus-visible {
  outline-offset: -8px;
}

.frame[data-video="on"] .placeholder {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.placeholder strong {
  font-family: var(--font-head);
  font-size: 27px;
  line-height: 1.1;
}

/* The card is the only control, so it says what it does. */
.hint {
  margin-top: 10px;
  color: color-mix(in srgb, var(--blue) 58%, white);
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}

.placeholder:disabled .hint {
  opacity: 0;
}

@media (hover: none) {
  .hint-key {
    display: none;
  }
}

.mark {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 28px;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  transition: transform 0.25s ease;
  background: radial-gradient(circle at 38% 30%, rgba(119, 52, 172, 0.75), transparent 42%), var(--blue);
  box-shadow:
    0 24px 55px rgba(37, 14, 98, 0.34),
    0 0 48px rgba(227, 30, 121, 0.15),
    inset 0 0 30px rgba(255, 255, 255, 0.08);
}

.mark::before,
.mark::after {
  content: "";
  position: absolute;
  z-index: 0;
  width: 150%;
  height: 150%;
  border-radius: 50%;
  filter: blur(18px);
  pointer-events: none;
}

.mark::before {
  top: -45%;
  left: -55%;
  background: radial-gradient(circle, var(--purple) 0%, rgba(119, 52, 172, 0.55) 32%, transparent 68%);
  opacity: 0.9;
  animation: orb-drift 9s ease-in-out infinite;
}

.mark::after {
  right: -60%;
  bottom: -50%;
  background: radial-gradient(circle, var(--pink) 0%, rgba(227, 30, 121, 0.45) 30%, transparent 66%);
  opacity: 0.75;
  animation: orb-drift-counter 11s ease-in-out infinite;
}

.frame[data-state="connecting"] .mark::before {
  animation-duration: 2.6s;
}

.frame[data-state="connecting"] .mark::after {
  animation-duration: 3.2s;
}

.frame[data-state="connecting"] .mark span {
  animation: orb-pulse 1.4s ease-in-out infinite;
}

.mark span {
  position: relative;
  z-index: 1;
  width: 70px;
  height: 84px;
  display: block;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.38));
}

.mark svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mark svg path {
  fill: #fff;
}

@keyframes orb-drift {
  50% { transform: translate(18%, 14%); }
}

@keyframes orb-drift-counter {
  50% { transform: translate(-16%, -12%); }
}

@keyframes orb-pulse {
  50% { opacity: 0.55; }
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted-on-dark);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ---- Controls ----------------------------------------------------------- */

.controls:not(:has(> :not([hidden]))) {
  display: none;
}

.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.live-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.live-controls[hidden] {
  display: none;
}

.round {
  width: 48px;
  min-width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.round[hidden] {
  display: none;
}

.round:hover {
  background: rgba(255, 255, 255, 0.18);
}

.mic .icon-off,
.mic[aria-pressed="true"] .icon-on {
  display: none;
}

.mic[aria-pressed="true"] .icon-off {
  display: block;
}

.mic[aria-pressed="true"] {
  color: var(--blue);
  background: #fff;
}

.end {
  border-color: transparent;
  background: var(--pink);
}

.end:hover {
  background: #c4155f;
}

.notice {
  max-width: 460px;
  margin: 0;
  padding: 10px 16px;
  color: #fff;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  line-height: 1.45;
}

.notice[hidden] {
  display: none;
}

button:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

/* ---- Live: the face takes the room the introduction used --------------- */

.page[data-state="live"] .intro {
  display: none;
}

.page[data-state="live"] .frame {
  width: min(92vw, 640px, calc((100svh - 230px) * 0.8));
}

@media (max-width: 480px) {
  .page {
    justify-content: flex-start;
  }

  .intro h1 {
    margin: 14px 0 0;
  }

  .frame {
    width: min(84vw, 340px, calc((100svh - 280px) * 0.8));
  }

  .page[data-state="live"] {
    justify-content: center;
  }

  .round {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mark::before,
  .mark::after,
  .mark span,
  .badge-bars i {
    animation: none !important;
  }

  .frame[data-speaking="true"] {
    animation: none;
    box-shadow:
      0 50px 90px -40px rgba(10, 4, 30, 0.75),
      0 0 0 3px rgba(227, 30, 121, 0.65),
      0 0 40px 4px rgba(227, 30, 121, 0.28);
  }

  .frame,
  .frame::after,
  .frame video,
  .placeholder,
  .badge,
  .mark {
    transition: none;
  }
}
