/* ============================================================================
   CourtOS · Guide/Pet-Widget (Phase 1 Prototyp)
   ----------------------------------------------------------------------------
   Erwartet vendor/courtos-ui.css (Tokens --cos-*) bereits geladen.
   Reines Prototyp-CSS für den visuellen/UX-Test — noch keine Tour-Engine.
   ============================================================================ */

.cos-guide {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 520; /* über App-Inhalt, unter .cos-modal (1000) */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  touch-action: none;
  user-select: none;
  transition: right .55s cubic-bezier(.32,.72,.31,1), bottom .55s cubic-bezier(.32,.72,.31,1);
}

/* Während des Ziehens soll die Position 1:1 der Maus folgen — keine Verzögerung. */
.cos-guide.cos-guide--dragging { transition: none; }

.cos-guide[hidden] { display: none; }

/* ---- Bühne: Avatar + Bodenschatten, damit das Pet "steht" statt klebt ---- */
.cos-guide-stage {
  position: relative;
  width: 64px;
  height: 78px;
}

.cos-guide-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 34px;
  height: 8px;
  margin-left: -17px;
  border-radius: 50%;
  background: rgba(18, 26, 50, .22);
  filter: blur(1px);
  animation: cos-guide-shadow-pulse 2.6s ease-in-out infinite;
}
[data-cos-theme="dark"] .cos-guide-shadow { background: rgba(0, 0, 0, .45); }

/* ---- Avatar: echtes Charakter-Bild (assets/guide/*.png), kein SVG mehr ---- */
.cos-guide-avatar {
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 64px;
  height: 72px;
  background: transparent;
  border: none;
  cursor: grab;
  display: grid;
  place-items: center;
  padding: 0;
  filter: drop-shadow(0 8px 14px rgba(18,26,50,.24));
  transform-origin: 50% 92%;
  animation: cos-guide-bob 3.4s ease-in-out infinite;
}

.cos-guide-avatar:active,
.cos-guide.cos-guide--dragging .cos-guide-avatar {
  cursor: grabbing;
  animation-play-state: paused;
  transform: scale(1.04, .92);
}

/* Zwei gestapelte Bild-Ebenen für weiches Überblenden zwischen Posen (siehe
   setAvatarImage in courtos-guide.js) — .is-front ist die gerade sichtbare. */
.cos-guide-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity .32s ease;
}
.cos-guide-img.is-front { opacity: 1; }

/* Spiegelt den Charakter horizontal, wenn er rechts vom Tour-Ziel steht —
   damit der Zeigefinger immer wirklich zum Ziel hin zeigt (siehe
   applyPointingDirection in courtos-guide.js). */
.cos-guide-avatar.cos-guide--flip .cos-guide-img { transform: scaleX(-1); }

/* ---- Zustände (data-state auf .cos-guide) — jeweils eigenes Bild (siehe
   STATE_IMAGES in courtos-guide.js), hier nur noch Bewegung/Timing. ----
   idle       — sanftes Schweben mit leichtem Wiegen, gelegentliches „Fidget“
   attentive  — wie idle, ohne Extra-Animation (eigenes Bild trägt den Ausdruck)
   speaking   — schnelleres, lebhafteres Schweben
   pointing   — wie idle (eigenes Bild trägt die Geste)
   success    — kurzer Erfolgs-Moment, danach zurück zu idle
   minimized  — an den Rand gedockt, "guckt um die Ecke"
*/
.cos-guide[data-state="speaking"] .cos-guide-avatar { animation: cos-guide-bob 1.15s ease-in-out infinite; }

@keyframes cos-guide-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-1.6deg); }
  50% { transform: translateY(-6px) rotate(0deg); }
  75% { transform: translateY(-3px) rotate(1.6deg); }
}

@keyframes cos-guide-shadow-pulse {
  0%, 100% { transform: scale(1); opacity: .22; }
  50% { transform: scale(.78); opacity: .14; }
}

@media (prefers-reduced-motion: reduce) {
  .cos-guide-avatar,
  .cos-guide-shadow {
    animation: none !important;
  }
}

/* ---- Steuer-Leiste (Einklappen) ---- */
.cos-guide-controls {
  display: flex;
  gap: 4px;
}
.cos-guide-min-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--cos-border, #E6E2DB);
  background: var(--cos-surface, #fff);
  color: var(--cos-text-2, #5C6470);
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.cos-guide-min-btn:hover { color: var(--cos-text, #0C0E12); }

/* ---- Sprechblase: jetzt ein Options-Menü statt nur einer Begrüßung ---- */
.cos-guide-bubble {
  width: 250px;
  background: var(--cos-surface, #fff);
  color: var(--cos-text, #0C0E12);
  border: 1px solid var(--cos-border, #E6E2DB);
  border-radius: var(--cos-r-md, 14px);
  box-shadow: var(--cos-shadow-card, 0 18px 44px -22px rgba(18,26,50,.20));
  padding: 14px;
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  font-size: 13px;
  line-height: 1.45;
}

.cos-guide-bubble[hidden] { display: none; }

.cos-guide-bubble-title {
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--cos-text, #0C0E12);
}

.cos-guide-menu { display: flex; flex-direction: column; gap: 2px; }

.cos-guide-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  font-weight: 600;
  font-size: 13px;
  color: var(--cos-text, #0C0E12);
  background: none;
  border: none;
  border-radius: var(--cos-r-sm, 10px);
  padding: 9px 8px;
  cursor: pointer;
}
.cos-guide-menu-item:hover { background: var(--cos-surface-2, #F5F3EF); }
.cos-guide-menu-item:disabled {
  color: var(--cos-text-3, #8A929C);
  cursor: not-allowed;
}
.cos-guide-menu-item:disabled:hover { background: none; }

.cos-guide-menu-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  background: #2E86FF;
  color: #fff;
  font-style: normal;
  font-size: 10px;
}
.cos-guide-menu-item:disabled .cos-guide-menu-icon { background: var(--cos-border, #E6E2DB); color: var(--cos-text-3, #8A929C); }

.cos-guide-bubble-note {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--cos-border-soft, #EFECE6);
  font-size: 11px;
  color: var(--cos-text-3, #8A929C);
}

@media (max-width: 480px) {
  .cos-guide { right: 14px; bottom: 14px; }
  .cos-guide-bubble { width: calc(100vw - 60px); }
}

/* ============================================================================
   Phase 2 — Tour-Engine-Grundgerüst (Varianten B "kurze Einführung" und
   C "geführte Tour"). Noch ohne Modul-Inhalte — die liefert Phase 3.
   ============================================================================ */

/* Spotlight: eigenständiges, position:fixed Overlay-Element (nicht das Ziel-Element
   selbst!) — so kann es nicht mit dessen eigenem box-shadow/overflow/z-index
   kollidieren. Positionierung per JS via getBoundingClientRect. */
.cos-guide-spotlight {
  position: fixed;
  z-index: 900;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: 0 0 0 4px var(--cos-accent, #E0A82E), 0 0 0 9999px rgba(12, 14, 18, .5);
  transition: top .2s ease, left .2s ease, width .2s ease, height .2s ease, opacity .15s ease;
  opacity: 0;
}
.cos-guide-spotlight.is-active { opacity: 1; }
[data-cos-theme="dark"] .cos-guide-spotlight {
  box-shadow: 0 0 0 4px var(--cos-accent, #E0A82E), 0 0 0 9999px rgba(0, 0, 0, .68);
}

/* Schritt-Panel: wie die Bubble, aber mit Fortschritt + Mehrfach-Navigation.
   Wird bei einem Ziel-Element in dessen Nähe positioniert (position:fixed,
   top/left werden von JS gesetzt), sonst wie die Bubble neben dem Pet. */
.cos-guide-step {
  position: fixed;
  z-index: 902; /* über dem Spotlight-Element */
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--cos-surface, #fff);
  color: var(--cos-text, #0C0E12);
  border: 1px solid var(--cos-border, #E6E2DB);
  border-radius: var(--cos-r-md, 14px);
  box-shadow: var(--cos-shadow-card, 0 18px 44px -22px rgba(18,26,50,.20));
  padding: 16px 18px;
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  /* Bewegt sich zusammen mit dem laufenden Charakter zum nächsten Ziel. */
  transition: right .55s cubic-bezier(.32,.72,.31,1), bottom .55s cubic-bezier(.32,.72,.31,1);
}
.cos-guide-step[hidden] { display: none; }

.cos-guide-step-progress { display: flex; gap: 4px; margin-bottom: 10px; }
.cos-guide-step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cos-border, #E6E2DB); }
.cos-guide-step-dot.is-active { background: var(--cos-accent, #E0A82E); }
.cos-guide-step-dot.is-done { background: var(--cos-accent-strong, #BE851A); }

.cos-guide-step-title { font-weight: 700; font-size: 14px; margin: 0 0 4px; }
.cos-guide-step-text { font-size: 13px; line-height: 1.45; color: var(--cos-text-2, #5C6470); margin: 0 0 14px; }

.cos-guide-step-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cos-guide-step-actions-left,
.cos-guide-step-actions-right { display: flex; align-items: center; gap: 10px; }

.cos-guide-step-btn-text {
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--cos-text-2, #5C6470);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
}
.cos-guide-step-btn-text:hover { color: var(--cos-text, #0C0E12); }
.cos-guide-step-btn-text:disabled { opacity: .4; cursor: not-allowed; }

.cos-guide-step-btn-primary {
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--cos-brand, #27407A);
  border: none;
  border-radius: var(--cos-r-pill, 999px);
  padding: 8px 18px;
  cursor: pointer;
}
.cos-guide-step-btn-primary:hover { background: var(--cos-brand-strong, #16264C); }

/* ============================================================================
   Einstellungen-Kachel (CourtGuide.mountSettingsToggle)
   ============================================================================ */
.cos-guide-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.cos-guide-settings-row + .cos-guide-settings-row {
  border-top: 1px solid var(--cos-border-soft, #EFECE6);
}
.cos-guide-settings-label { font-weight: 600; font-size: 14px; color: var(--cos-text, #0C0E12); }
.cos-guide-settings-desc { font-size: 12px; color: var(--cos-text-2, #5C6470); margin-top: 2px; }

.cos-guide-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
  flex: none;
}
.cos-guide-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.cos-guide-switch-track {
  position: absolute;
  inset: 0;
  background: var(--cos-border, #E6E2DB);
  border-radius: var(--cos-r-pill, 999px);
  transition: background .15s ease;
}
.cos-guide-switch-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(18,26,50,.3);
  transition: transform .15s ease;
}
.cos-guide-switch input:checked + .cos-guide-switch-track { background: var(--cos-accent, #E0A82E); }
.cos-guide-switch input:checked + .cos-guide-switch-track::before { transform: translateX(16px); }
.cos-guide-switch input:focus-visible + .cos-guide-switch-track { outline: 2px solid var(--cos-brand, #27407A); outline-offset: 2px; }

.cos-guide-settings-btn {
  font-family: var(--cos-font, 'Sora', system-ui, sans-serif);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--cos-r-md, 14px);
  border: 1px solid var(--cos-border, #E6E2DB);
  background: var(--cos-surface, #fff);
  color: var(--cos-text, #0C0E12);
  cursor: pointer;
}
.cos-guide-settings-btn:hover { border-color: var(--cos-brand, #27407A); }
.cos-guide-settings-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================================
   Rechtsklick-/Doppelklick-Kontextmenü (Einklappen / Nur Symbol in der Navigation)
   ============================================================================ */
.cos-guide-ctxmenu {
  position: fixed;
  z-index: 903;
  width: 240px;
  background: var(--cos-surface, #fff);
  border: 1px solid var(--cos-border, #E6E2DB);
  border-radius: var(--cos-r-md, 14px);
  box-shadow: var(--cos-shadow-card, 0 18px 44px -22px rgba(18,26,50,.20));
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: right .55s cubic-bezier(.32,.72,.31,1), bottom .55s cubic-bezier(.32,.72,.31,1);
}
.cos-guide-ctxmenu[hidden] { display: none; }

/* ============================================================================
   Nav-Icon-Modus: kleines, fest angedocktes Symbol statt des vollen Charakters
   ============================================================================ */
/* Eingeklappt: kleines Icon oben rechts, wie in einer Tab-/Menüleiste
   abgelegt — die einzige Einklapp-Darstellung (siehe courtos-guide.js). */
.cos-guide-navicon {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 950;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--cos-border, #E6E2DB);
  background: var(--cos-surface, #fff);
  box-shadow: var(--cos-shadow-sm, 0 2px 10px -4px rgba(18,26,50,.16));
  padding: 5px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s ease, border-color .15s ease;
}
.cos-guide-navicon[hidden] { display: none; }
.cos-guide-navicon img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.cos-guide-navicon:hover { border-color: #2E86FF; transform: scale(1.06); }
