/* The Kairos glass orb on a light ground. orbloom's own component rules come first, unchanged. */
@import url("./orbloom/orb.css");

/* Two accent themes, neither blue nor purple. They colour the orb's interior and the UI around it. */
:root,
[data-orb-theme="amber"] {
  --orb-accent-1: #FF7A2F;
  --orb-accent-2: #FF4F5E;
  --orb-accent-3: #FFE0B5;
  --orb-accent-ui: #C2410C;
}

[data-orb-theme="teal"] {
  --orb-accent-1: #14B8A0;
  --orb-accent-2: #3DD68C;
  --orb-accent-3: #D6FFF0;
  --orb-accent-ui: #0F766E;
}

.korb {
  --orb-diameter: 240px;
  --korb-label-size: 15px;
  --korb-label-dim: #77716a;
  --korb-label-lit: #16130f;
  position: relative;
  display: inline-grid;
  justify-items: center;
  gap: calc(var(--orb-diameter) * 0.12);
}

.korb .orb-motion {
  /* orbloom sets its own default size on this element; take the host's instead. */
  --orb-diameter: inherit;
  --orb-motion-distance: calc(var(--orb-diameter) * -0.03);
  grid-area: 1 / 1;
}

.korb .orb-fallback {
  background:
    radial-gradient(circle at 31% 25%, rgb(255 255 255 / 0.9) 0 1.2%, rgb(255 255 255 / 0.22) 3.5%, transparent 9%),
    radial-gradient(ellipse 38% 26% at 58% 68%, color-mix(in oklab, var(--orb-accent-2) 38%, transparent), transparent 70%),
    radial-gradient(circle, #0f1011 0 64%, #232527 88%, color-mix(in oklab, var(--orb-accent-1) 35%, #232527) 100%);
}

/* orbloom's chrome is tuned for a dark ground; on white the edge needs a dark hairline to stay crisp. */
.korb .orb-chrome {
  opacity: 1;
  box-shadow:
    inset 0 0 0 1px rgba(22, 16, 10, 0.22),
    inset 0 1px 1px rgba(255, 255, 255, 0.55),
    inset 0 0 0 2px rgba(255, 255, 255, 0.1),
    inset 0 0 var(--orb-shell-blur) rgba(255, 255, 255, 0.14);
}

/* The light the orb throws on the ground, and its contact shadow. Both stay put while the orb floats. */
.korb-glow,
.korb-shadow {
  grid-area: 1 / 1;
  pointer-events: none;
}

.korb-glow {
  width: calc(var(--orb-diameter) * 1.5);
  height: calc(var(--orb-diameter) * 1.5);
  /* As wide as the glow, but taking only the orb's own space in the layout. */
  margin: calc(var(--orb-diameter) * -0.25);
  translate: 0 calc(var(--orb-diameter) * 0.08);
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--orb-accent-1) 30%, transparent), transparent);
  opacity: 0.45;
  transition: opacity 400ms ease, scale 400ms cubic-bezier(0.23, 1, 0.32, 1);
}

.korb[data-state="listening"] .korb-glow,
.korb[data-state="speaking"] .korb-glow {
  opacity: 0.75;
}

.korb[data-state="thinking"] .korb-glow,
.korb[data-state="tool"] .korb-glow {
  opacity: 0.9;
  scale: 1.06;
}

.korb-shadow {
  width: calc(var(--orb-diameter) * 0.72);
  height: calc(var(--orb-diameter) * 0.12);
  align-self: end;
  translate: 0 calc(var(--orb-diameter) * 0.1);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(28, 20, 12, 0.3), transparent);
  filter: blur(calc(var(--orb-diameter) * 0.02));
}

.korb-label {
  margin: 0;
  min-height: 1.3em;
  font-size: var(--korb-label-size);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--korb-label-dim);
}

/* Tojawuzik's shimmer, measured: a bright window crosses the word in 0.55 s and comes back every 1.7 s. */
.korb-label[data-shimmer] {
  color: transparent;
  background: linear-gradient(90deg, var(--korb-label-dim) 0 38%, var(--korb-label-lit) 46% 54%, var(--korb-label-dim) 62% 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  animation: korb-shimmer 1.7s infinite;
}

@keyframes korb-shimmer {
  0% {
    background-position: 100% 0;
    animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
  }

  32%,
  100% {
    background-position: 0% 0;
  }
}

/* The status row of a chat, laid out as in the reference: label to the right, 0.2 diameters away. */
.korb[data-layout="row"] {
  grid-auto-flow: column;
  align-items: center;
  gap: calc(var(--orb-diameter) * 0.2);
  --korb-label-size: calc(var(--orb-diameter) * 0.43);
}

.korb[data-layout="row"] .korb-shadow {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .korb-label[data-shimmer] {
    animation: none;
    color: var(--korb-label-lit);
    background: none;
  }

  .korb-glow {
    transition: opacity 200ms ease;
  }
}
