/* ============================================
   Status avatar (SVG built by status-avatar.js)
   + segmented status control
   ============================================ */

.status-avatar {
  /* colour behind the avatar, used for the cut around the status dot */
  --sa-cutout: var(--color-board-frame);
  display: block;
  width: 100%;
  aspect-ratio: 1;
  -webkit-tap-highlight-color: transparent;
}

.sa-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sa-disc { fill: var(--sa-disc); }
.sa-ink-fill { fill: var(--sa-ink); }
.sa-ink-stroke {
  fill: none;
  stroke: var(--sa-ink);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sa-mouth--wave { stroke-width: 6; }

.sa-mouth--oh {
  transform-box: fill-box;
  transform-origin: center;
  animation: sa-oh 2.6s ease-in-out infinite;
}

@keyframes sa-oh {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(0.85, 1.12); }
}

/* --- Background stars (online: faint, idle: bright night) --- */
.sa-stars {
  opacity: 0;
  transition: opacity 0.6s var(--ease-standard);
}

.sa-svg[data-state="idle"] .sa-stars { opacity: 1; }

.sa-star {
  fill: var(--sa-star);
  transform-box: fill-box;
  transform-origin: center;
  animation: sa-star 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.55s);
}

@keyframes sa-star {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* --- Decorations: enter "nach und nach", leave together --- */
.sa-deco { pointer-events: none; }

.sa-sparkle,
.sa-note,
.sa-sweat,
.sa-wisp {
  transform-box: fill-box;
  transform-origin: center;
}

.sa-sparkle {
  opacity: 0;
  transform: scale(0) rotate(-60deg);
  transition: transform 0.5s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.25s var(--ease-standard);
}

.sa-deco.is-on .sa-sparkle {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  transition-delay: calc(var(--i) * 90ms + 80ms);
}

.sa-sparkle__shape {
  fill: var(--sa-sparkle);
  stroke: var(--sa-sparkle);
  stroke-width: 6;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: sa-twinkle 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.8s);
}

@keyframes sa-twinkle {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Zzz like in a comic: they pop in one after another along a diagonal, bob a little and leave in the same order */
.sa-z {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  fill: var(--sa-z);
  stroke: var(--sa-z);
  stroke-width: 0.14em;
  stroke-linejoin: round;
  stroke-linecap: round;
  text-anchor: middle;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.sa-deco.is-on .sa-z {
  animation: sa-z 4.6s cubic-bezier(0.4, 0, 0.3, 1) infinite;
  animation-delay: calc(var(--i) * 0.55s);
}

@keyframes sa-z {
  0% { opacity: 0; transform: translateY(8px) scale(0.2) rotate(-14deg); }
  9% { opacity: 1; transform: translateY(0) scale(1.15) rotate(5deg); }
  15% { opacity: 1; transform: translateY(-1px) scale(1) rotate(0deg); }
  45% { opacity: 1; transform: translateY(-5px) scale(1) rotate(-4deg); }
  78% { opacity: 1; transform: translateY(-2px) scale(1) rotate(3deg); }
  92%, 100% { opacity: 0; transform: translateY(-9px) scale(0.5) rotate(-6deg); }
}

/* Notes fly in one after another, then orbit the head (position is set in JS) */
.sa-note {
  opacity: 0;
  transform: translate(var(--fx), var(--fy)) scale(0.3) rotate(40deg);
  transition: transform 0.6s cubic-bezier(0.3, 1.35, 0.5, 1), opacity 0.3s var(--ease-standard);
}

.sa-deco.is-on .sa-note {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--i) * 85ms);
}

.sa-note__bg { fill: var(--sa-note); }
.sa-note__bg--accent { fill: var(--sa-note-accent); }
/* Line lengths are set from JS every frame (see Avatar.frame) */
.sa-note__line { stroke-width: 6; opacity: 0.85; }

.sa-sweat {
  fill: var(--sa-sweat);
  stroke: var(--sa-ink);
  stroke-width: 6;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) 0.35s, opacity 0.2s 0.35s;
}


.sa-deco.is-on .sa-sweat {
  opacity: 1;
  transform: scale(1);
  animation: sa-sweat 2.8s ease-in-out 0.9s infinite;
}

/* The drop stays put and just hangs, no fading in and out */
@keyframes sa-sweat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.sa-wisp {
  fill: var(--sa-body-invisible);
  opacity: 0;
}

.sa-deco.is-on .sa-wisp {
  animation: sa-wisp 3.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 1.2s);
}

@keyframes sa-wisp {
  0% { opacity: 0; transform: translateY(10px) scale(0.4); }
  30% { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-46px) scale(1.2); }
}

/* --- Status badge: one shape that morphs (dot, crescent) plus one hole that morphs (none, bar, ring) --- */
.sa-status__cut { fill: var(--sa-cutout); transition: fill 0.3s var(--ease-standard); }

.sa-status__shape {
  fill: var(--color-status-online);
  stroke: var(--color-status-online);
  stroke-width: 10;
  stroke-linejoin: round;
  transition: fill 0.4s var(--ease-standard), stroke 0.4s var(--ease-standard);
}

.sa-status__hole { fill: var(--sa-cutout); transition: fill 0.3s var(--ease-standard); }

.sa-svg[data-state="idle"] .sa-status__shape { fill: var(--color-status-idle); stroke: var(--color-status-idle); }
.sa-svg[data-state="busy"] .sa-status__shape { fill: var(--color-status-busy); stroke: var(--color-status-busy); }
.sa-svg[data-state="invisible"] .sa-status__shape { fill: var(--color-status-invisible); stroke: var(--color-status-invisible); }

@media (prefers-reduced-motion: reduce) {
  .sa-svg *,
  .sa-svg *::before {
    animation: none !important;
  }
  .sa-svg [class] { transition-duration: 0.01ms !important; }
  .sa-deco.is-on .sa-z { opacity: 0.8; }
  .sa-deco.is-on .sa-z:nth-child(n + 3) { opacity: 0; }
}

/* ============================================
   Segmented control (status)
   ============================================ */
.segmented {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--seg-gap, 0.375rem);
  padding: var(--seg-pad, 0.375rem);
  border-radius: var(--border-radius-pill);
  background: var(--sa-segment-track);
  border: 1px solid var(--color-board-section-border);
  font-family: var(--font-body);
  letter-spacing: var(--tracking);
}

.segmented__thumb {
  position: absolute;
  top: var(--seg-pad, 0.375rem);
  bottom: var(--seg-pad, 0.375rem);
  left: 0;
  width: var(--thumb-w, 0);
  transform: translateX(var(--thumb-x, 0));
  border-radius: var(--border-radius-pill);
  background: var(--sa-segment-thumb);
  pointer-events: none;
}

.segmented.is-ready .segmented__thumb {
  transition:
    transform 0.5s cubic-bezier(0.3, 1.25, 0.45, 1),
    width 0.5s cubic-bezier(0.3, 1.25, 0.45, 1);
}

.segmented__option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: var(--seg-option-pad, 0.6em 1.1em);
  border: 0;
  border-radius: var(--border-radius-pill);
  background: transparent;
  color: var(--sa-segment-text);
  font: inherit;
  font-size: var(--seg-font, var(--text-sm));
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking);
  line-height: 1;
  white-space: nowrap;
  transition: color 0.3s var(--ease-standard), background-color 0.2s var(--ease-standard);
}

.segmented__option:hover:not([aria-checked="true"]) {
  background: var(--color-surface-work-card-hover-stroke);
}

.segmented__option[aria-checked="true"] {
  color: var(--sa-segment-text-active);
}

.segmented__option:focus-visible {
  outline: 2px solid var(--color-text-primary);
  outline-offset: 2px;
}

.segmented__dot {
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  background: var(--dot);
  flex: none;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.segmented__option[aria-checked="true"] .segmented__dot {
  transform: scale(1.2);
}
