/* Ghost coach dock (Ghost Crew). Same look as the Chores coach: mascot, speech bubble, dark band.
   Tokens only; motion is transform and opacity. */
.ghost-coach {
  --size-bubble-tail: 14px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-sizing: border-box;
  width: 100%;
  max-height: 30vh;
  overflow: hidden;
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  background-color: var(--color-surface);
  border-top: var(--size-border) solid var(--color-outline-variant);
  box-shadow: 0 -8px 18px -8px var(--color-shadow);
}
.ghost-coach[hidden] {
  display: none;
}
/* Room under the last controls, only while the dock shows. */
.page.has-coach-dock {
  padding-bottom: calc(var(--space-section) + 112px + env(safe-area-inset-bottom, 0px));
}
/* A focused control scrolls clear of the dock. */
:root:has(.has-coach-dock) {
  scroll-padding-bottom: calc(112px + var(--space-lg) + env(safe-area-inset-bottom, 0px));
}
.ghost-coach-mascot {
  flex: none;
  width: 58px;
  height: 72px;
  transform-origin: 50% 100%;
  animation: ghost-coach-bob 3.6s ease-in-out infinite;
}
.ghost-coach-mascot svg {
  display: block;
  width: 100%;
  height: 100%;
}
.ghost-coach-mascot.is-hopping {
  animation: ghost-coach-hop var(--duration-slow) var(--ease-out), ghost-coach-bob 3.6s ease-in-out infinite;
}
/* The speech bubble: lightbulb, then the label row and the line. */
.ghost-coach-bubble {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border: var(--size-border) solid var(--color-outline-variant);
  border-radius: var(--radius-xl);
  background-color: var(--color-surface-container);
  color: var(--color-on-surface);
}
/* Tail pointing left at the ghost. It takes the bubble's border colour. */
.ghost-coach-bubble::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(var(--size-bubble-tail) / -2 - var(--size-border));
  width: var(--size-bubble-tail);
  height: var(--size-bubble-tail);
  box-sizing: border-box;
  border-style: solid;
  border-width: 0 0 var(--size-border) var(--size-border);
  border-color: inherit;
  background-color: var(--color-surface-container);
  transform: translateY(-50%) rotate(45deg);
}
.ghost-coach-icon {
  flex: none;
  display: inline-flex;
  color: var(--color-primary);
}
.ghost-coach-icon svg {
  display: block;
}
.ghost-coach-body {
  flex: 1;
  min-width: 0;
}
.ghost-coach-text {
  display: grid;
  font-size: var(--font-size-body-lg);
  line-height: var(--line-height-body-lg);
  overflow-wrap: anywhere;
}
.ghost-coach-layer {
  grid-area: 1 / 1;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}
.ghost-coach-layer.is-live {
  opacity: 1;
}
.ghost-coach-label,
.ghost-coach-line {
  display: block;
}
.ghost-coach-label {
  font-size: var(--font-size-label-md);
  line-height: var(--line-height-label-md);
  letter-spacing: var(--letter-spacing-label-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}
.ghost-coach-step {
  white-space: nowrap;
}
.ghost-coach-sep {
  color: var(--color-primary);
}
/* Show me and Hide, on the right of the dock. */
.ghost-coach-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.ghost-coach-actions .btn {
  min-height: var(--size-touch);
  min-width: var(--size-touch);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-label-lg);
  line-height: var(--line-height-label-lg);
  box-shadow: none;
}
@media (min-width: 768px) {
  .ghost-coach-mascot {
    width: 77px;
    height: 96px;
  }
  .ghost-coach-actions {
    flex-direction: row;
    gap: var(--space-sm);
  }
  .ghost-coach-actions .btn {
    padding-inline: var(--space-lg);
  }
}
/* Below 768px: smaller ghost, icon and text, no tail, buttons stacked; the dock stays under about 110px. */
@media (max-width: 767.98px) {
  .ghost-coach {
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    padding-bottom: calc(var(--space-xs) + env(safe-area-inset-bottom, 0px));
  }
  .ghost-coach-mascot {
    width: 38px;
    height: 48px;
  }
  .ghost-coach-bubble {
    align-items: flex-start;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
  }
  .ghost-coach-bubble::before {
    display: none;
  }
  /* The bulb sits in the label row, so the line below gets the full bubble width. */
  .ghost-coach-icon {
    position: absolute;
    top: calc(var(--space-xs) + var(--size-border));
    left: var(--space-sm);
  }
  .ghost-coach-icon svg {
    width: 16px;
    height: 16px;
  }
  .ghost-coach-label {
    padding-inline-start: calc(16px + var(--space-xs));
  }
  .ghost-coach-text {
    font-size: var(--font-size-body-md);
    line-height: var(--line-height-label-lg);
  }
  .ghost-coach-actions .btn {
    padding-inline: var(--space-xs);
    font-size: var(--font-size-label-md);
    line-height: var(--line-height-label-md);
  }
}
/* Shine: one slide up on load, one soft glow pulse per new line. */
.ghost-coach.is-entering {
  animation: ghost-coach-enter var(--duration-slow) var(--ease-out) both;
}
.ghost-coach.is-shining {
  animation: ghost-coach-shine 1.2s var(--ease-out);
}
/* The control that Show me points at. */
.coach-glow {
  animation: coach-target-glow 2s var(--ease-out);
}
@keyframes ghost-coach-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 calc(var(--space-xs) * -1); }
}
@keyframes ghost-coach-hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(calc(var(--space-sm) * -1)); }
}
@keyframes ghost-coach-enter {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes ghost-coach-shine {
  0%, 100% { box-shadow: 0 -8px 18px -8px var(--color-shadow); }
  35% { box-shadow: 0 -4px 22px 2px var(--accent-pixel), 0 -8px 18px -8px var(--color-shadow); }
}
@keyframes coach-target-glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  15%, 75% { box-shadow: 0 0 0 4px var(--accent-pixel), 0 0 18px 4px var(--accent-pixel); }
}
@media (prefers-reduced-motion: reduce) {
  .ghost-coach,
  .coach-glow,
  .ghost-coach-mascot,
  .ghost-coach-mascot.is-hopping {
    animation: none;
  }
  .ghost-coach-layer {
    transition: none;
  }
  .ghost-coach.is-entering,
  .ghost-coach.is-shining {
    animation: none;
  }
}
.ghost-coach[data-reduced-motion="true"],
.ghost-coach[data-reduced-motion="true"] .ghost-coach-mascot,
.ghost-coach[data-reduced-motion="true"] .ghost-coach-layer {
  animation: none;
  transition: none;
}
