/* The AI assistant orb whose eyes change expression: the assistant panel of a calendar app on a near black page.
   The orb is a WebGL canvas a little bigger than the orb itself (so the halo can spill), the eyes are an SVG on top,
   both inside .orb__body, which is the one element GSAP squashes and lifts. Without WebGL a CSS gradient takes the
   canvas' place. */
:root {
  --page: #09090b;          /* the page */
  --panel: #111114;         /* the body of the panel */
  --edge: rgba(255, 255, 255, 0.075); /* its edge at rest */
  --ink: #efedf0;           /* the words */
  --muted: #8b8893;         /* the small words */
  --accent: #ff8a5c;        /* the warm light of the orb */
  --accent-2: #a98bff;      /* the cool light of the orb */
  --eye: #fff8f2;           /* the eyes */
  --ok: #8be3b8;            /* the check of the chip */
  --orb: clamp(84px, min(36vw, 25vh), 150px); /* the size of the orb */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(60vmax 40vmax at 20% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(60vmax 40vmax at 90% 100%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a little grain on the whole page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px 16px;
  overflow: hidden;
}

.panel {
  position: relative;
  width: min(100%, 360px);
  padding: clamp(12px, 3.6vh, 18px) clamp(14px, 4.6vw, 20px);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 40%),
    var(--panel);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 24px -12px rgba(0, 0, 0, 0.7),
    0 40px 80px -40px rgba(0, 0, 0, 0.9);
  display: grid;
  gap: clamp(6px, 2vh, 12px);
  opacity: 0;
}

/* the edge catches the light of the orb from above */
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(70% 50% at 50% 0%, color-mix(in srgb, var(--accent) calc(var(--rim, 0.4) * 60%), transparent), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.who {
  display: grid;
  gap: 1px;
}

.who__name {
  font-size: 14px;
  font-weight: 620;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
}

.who__sub {
  font-size: 11px;
  color: var(--muted);
}

/* the state: one word in a pill, the words roll on a track */
.state {
  position: relative;
  height: 24px;
  width: var(--pill-w, 78px);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  font-size: 11px;
  font-weight: 540;
  letter-spacing: 0.01em;
  color: #d9d5de;
  transition: width 0.45s cubic-bezier(0.34, 1.4, 0.5, 1);
}

.state__track {
  display: grid;
}

.state__word {
  width: max-content;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 11px;
  white-space: nowrap;
}

/* thinking shimmers */
.state__word[data-word='think'] {
  background: linear-gradient(90deg, #8b8893 0%, #ffffff 45%, #8b8893 60%) 0 0 / 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -100% 0; }
}

/* the orb */
.orb {
  position: relative;
  justify-self: center;
  width: var(--orb);
  height: var(--orb);
  margin-top: clamp(0px, 1vh, 6px);
  z-index: 1;
}

.orb__body {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.orb__canvas {
  position: absolute;
  left: -40%;
  top: -40%;
  width: 180%;
  height: 180%;
  pointer-events: none;
}

.orb__fallback {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: none;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.75), transparent 22%),
    radial-gradient(circle at 40% 40%, var(--accent), var(--accent-2) 75%);
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 -10px 30px rgba(0, 0, 0, 0.25);
}

.no-gl .orb__fallback {
  display: block;
}

.orb__eyes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(40, 12, 60, 0.45)) drop-shadow(0 0 4px rgba(255, 246, 236, 0.7)) drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 55%, transparent));
}

.eye {
  fill: var(--eye);
  stroke: var(--eye);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

/* the soft shadow the orb casts on the panel, under it */
.orb__shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -9%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, rgba(0, 0, 0, 0.6)), transparent);
  filter: blur(4px);
  opacity: 0.7;
  pointer-events: none;
  z-index: -1;
}

/* the conversation */
.thread {
  position: relative;
  z-index: 2;
  height: clamp(118px, 31vh, 132px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.ask {
  margin: 0;
  align-self: flex-end;
  max-width: 88%;
  min-height: 27px;
  padding: 4px 11px;
  border-radius: 14px 14px 4px 14px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #cfcbd4;
  opacity: 0;
}

.answer {
  margin: 0;
  min-height: 1.45em;
  color: var(--ink);
  text-wrap: pretty;
}

.caret {
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 540;
  color: #d9f5e7;
  background: color-mix(in srgb, var(--ok) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 26%, transparent);
  opacity: 0;
}

.chip__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the bar at the bottom: hint, voice wave, mic */
.bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 4px 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.bar__hint {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wave {
  width: 66px;
  height: 18px;
  flex: none;
  overflow: visible;
}

.wave rect {
  fill: var(--accent);
}

.mic {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}

.mic__face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #e9e6ee);
  color: #121216;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 4px 12px -4px color-mix(in srgb, var(--accent) 70%, transparent);
}

.mic svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.mic:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

@media (hover: hover) {
  .orb {
    cursor: pointer;
  }
  .mic:hover .mic__face {
    background: linear-gradient(180deg, #ffffff, #f4f1f7);
  }
}

@media (prefers-reduced-motion: reduce) {
  .state__word[data-word='think'] {
    animation: none;
    color: #e6e2ea;
    background: none;
  }
  .state {
    transition: none;
  }
}
