/*
  Bloom kit: the assistant's face, the dot texture, bricks and the blurred
  editor. Everything is built from the workspace tokens (--accent, --surface-*,
  --text-*), so a partner's colour flows through without any Bloom colour
  appearing on their surface. The five petal colours below are Bloom's own mark
  and are used only by the face's "bloom" tone.
*/
:root {
  --bk-petal-rose: #e98385;
  --bk-petal-orchid: #d284cc;
  --bk-petal-plum: #69598f;
  --bk-petal-mint: #57ba96;
  --bk-petal-mist: #a7cbd0;
  --bk-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- The face ---- */
.bk-face {
  position: relative;
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  border-radius: 999px;
  --bk-ink: color-mix(in srgb, var(--bk-petal-plum) 38%, black);
  --bk-p0: var(--bk-petal-rose);
  --bk-p1: var(--bk-petal-orchid);
  --bk-p2: var(--bk-petal-plum);
  --bk-p3: var(--bk-petal-mint);
  --bk-p4: var(--bk-petal-mist);
  --bk-glow: var(--bk-petal-orchid);
}
.bk-face[data-tone="accent"] {
  --bk-ink: color-mix(in srgb, var(--accent) 26%, black);
  --bk-p0: color-mix(in srgb, var(--accent) 62%, white);
  --bk-p1: var(--accent);
  --bk-p2: color-mix(in srgb, var(--accent) 74%, black);
  --bk-p3: color-mix(in srgb, var(--accent) 80%, white);
  --bk-p4: color-mix(in srgb, var(--accent) 42%, white);
  --bk-glow: var(--accent);
}
.bk-face-glow {
  position: absolute;
  inset: -24%;
  border-radius: 999px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--bk-glow) 46%, transparent), transparent 72%);
  filter: blur(6px);
  opacity: 0.5;
  animation: bk-breathe 5s ease-in-out infinite;
}
.bk-face-petals {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  transition: scale 400ms var(--bk-ease);
  scale: 0.9;
}
.bk-face-petal {
  position: absolute;
  inset: 0;
}
.bk-face-petal::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -9%;
  width: 54%;
  height: 60%;
  translate: -50% 0;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bk-petal) 78%, white), var(--bk-petal) 55%);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--bk-petal) 70%, black);
}
.bk-face-petal[data-petal="0"] { rotate: 0deg; --bk-petal: var(--bk-p0); }
.bk-face-petal[data-petal="1"] { rotate: 72deg; --bk-petal: var(--bk-p1); }
.bk-face-petal[data-petal="2"] { rotate: 144deg; --bk-petal: var(--bk-p2); }
.bk-face-petal[data-petal="3"] { rotate: 216deg; --bk-petal: var(--bk-p3); }
.bk-face-petal[data-petal="4"] { rotate: 288deg; --bk-petal: var(--bk-p4); }
.bk-face-body {
  position: absolute;
  inset: 11%;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(120% 90% at 50% -10%, rgb(255 255 255 / 0.2), transparent 46%),
    radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--bk-ink) 86%, white), var(--bk-ink) 72%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.45), inset 0 -6px 14px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.25);
}
.bk-face-features {
  position: relative;
  display: grid;
  justify-items: center;
  transform: translate(var(--bk-ex, 0px), var(--bk-ey, 0px));
  transition: transform 180ms var(--bk-ease);
}
.bk-face-eyes {
  display: flex;
  align-items: center;
  gap: calc(var(--bk-size) * 0.1);
}
.bk-face-eye {
  display: block;
  width: calc(var(--bk-size) * 0.105);
  height: calc(var(--bk-size) * 0.25);
  border-radius: 999px;
  background: white;
  box-shadow: 0 0 10px rgb(255 255 255 / 0.5);
  animation: bk-blink 21s infinite;
  animation-delay: var(--bk-delay, 0s);
  transform-origin: center;
  transition: scale 240ms var(--bk-ease), border-radius 240ms var(--bk-ease), height 240ms var(--bk-ease), width 240ms var(--bk-ease);
}
/* The mouth sits under the eyes and stays hidden until a mood or the idle "blep" shows it. */
.bk-face-mouth {
  position: absolute;
  top: calc(50% + var(--bk-size) * 0.15);
  left: 50%;
  width: calc(var(--bk-size) * 0.17);
  height: calc(var(--bk-size) * 0.085);
  translate: -50% 0;
  border-radius: 0 0 999px 999px;
  background: color-mix(in srgb, var(--bk-petal-rose) 34%, black);
  box-shadow: inset 0 0 0 0.5px rgb(255 255 255 / 0.5);
  opacity: 0;
  scale: 0.4;
  transform-origin: 50% 0;
  transition: opacity 240ms var(--bk-ease), scale 240ms var(--bk-ease), border-radius 240ms var(--bk-ease), width 240ms var(--bk-ease), height 240ms var(--bk-ease);
}
.bk-face-tongue {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bk-size) * -0.05);
  width: 62%;
  height: calc(var(--bk-size) * 0.1);
  translate: -50% 0;
  border-radius: 40% 40% 999px 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bk-petal-rose) 82%, black), var(--bk-petal-rose));
  scale: 1 0;
  transform-origin: 50% 0;
  transition: scale 240ms var(--bk-ease);
}

/* Idle (2026-11-12): both eyes blink together on one 21-second clock, with a
   double blink in the middle. Once per cycle, and only then, it winks with
   its tongue out: one deliberate moment instead of two clocks drifting apart
   into a lopsided face. */
.bk-face[data-mood="idle"] .bk-face-mouth {
  animation: bk-blep-mouth 21s infinite;
  animation-delay: var(--bk-delay, 0s);
}
.bk-face[data-mood="idle"] .bk-face-tongue {
  animation: bk-blep-tongue 21s infinite;
  animation-delay: var(--bk-delay, 0s);
}
.bk-face[data-mood="idle"] .bk-face-eye[data-eye="right"] {
  animation-name: bk-blink-wink;
}

/* Listening: eyes open a little wider and keep blinking (a stare reads cold). */
.bk-face[data-mood="listening"] .bk-face-petals { scale: 1; }
.bk-face[data-mood="listening"] .bk-face-eye {
  width: calc(var(--bk-size) * 0.115);
  height: calc(var(--bk-size) * 0.28);
}

.bk-face[data-mood="thinking"] .bk-face-petals {
  scale: 1.06;
  animation: bk-spin 3.2s linear infinite;
}
.bk-face[data-mood="thinking"] .bk-face-eye {
  animation: bk-squint 1.6s ease-in-out infinite;
}
/* Thinking looks up and to the side, the way people do. */
.bk-face[data-mood="thinking"] .bk-face-eyes {
  translate: calc(var(--bk-size) * 0.035) calc(var(--bk-size) * -0.035);
}
.bk-face-eyes { transition: translate 320ms var(--bk-ease); }
.bk-face[data-mood="thinking"] .bk-face-glow { opacity: 0.9; }

.bk-face[data-mood="happy"] .bk-face-petals {
  scale: 1.08;
  animation: bk-cheer 900ms var(--bk-ease);
}
.bk-face[data-mood="happy"] .bk-face-eye {
  animation: none;
  height: calc(var(--bk-size) * 0.11);
  width: calc(var(--bk-size) * 0.15);
  border-radius: 999px 999px 0 0;
}
.bk-face[data-mood="happy"] .bk-face-eyes { translate: 0 calc(var(--bk-size) * -0.04); }
.bk-face[data-mood="happy"] .bk-face-mouth {
  opacity: 1;
  scale: 1.25;
  top: calc(50% + var(--bk-size) * 0.06);
}
.bk-face[data-mood="happy"] .bk-face-tongue { scale: 1 0.5; }

.bk-face[data-mood="surprised"] .bk-face-eye {
  animation: bk-pop 360ms var(--bk-ease);
  width: calc(var(--bk-size) * 0.15);
  height: calc(var(--bk-size) * 0.15);
}
.bk-face[data-mood="surprised"] .bk-face-eyes { translate: 0 calc(var(--bk-size) * -0.05); }
.bk-face[data-mood="surprised"] .bk-face-mouth {
  opacity: 1;
  scale: 1;
  width: calc(var(--bk-size) * 0.1);
  height: calc(var(--bk-size) * 0.1);
  top: calc(50% + var(--bk-size) * 0.07);
  border-radius: 999px;
}

.bk-face[data-mood="sleepy"] .bk-face-petals { scale: 0.84; }
.bk-face[data-mood="sleepy"] .bk-face-eye {
  animation: bk-doze 4.8s ease-in-out infinite;
}
.bk-face[data-mood="sleepy"] .bk-face-glow { opacity: 0.25; animation-duration: 8s; }

.bk-face[data-mood="wink"] .bk-face-eye { animation: none; }
.bk-face[data-mood="wink"] .bk-face-eye[data-eye="right"] { scale: 1.1 0.12; }
.bk-face[data-mood="wink"] .bk-face-mouth { opacity: 1; scale: 1; top: calc(50% + var(--bk-size) * 0.1); }
.bk-face[data-mood="wink"] .bk-face-tongue { scale: 1 1; }

/* The face opens a little when its button is hovered or focused. */
:is(button, a):is(:hover, :focus-visible) > .bk-face .bk-face-petals {
  scale: 1;
}

/* One 21s cycle; 1% is about 210ms, so each blink is closed for about 100ms. */
@keyframes bk-blink {
  0%, 14%, 14.9%, 46%, 46.9%, 48%, 48.9%, 70%, 70.9%, 100% { scale: 1 1; }
  14.45%, 46.45%, 48.45%, 70.45% { scale: 1 0.08; }
}
@keyframes bk-blink-wink {
  0%, 14%, 14.9%, 46%, 46.9%, 48%, 48.9%, 70%, 70.9%, 85.6%, 91.2%, 100% { scale: 1 1; }
  14.45%, 46.45%, 48.45%, 70.45% { scale: 1 0.08; }
  86.4%, 90.4% { scale: 1.1 0.12; }
}
@keyframes bk-blep-mouth {
  0%, 85.6%, 91.4%, 100% { opacity: 0; scale: 0.4; }
  86.6%, 90.4% { opacity: 1; scale: 1; }
}
@keyframes bk-blep-tongue {
  0%, 86.6%, 90.6%, 100% { scale: 1 0; }
  87.4%, 89.8% { scale: 1 1; }
  88.6% { scale: 1.08 0.9; }
}
@keyframes bk-pop {
  0% { scale: 0.6; }
  60% { scale: 1.12; }
  100% { scale: 1; }
}
@keyframes bk-squint {
  0%, 100% { scale: 1 0.55; }
  50% { scale: 1 0.9; }
}
@keyframes bk-doze {
  0%, 100% { scale: 1 0.22; }
  50% { scale: 1 0.32; }
}
@keyframes bk-spin {
  to { rotate: 360deg; }
}
@keyframes bk-cheer {
  0% { rotate: 0deg; scale: 0.9; }
  60% { rotate: 80deg; scale: 1.16; }
  100% { rotate: 72deg; scale: 1.08; }
}
@keyframes bk-breathe {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.06); }
}

/* ---- Texture ---- */
.bk-dot-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Read by the canvas: ink for resting dots, accent for lit ones. */
  color: var(--text-primary);
  outline: 0 solid var(--accent);
}
/* A stage for the face and a composer: soft accent light over the dot field. */
.bk-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(60% 70% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 72%),
    var(--surface-1);
}
.bk-stage > :not(.bk-dot-field) {
  position: relative;
  z-index: 1;
}
/* Static dots for small surfaces where the live canvas would be wasteful. */
.bk-dots {
  background-image: radial-gradient(color-mix(in srgb, var(--text-primary) 13%, transparent) 1px, transparent 1.2px);
  background-size: 9px 9px;
}

/* ---- Bricks: a panel that stands off its canvas. A filled one is solid; an empty one is a soft slot. ---- */
.bk-brick {
  /* Dark: a panel is a shade lighter than its canvas. Light: it is white. */
  --bk-brick-surface: color-mix(in srgb, var(--text-primary) 7%, var(--surface-1));
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-radius: 20px;
  background: var(--bk-brick-surface);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),
    0 1px 2px color-mix(in srgb, var(--text-primary) 5%, transparent),
    0 16px 32px -20px color-mix(in srgb, var(--accent) 38%, transparent);
  transition: box-shadow 240ms var(--bk-ease), translate 240ms var(--bk-ease), background-color 240ms var(--bk-ease);
}
:root[data-theme="light"] .bk-brick {
  --bk-brick-surface: var(--surface-1);
}
.bk-brick[data-empty="true"] {
  background: color-mix(in srgb, var(--bk-brick-surface) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
}
@media (hover: hover) {
  .bk-brick[data-editable="true"]:hover {
    translate: 0 -2px;
    background: var(--bk-brick-surface);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent),
      0 1px 2px color-mix(in srgb, var(--text-primary) 5%, transparent),
      0 22px 44px -22px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  .bk-brick[data-editable="true"]:hover .bk-brick-edit {
    color: var(--accent-text, var(--accent));
  }
}
/* Keyboard focus rings the whole brick; a mouse press leaves no outline behind. */
.bk-brick:has(.bk-brick-hit:focus-visible) {
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent);
}
.bk-brick-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 0 16px;
}
.bk-brick-title {
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}
.bk-brick-edit {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text-faint);
  transition: color 160ms var(--bk-ease), background-color 160ms var(--bk-ease);
}
.bk-brick[data-empty="true"] .bk-brick-edit {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-weight: 600;
  color: var(--accent-text, var(--accent));
}
.bk-brick:has(.bk-brick-hit:focus-visible) .bk-brick-edit {
  color: var(--accent-text, var(--accent));
}
.bk-brick-body {
  display: flex;
  min-height: 72px;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px 16px;
}
/* A control inside a brick sits above the brick's own edit target. */
.bk-brick-body :is(a, button, input, select, textarea) {
  position: relative;
  z-index: 2;
}
/* The whole brick is the edit target. */
.bk-brick-hit {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  cursor: pointer;
  outline: none;
}
/* One ring of light leaves a brick as it is pressed. */
.bk-brick-hit:active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  animation: bk-radiate 600ms var(--bk-ease);
}
@keyframes bk-radiate {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  to { box-shadow: 0 0 0 18px transparent; }
}
.bk-brick[data-missing="true"] .bk-brick-title::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 999px;
  vertical-align: middle;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.bk-brick-empty {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  text-wrap: balance;
  color: var(--text-faint);
}

/* Bricks arrive one after another when a profile is first shown. */
.bk-reveal {
  animation: bk-rise 500ms var(--bk-ease) both;
  animation-delay: calc(var(--bk-index, 0) * 80ms);
}
@keyframes bk-rise {
  from { opacity: 0; translate: 0 14px; filter: blur(6px); }
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

/* ---- The blurred editor: a brick that opens over an out-of-focus page ---- */
[data-scrim="blur"] > [role="dialog"] {
  border-color: transparent;
  border-radius: 20px;
  box-shadow:
    0 0 0 1px var(--border),
    0 40px 100px -24px rgb(0 0 0 / 0.35),
    0 0 0 6px color-mix(in srgb, var(--accent) 7%, transparent);
  animation: bk-modal-in 400ms var(--bk-ease) both;
}
[data-scrim="blur"] > [role="dialog"] h3 {
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
@keyframes bk-modal-in {
  from { opacity: 0; scale: 0.955; translate: 0 14px; filter: blur(6px); }
  to { opacity: 1; scale: 1; translate: 0 0; filter: blur(0); }
}

/* Text that shimmers while the assistant is working. */
.bk-shimmer {
  background: linear-gradient(90deg, var(--text-muted) 30%, var(--accent) 50%, var(--text-muted) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: bk-shimmer 1.8s linear infinite;
}
@keyframes bk-shimmer {
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bk-face-glow,
  .bk-face .bk-face-eye,
  .bk-face .bk-face-mouth,
  .bk-face .bk-face-tongue,
  .bk-face .bk-face-petals,
  .bk-reveal,
  .bk-shimmer,
  .bk-brick-hit:active::after,
  [data-scrim="blur"] > [role="dialog"] {
    animation: none;
  }
  .bk-face-features,
  .bk-face-petals,
  .bk-brick {
    transition: none;
  }
  .bk-shimmer {
    color: var(--text-muted);
    background: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bk-face-eyes { transition: none; }
  .bk-face[data-mood] :is(.bk-face-eye, .bk-face-mouth, .bk-face-tongue) { animation: none; }
}
