/* ================================================================== */
/* Header (S2 App Frame Header — 48px)                               */
/* ================================================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  height: var(--s2-header-height);
  min-height: var(--s2-header-height);
  background: var(--s2-bg-layer-2);
  flex-shrink: 0;
  z-index: 10;
}
.header__row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 6px;
}
.header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header__spacer {
  flex: 1;
}
.header__logo {
  width: 32px;
  height: 32px;
  margin-right: 12px;
  flex-shrink: 0;
  transition: viewBox 300ms ease;
}

/* Hamburger toggle in header (replaces logo) */
.header__brand .scoops-hamburger {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--s2-content-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 130ms ease,
    color 130ms ease;
}
.header__brand .scoops-hamburger:hover {
  background: var(--s2-bg-elevated);
  color: var(--s2-content-default);
}

/* Logo scoop entrance animation — drops in from above with bounce */
.logo-scoop-enter {
  transform-box: fill-box;
  transform-origin: center;
  animation: scoop-drop 600ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes scoop-drop {
  0% {
    transform: translateY(-18px) scale(0.2);
    opacity: 0;
  }
  40% {
    transform: translateY(1px) scale(1.15);
    opacity: 1;
  }
  60% {
    transform: translateY(-2px) scale(0.95);
  }
  80% {
    transform: translateY(0.5px) scale(1.03);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
/* Existing scoops wiggle when a new one arrives */
.logo-scoop-wiggle {
  transform-box: fill-box;
  transform-origin: center;
  animation: scoop-wiggle 500ms ease both;
}
@keyframes scoop-wiggle {
  0% {
    transform: translateY(0);
  }
  20% {
    transform: translateY(1.5px);
  }
  40% {
    transform: translateY(-1px);
  }
  60% {
    transform: translateY(0.5px);
  }
  100% {
    transform: translateY(0);
  }
}
/* Cone squash when new scoop lands */
.logo-cone-squash {
  transform-box: fill-box;
  transform-origin: top center;
  animation: cone-squash 500ms ease both;
}
@keyframes cone-squash {
  0% {
    transform: scaleY(1) scaleX(1);
  }
  30% {
    transform: scaleY(0.92) scaleX(1.06);
  }
  60% {
    transform: scaleY(1.03) scaleX(0.98);
  }
  100% {
    transform: scaleY(1) scaleX(1);
  }
}
.header__title {
  font-size: 18px;
  font-weight: 800;
  color: var(--s2-gray-900);
  line-height: 20px;
  letter-spacing: -0.01em;
}
.header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.header__separator {
  width: 1px;
  height: 20px;
  background: var(--s2-border-subtle);
  margin: 0;
}

/* S2 Ghost Action Button — icon-only pill */
.header__btn {
  background: transparent;
  color: var(--s2-content-default);
  border: none;
  border-radius: 8px;
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: var(--s2-font-family);
  cursor: pointer;
  transition:
    background var(--s2-transition-default),
    color var(--s2-transition-default),
    transform var(--s2-transition-default);
  flex-shrink: 0;
  position: relative;
}
.header__btn:hover {
  background: var(--s2-bg-elevated);
  color: var(--s2-content-default);
}
.header__btn:active {
  transform: scale(0.92);
}
.header__btn svg {
  width: 20px;
  height: 20px;
}
/* Text variant for standalone mode labels */
.header__btn--text {
  width: auto;
  padding: var(--s2-spacing-50) var(--s2-spacing-200);
  font-size: var(--s2-font-size-75);
  font-weight: 500;
  border-radius: var(--s2-radius-default);
  gap: var(--s2-spacing-75);
}

/* ================================================================== */
/* S2 Tooltip — rendered via JS into a fixed-position body element     */
/* ================================================================== */
.s2-tooltip {
  position: fixed;
  padding: 4px 8px;
  background: var(--s2-gray-900);
  color: var(--s2-gray-25);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--s2-font-family);
  white-space: pre-line;
  max-width: 280px;
  text-align: left;
  border-radius: var(--s2-radius-s);
  pointer-events: none;
  opacity: 0;
  transition: opacity 130ms ease;
  z-index: 10000;
  line-height: 1.3;
}
.s2-tooltip--visible {
  opacity: 1;
}

/* ================================================================== */
/* User Avatar                                                         */
/* ================================================================== */
.header__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid transparent;
  transition:
    border-color var(--s2-transition-default),
    box-shadow var(--s2-transition-default);
  position: relative;
  background: var(--s2-gray-200);
  color: var(--s2-content-tertiary);
}
.header__avatar:hover {
  border-color: var(--s2-gray-300);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--s2-accent) 20%, transparent);
}
.header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.header__avatar--initials {
  background: var(--slicc-cone);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--s2-font-family);
  line-height: 1;
}
.header__avatar--placeholder svg {
  width: 16px;
  height: 16px;
}

/* ================================================================== */
/* Avatar Popover                                                      */
/* ================================================================== */
.avatar-popover {
  position: fixed;
  z-index: 10001;
  min-width: 220px;
  background: var(--s2-bg-layer-2);
  border: 1px solid var(--s2-border-subtle);
  border-radius: var(--s2-radius-default);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 8px 0;
  font-family: var(--s2-font-family);
}
.avatar-popover__user {
  padding: 12px 16px;
  border-bottom: 1px solid var(--s2-border-subtle);
}
.avatar-popover__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--s2-content-default);
}
.avatar-popover__provider {
  font-size: 11px;
  color: var(--s2-content-tertiary);
  margin-top: 2px;
}
.avatar-popover__caption {
  padding: 4px 16px 8px;
  font-size: 11px;
  color: var(--s2-content-tertiary);
}
.avatar-popover__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--s2-content-default);
  font-size: 13px;
  font-family: var(--s2-font-family);
  cursor: pointer;
  text-align: left;
  transition: background var(--s2-transition-default);
}
.avatar-popover__item:hover {
  background: var(--s2-bg-elevated);
}
.avatar-popover__item--danger {
  color: var(--s2-negative);
}
.avatar-popover__item--danger:hover {
  background: color-mix(in srgb, var(--s2-negative) 8%, transparent);
}
.avatar-popover__separator {
  height: 1px;
  background: var(--s2-border-subtle);
  margin: 4px 0;
}

/* ================================================================== */
/* Popout button + detached-active overlay                             */
/* ================================================================== */
.header__popout-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
}
.header__popout-btn:hover {
  opacity: 1;
}
.header__popout-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.layout-detached-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  color: #fff;
  font-size: 16px;
  padding: 2rem;
  text-align: center;
}
.layout-detached-overlay-close {
  margin-top: 1.5rem;
  padding: 0.6rem 1.5rem;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
