/* ═══════════════════════════════════════════════════════
   Calm editor overflow menu & heading trigger (#2725)
   Loaded after skrivebord-v2.css to override base values.
   ═══════════════════════════════════════════════════════ */

/* ── Overflow menu active: viewport-relative cap ── */
.bb-skrivebord .ed-overflow-menu.active {
  max-height: calc(100vh - 120px) !important;
  overflow: hidden auto !important;
}

/* ── Unified dividers ── */
.bb-skrivebord .ed-overflow-collapse-divider,
.bb-skrivebord .ed-overflow-voice-divider {
  height: 1px !important;
  background: rgba(228, 220, 212, 0.78) !important;
  margin: 6px 8px !important;
  border: 0 !important;
}

/* ── Word-count as metadata label ── */
.bb-skrivebord .ed-overflow-word-count {
  border: 0 !important;
  border-bottom: 0 !important;
  background: transparent !important;
  color: #8A7E72 !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  padding: 6px 10px 2px !important;
  line-height: 1.2 !important;
  margin-bottom: 0 !important;
}

/* ── Voice toggle track ── */
.bb-skrivebord .ed-overflow-voice-toggle {
  display: flex !important;
  align-items: stretch !important;
  gap: 2px !important;
  padding: 3px !important;
  background: #F3EFE7 !important;
  border: 1px solid rgba(228, 220, 212, 0.78) !important;
  border-radius: 10px !important;
  height: auto !important;
  overflow: hidden !important;
}

/* ── Voice segment buttons ── */
.bb-skrivebord .ed-overflow-voice-btn {
  height: 28px !important;
  padding: 0 10px !important;
  border-radius: 7px !important;
  color: #8A7E72 !important;
}

.bb-skrivebord .ed-overflow-voice-btn.active {
  background: #FFFEFB !important;
  color: #4A7A68 !important;
  font-weight: 600 !important;
  box-shadow:
    0 1px 2px rgba(58, 47, 38, 0.06),
    0 0 0 1px rgba(110, 138, 126, 0.20) !important;
}

/* ── Six-voice persona picker: grouped list (#3758, public #589) ── */
.bb-skrivebord .ed-overflow-voice-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  width: 100% !important;
}

.bb-skrivebord .ed-overflow-voice-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
}

.bb-skrivebord .ed-overflow-voice-group-label {
  display: flex !important;
  align-items: center !important;
  gap: 5px !important;
  font-size: 10.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  line-height: 1.2 !important;
  color: #8A7E72 !important;
  padding-left: 1px !important;
}

.bb-skrivebord .ed-overflow-voice-group-label svg {
  width: 12px !important;
  height: 12px !important;
  opacity: 0.65 !important;
  flex: 0 0 auto !important;
}

/* ── Heading trigger: 36×36 circle ── */
.bb-skrivebord .format-toolbar .calm-heading-trigger {
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  background: transparent !important;
  color: #5C4D43 !important;
}

.bb-skrivebord .format-toolbar .calm-heading-trigger:hover {
  background: rgba(154, 142, 130, 0.12) !important;
}

/* Sage only when actually expanded */
.bb-skrivebord .format-toolbar .calm-heading-trigger[aria-expanded="true"] {
  background: rgba(110, 138, 126, 0.16) !important;
  color: #4A7A68 !important;
}

/* Override stale data-active paint when not expanded */
.bb-skrivebord .format-toolbar .calm-heading-trigger[data-active="true"]:not([aria-expanded="true"]) {
  background: transparent !important;
  color: #5C4D43 !important;
}

/* ── Trigger label ── */
.bb-skrivebord .format-toolbar .calm-heading-trigger .calm-trigger-label {
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
}

/* ── Trigger caret: hidden but in DOM ── */
.bb-skrivebord .calm-trigger-caret {
  display: none !important;
}

/* ── Dark mode overrides ── */
[data-theme="dark"] .bb-skrivebord .ed-overflow-collapse-divider,
[data-theme="dark"] .bb-skrivebord .ed-overflow-voice-divider {
  background: rgba(232, 224, 216, 0.12) !important;
}

[data-theme="dark"] .bb-skrivebord .ed-overflow-word-count {
  color: rgba(232, 221, 212, 0.55) !important;
}

[data-theme="dark"] .bb-skrivebord .ed-overflow-voice-toggle {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}

[data-theme="dark"] .bb-skrivebord .ed-overflow-voice-btn {
  color: rgba(232, 221, 212, 0.55) !important;
}

[data-theme="dark"] .bb-skrivebord .ed-overflow-voice-btn.active {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #7FBAA8 !important;
  box-shadow: 0 0 0 1px rgba(110, 138, 126, 0.30) !important;
}

[data-theme="dark"] .bb-skrivebord .ed-overflow-voice-group-label {
  color: rgba(232, 221, 212, 0.48) !important;
}

[data-theme="dark"] .bb-skrivebord .format-toolbar .calm-heading-trigger {
  color: #E8DDD4 !important;
}

[data-theme="dark"] .bb-skrivebord .format-toolbar .calm-heading-trigger[data-active="true"]:not([aria-expanded="true"]) {
  color: #E8DDD4 !important;
}

/* ── Mobile / touch: hide low-value inventory ── */
@media (max-width: 768px) {
  .bb-skrivebord .ed-overflow-menu .ed-overflow-item[data-skt-key="toolbar.blockquote"],
  .bb-skrivebord .ed-overflow-menu .ed-overflow-item[data-skt-key="toolbar.strikethrough"],
  .bb-skrivebord .ed-overflow-menu .ed-overflow-item[data-skt-key="toolbar.indent"],
  .bb-skrivebord .ed-overflow-word-count,
  .bb-skrivebord .ed-overflow-collapse-divider {
    display: none !important;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .bb-skrivebord .calm-heading-trigger {
    transition: none !important;
  }
}
