/*  guide.css — everything the guide needs to draw itself.
 *  Scoped under .pg-root so it cannot leak into your app's styles.
 */

.pg-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease;
  font-family: inherit;
  --pg-accent: #f0a81e;
  --pg-accent-soft: #fdf0d2;
  --pg-ink: #5a3d02;
  --pg-h: 132px;
  --pg-surface: #fff;
  --pg-text: #1b1b1f;
  --pg-line: rgba(20, 20, 30, 0.1);
}
.pg-root.pg-live { opacity: 1; visibility: visible; }

/* ---------- spotlight ring ---------- */
.pg-ring {
  position: absolute;
  top: 0; left: 0;
  border-radius: 12px;
  border: 2px solid var(--pg-accent);
  background: transparent;
  opacity: 0;
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1),
    width 0.42s cubic-bezier(0.32, 0.72, 0, 1),
    height 0.42s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.24s ease, box-shadow 0.3s ease;
}
.pg-ring.pg-scrim { box-shadow: 0 0 0 9999px rgba(16, 18, 27, 0.42); }
.pg-ring::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 15px;
  border: 2px solid var(--pg-accent);
  opacity: 0.3;
  animation: pg-pulse 2.2s ease-out infinite;
}
@keyframes pg-pulse {
  0% { transform: scale(1); opacity: 0.34; }
  70% { transform: scale(1.045); opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- pointer leash ---------- */
.pg-leash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  overflow: visible;
  transition: opacity 0.3s ease;
}
.pg-leash-path {
  fill: none;
  stroke: var(--pg-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 2 9;
  opacity: 0.85;
  animation: pg-dash 0.9s linear infinite;
}
@keyframes pg-dash { to { stroke-dashoffset: -11; } }

/* ---------- the character ---------- */
.pg-guide {
  position: absolute;
  top: 0; left: 0;
  height: var(--pg-h);
  will-change: transform;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 14px 20px rgba(20, 22, 40, 0.22));
}
.pg-sprite {
  height: 100%;
  width: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.pg-m-duo { height: calc(var(--pg-h) * 1.06); }

/* ---------- speech bubble ---------- */
.pg-bubble {
  position: absolute;
  top: 0; left: 0;
  max-width: min(340px, calc(100vw - 32px));
  background: var(--pg-surface);
  color: var(--pg-text);
  border: 2px solid var(--pg-accent);
  border-radius: 16px;
  padding: 13px 15px 9px;
  box-shadow: 0 16px 34px rgba(18, 20, 34, 0.16);
  pointer-events: auto;
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity 0.2s ease, transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.pg-bubble.pg-on { opacity: 1; animation: pg-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pg-pop {
  from { scale: 0.9; }
  to { scale: 1; }
}
.pg-bubble::after {
  content: '';
  position: absolute;
  left: 26px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: var(--pg-surface);
  border-right: 2px solid var(--pg-accent);
  border-bottom: 2px solid var(--pg-accent);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}
.pg-bubble.pg-b-side::after { left: -9px; bottom: 22px; transform: rotate(135deg); }
.pg-bubble.pg-b-below::after { top: -9px; bottom: auto; transform: rotate(225deg); }

.pg-beat {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  min-height: 1.45em;
}
.pg-beat:last-child { margin-bottom: 0; }
.pg-who {
  --pg-who: var(--pg-accent);
  display: inline-block;
  margin-right: 7px;
  padding: 1px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--pg-who) 16%, transparent);
  color: color-mix(in srgb, var(--pg-who) 74%, #101018);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.pg-bubble-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--pg-line);
}
.pg-dots {
  font-size: 11px;
  font-weight: 600;
  color: color-mix(in srgb, var(--pg-text) 45%, transparent);
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}
.pg-bubble button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s ease, background 0.15s ease;
}
.pg-skip {
  background: transparent;
  color: color-mix(in srgb, var(--pg-text) 52%, transparent);
}
.pg-skip:hover { background: color-mix(in srgb, var(--pg-text) 6%, transparent); }
.pg-next {
  background: var(--pg-accent);
  color: #fff;
  border-color: var(--pg-accent);
}
.pg-next:hover { filter: brightness(1.07); }
/* Replay and Back: quiet by default so they never compete with Next, but
   always there -- with audio as the primary delivery, missing a line and
   having no way back was a real dead end. */
.pg-replay,
.pg-back {
  background: transparent;
  color: color-mix(in srgb, var(--pg-text) 60%, transparent);
}
.pg-replay { padding: 6px 10px; font-size: 14px; line-height: 1; }
.pg-replay:hover:not(:disabled),
.pg-back:hover:not(:disabled) { background: color-mix(in srgb, var(--pg-text) 8%, transparent); }
.pg-back:disabled {
  opacity: 0.32;
  cursor: default;
}
.pg-bubble button:focus-visible { outline: 2px solid var(--pg-ink); outline-offset: 2px; }

/* ---------- full-text switch ---------- */
/* The written lesson runs several times longer than the spoken line, so it is
   capped and scrolls rather than growing a bubble tall enough to bury the very
   control the guide is pointing at. */
.pg-long {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--pg-line);
  /* Sized so the whole bubble stays under ~420px even on a phone. Past that
     there is no clear band left on a 844px-tall screen and the bubble starts
     covering the control it is describing -- measured cliff, not a guess. The
     rest scrolls. */
  max-height: min(26vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pg-long[hidden] { display: none; }
.pg-long p {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: color-mix(in srgb, var(--pg-text) 78%, transparent);
}
.pg-long p:last-child { margin-bottom: 0; }

.pg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.pg-toggle[hidden] { display: none; }
.pg-toggle-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.pg-toggle-track {
  position: relative;
  display: block;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pg-text) 22%, transparent);
  transition: background 0.18s ease;
}
.pg-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 18, 27, 0.32);
  transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1);
}
.pg-toggle-input:checked + .pg-toggle-track { background: var(--pg-accent); }
.pg-toggle-input:checked + .pg-toggle-track .pg-toggle-thumb { transform: translateX(13px); }
.pg-toggle-input:focus-visible + .pg-toggle-track { outline: 2px solid var(--pg-ink); outline-offset: 2px; }
.pg-toggle-text {
  font-size: 12px;
  font-weight: 600;
  color: color-mix(in srgb, var(--pg-text) 52%, transparent);
}

@media (max-width: 560px) {
  .pg-bubble { max-width: calc(100vw - 24px); }
  .pg-beat { font-size: 14.5px; }
  /* Keep the switch, drop its label -- the wrapper's aria-label covers
     screen readers, and this is the control most affordably shortened when
     the footer bar (dots, two toggles, replay, back, exit, next) is tight
     on a phone width, which is the exact crowding this restructure exists
     to fix. Full text keeps its label; that toggle predates this one and
     changing its behavior isn't this change's job. */
  .pg-scrim-toggle .pg-toggle-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-ring::after, .pg-leash-path { animation: none; }
  .pg-bubble.pg-on { animation: none; }
  .pg-ring, .pg-bubble { transition-duration: 0.01s; }
}

@media (prefers-color-scheme: dark) {
  .pg-root { --pg-surface: #1b1d24; --pg-text: #f2f3f7; --pg-line: rgba(255, 255, 255, 0.13); }
  .pg-ring.pg-scrim { box-shadow: 0 0 0 9999px rgba(6, 7, 12, 0.58); }
}
