/* Exit Code Zero v4: goal line and tracker, the speech bubble, the coach ring.
   Owner: rounds. Uses the shared tokens from styles.css with fallbacks. */

/* ---------- goal line with the nine-round tracker ---------- */
#goal {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 140px);
  padding: 9px 18px 9px 14px;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line, rgba(15, 15, 15, .07));
  border-radius: var(--r-pill, 999px);
  box-shadow: 0 10px 30px -14px rgba(15, 61, 44, .35);
  white-space: nowrap;
  pointer-events: none;
  color: var(--ink, #0f0f0f);
}
#goal .sep { flex: none; width: 1px; height: 20px; background: #e3e9e6; }
#goal .txt { font: 400 13px/1 var(--mono, 'Geist Mono', ui-monospace, monospace); color: #3d4542; overflow: hidden; text-overflow: ellipsis; }
#goal .txt b { font-weight: 600; color: var(--ink, #0f0f0f); }
#goal .gs { font: 500 14px/1 var(--sans, 'Inter', system-ui, sans-serif); letter-spacing: -.1px; color: var(--ink, #0f0f0f); }
#goal .cw { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink, #0f0f0f); }
#goal .cw i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
#goal .short { display: none; }

#goal .trk { flex: none; display: flex; align-items: center; gap: 10px; }
#goal .trk .g { display: flex; align-items: center; gap: 4px; }
#goal .trk .gi { width: 15px; height: 15px; margin-right: 2px; fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#goal .trk .seg { width: 18px; height: 6px; border-radius: 999px; background: #e3e8e5; transition: width .3s ease, background-color .3s ease; }
#goal .trk .seg.done { background: var(--mint, #12e29d); }
#goal .trk .seg.now { width: 30px; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }

/* ---------- the one speech bubble ---------- */
#bubble.bubble {
  position: fixed;
  left: 28px;
  bottom: var(--bubble-bottom, 28px);
  z-index: 40;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  max-width: min(600px, calc(100vw - 56px));
  padding: 16px 20px 16px 16px;
  background: #fff;
  border: 1px solid var(--line, rgba(15, 15, 15, .07));
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(15, 61, 44, .12);
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .16s ease, transform .16s ease;
}
#bubble.bubble.swap { opacity: 0; transform: translateY(4px); }
#bubble .disc {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 14px/1 var(--sans, 'Inter', system-ui, sans-serif);
  background: #e6e9e8;
  color: var(--ink, #0f0f0f);
}
#bubble .disc-mint { background: var(--mint, #12e29d); color: #04281b; }
#bubble .bw { min-width: 0; }
#bubble .who { font: 600 14px/1.2 var(--sans, 'Inter', system-ui, sans-serif); color: var(--ink, #0f0f0f); }
#bubble .who b { font-weight: 600; }
#bubble .who .role { font: 400 11px/1.2 var(--mono, 'Geist Mono', ui-monospace, monospace); color: var(--grey, #636363); margin-left: 6px; }
#bubble .say { margin: 5px 0 0; font: 500 18px/1.4 var(--sans, 'Inter', system-ui, sans-serif); letter-spacing: -.01em; color: var(--ink, #0f0f0f); }
#bubble .say .s { display: none; }

/* title placement: under the hero, above the credit */
#bubble.bubble[data-place="title"] { left: 40px; bottom: 66px; max-width: min(520px, calc(100vw - 80px)); z-index: 70; }
#bubble.bubble[data-place="title"] .say { font-size: 17px; }

/* ---------- the coach ring (the only pulse on screen) ---------- */
#coach {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  box-sizing: border-box;
  border: 3px solid var(--mint, #12e29d);
  border-radius: 999px;
  pointer-events: none;
  will-change: transform;
  animation: ecz-coach 1.6s ease-out infinite;
}
#coach.still { animation: none; box-shadow: 0 0 0 6px rgba(18, 226, 157, .22); }
@keyframes ecz-coach {
  0% { box-shadow: 0 0 0 0 rgba(18, 226, 157, .45); }
  70% { box-shadow: 0 0 0 12px rgba(18, 226, 157, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 226, 157, 0); }
}
@media (prefers-reduced-motion: reduce) {
  #coach { animation: none; box-shadow: 0 0 0 6px rgba(18, 226, 157, .22); }
  #bubble.bubble { transition: none; }
}

/* round 1, first two steps: the rest of the card steps back */
#card .coach-dimmed { opacity: .7; transition: opacity .2s ease; }

/* ---------- narrow: below 760 px ---------- */
@media (max-width: 759.98px) {
  #goal {
    left: 12px;
    right: 62px;
    top: calc(12px + env(safe-area-inset-top, 0px));
    transform: none;
    max-width: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    border-radius: 18px;
    padding: 10px 14px;
    white-space: normal;
  }
  #goal .sep { display: none; }
  #goal .long { display: none; }
  #goal .short { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* guide.js fitGoal: a goal that would end in an ellipsis drops its chapter tag, then wraps if it must */
  #goal[data-tight] .short .cwrap { display: none; }
  #goal[data-tight="2"] .short { white-space: normal; line-height: 1.3; }
  #goal .trk { gap: 8px; }
  #goal .trk .seg { width: 16px; }
  #goal .trk .seg.now { width: 26px; }

  #bubble.bubble {
    left: 16px;
    right: 16px;
    bottom: var(--bubble-bottom, 12px);
    max-width: none;
    padding: 10px 14px 10px 12px;
    gap: 10px;
    border-radius: 16px;
  }
  #bubble .disc { width: 34px; height: 34px; font-size: 12px; }
  #bubble .who .role { margin-left: 6px; }
  #bubble .say { margin-top: 3px; line-height: 1.35; }
  #bubble .who .co { display: none; }
  #bubble .say { font-size: 15px; }
  #bubble .say .l { display: none; }
  #bubble .say .s { display: inline; }

  #bubble.bubble[data-place="title"] { left: 12px; right: 12px; bottom: 64px; max-width: none; }
  #bubble.bubble[data-place="title"] .role { display: none; }
  #bubble.bubble[data-place="title"] .say { font-size: 15px; }
  #bubble .who .role { font-size: 12px; }

  /* docked: during a round the bubble is the sheet's first row, flush on its top edge (guide.js position) */
  #bubble.bubble.docked {
    left: 0;
    right: 0;
    bottom: var(--bubble-bottom, 0px);
    padding: 12px 16px 10px 14px;
    border: 1px solid #dfeae5;
    border-bottom: 1px solid #e6eeea;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(15, 61, 44, .14);
  }
}
/* short narrow screens (a phone browser with its toolbars, an in-app viewer): a one line goal with a slim
   tracker under it, and a more compact bubble, so the island keeps its band */
@media (max-width: 759.98px) and (max-height: 719.98px) {
  #goal { top: calc(8px + env(safe-area-inset-top, 0px)); padding: 8px 12px 9px; gap: 7px; border-radius: 16px; }
  #goal .trk { order: 2; gap: 6px; }
  #goal .trk .gi { display: none; }
  #goal .trk .g { gap: 3px; }
  #goal .trk .seg { height: 4px; width: 14px; }
  #goal .trk .seg.now { width: 22px; box-shadow: none; }
  #goal .txt { order: 1; }
  #bubble .disc { width: 30px; height: 30px; font-size: 12px; }
  #bubble.bubble.docked { padding: 10px 14px 9px 12px; gap: 9px; }
  #bubble .say { font-size: 14.5px; margin-top: 2px; line-height: 1.32; }
  #bubble.bubble[data-place="title"] { bottom: 58px; padding: 9px 12px 9px 10px; }
  #bubble.bubble[data-place="title"] .say { font-size: 14.5px; }
}
@media (max-width: 359.98px) {
  #goal .trk .seg { width: 12px; }
  #goal .trk .seg.now { width: 20px; }
}
