/* Dialogue (js/dialogue.js): navy speech bubble anchored above the speaking NPC (.dlg.dlg-bubble), or a compact centred
   box near the bottom for signs / narration (.dlg.dlg-box). Uses the HUD tokens from style.css with fallbacks. */
.dlg {
  --dlg-bg: linear-gradient(#1b3f86, #0f2148);
  --dlg-edge: var(--border-hi, #6fa6ff);
  --dlg-tail-bg: #12295a;
  position: fixed; z-index: 8; box-sizing: border-box;
  min-width: 200px; max-width: min(380px, calc(calc(100 * var(--uvw, 1vw)) - 32px)); padding: 10px 16px 8px;
  background: var(--dlg-bg);
  border: 2px solid var(--dlg-edge); border-radius: 14px;
  box-shadow: 0 0 0 2px #0a1630, inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 22px rgba(0, 0, 0, .45);
  color: var(--text, #f4f7ff); font-family: Nunito, system-ui, sans-serif;
  font-size: 16px; font-weight: 800; line-height: 1.4; letter-spacing: .2px; text-align: left;
  opacity: 0; pointer-events: none; transition: opacity .15s; cursor: pointer; user-select: none;
}
.dlg.open { opacity: 1; pointer-events: auto; }

/* narration / signs / speakers that aren't on screen: compact box, bottom centre */
.dlg.dlg-box { left: 50%; bottom: 26px; transform: translateX(-50%); width: max-content; max-width: min(560px, calc(calc(100 * var(--uvw, 1vw)) - 32px)); min-width: 280px; }
.dlg.dlg-box .dlg-tail { display: none; }
.dlg.sign { --dlg-bg: linear-gradient(#3e3322, #241c10); --dlg-edge: #d8b25a; --dlg-tail-bg: #2e2416; }

/* speech bubble: left/top set every frame by Dialogue.update() */
.dlg.dlg-bubble { width: max-content; }
.dlg[data-kind="player"], .dlg[data-kind="sys"] { --dlg-edge: #9cd2ff; }

.dlg-name {
  display: block; margin-bottom: 1px; color: var(--gold, #ffcf4a); font-size: 14px; font-weight: 900; letter-spacing: .6px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .45);
}
.dlg-name[data-color="female"] { color: #ffb3c8; }
.dlg-name[hidden], .dlg-yesno[hidden], .dlg-choices[hidden] { display: none; }

.dlg-text { white-space: pre-line; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); overflow-wrap: anywhere; }
.dlg-rest { visibility: hidden; }
.dlg-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.dlg-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px; height: 18px; margin-top: 2px;
  color: #c8d8ff; font-size: 12px; font-weight: 800; opacity: 0; transition: opacity .12s;
}
.dlg-foot.show { opacity: 1; }
.dlg-next { color: var(--gold, #ffcf4a); font-size: 13px; }
.dlg-foot.show .dlg-next { animation: dlg-bob .7s ease-in-out infinite; }
@keyframes dlg-bob { 50% { transform: translateY(3px); } }

/* tail: a rotated square straddling the bottom edge (top edge when .flip), x set by Dialogue.update() */
.dlg-tail {
  position: absolute; top: 100%; left: 50%; width: 16px; height: 16px; margin: -8px 0 0 -9px;
  background: var(--dlg-tail-bg); border: solid var(--dlg-edge); border-width: 0 2px 2px 0;
  transform: rotate(45deg); box-shadow: 3px 3px 0 -1px #0a1630;
}
.dlg.flip .dlg-tail { top: auto; bottom: 100%; margin: 0 0 -8px -9px; border-width: 2px 0 0 2px; box-shadow: -3px -3px 0 -1px #0a1630; background: #1b3f86; }

/* YES / NO and choice lists float next to the bubble (positioned by Dialogue._dock) */
.dlg-yesno, .dlg-choices {
  position: fixed; z-index: 9; left: 0; top: 0; display: flex; flex-direction: column; gap: 3px; padding: 6px;
  max-height: calc(50 * var(--uvh, 1vh)); overflow: auto;
  background: linear-gradient(#1b3f86, #0f2148); border: 2px solid var(--border-hi, #6fa6ff); border-radius: 12px;
  box-shadow: 0 0 0 2px #0a1630, 0 6px 18px rgba(0, 0, 0, .4);
}
.dlg-yesno button, .dlg-choices button {
  display: flex; align-items: center; gap: 6px; min-width: 96px; padding: 5px 12px 5px 6px; border: 2px solid transparent; border-radius: 8px;
  background: none; color: var(--text, #f4f7ff); font: 900 16px Nunito, system-ui, sans-serif; text-align: left; cursor: pointer;
}
.dlg-yesno button::before, .dlg-cur { content: '▶'; color: var(--gold, #ffcf4a); font-size: 12px; visibility: hidden; }
.dlg-yesno button.sel::before, .dlg-choices button.sel .dlg-cur { visibility: visible; }
.dlg-yesno button.sel, .dlg-choices button.sel { border-color: var(--gold, #ffcf4a); background: rgba(255, 207, 74, .14); }
.dlg-yesno button:focus-visible, .dlg-choices button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ambient NPC chatter / online-player chat bubbles (Trainer.say → .bubble, style.css): same navy look */
.bubble {
  background: linear-gradient(#1b3f86, #0f2148); color: var(--text, #f4f7ff); font-family: Nunito, system-ui, sans-serif;
  font-size: 14px; font-weight: 800; line-height: 1.35; padding: 6px 12px; border-radius: 12px; max-width: 240px;
  border: 2px solid var(--border-hi, #6fa6ff); box-shadow: 0 0 0 2px #0a1630, 0 6px 14px rgba(0, 0, 0, .4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
.bubble::after {
  left: 50%; bottom: -7px; width: 10px; height: 10px; margin-left: -6px; border: solid var(--border-hi, #6fa6ff);
  border-width: 0 2px 2px 0; background: #11275a; transform: rotate(45deg);
}

@media (max-width: 760px) {
  .dlg { font-size: 15px; padding: 9px 12px 7px; }
  .dlg.dlg-box { bottom: 12px; min-width: 0; width: calc(calc(100 * var(--uvw, 1vw)) - 32px); }
  .dlg-yesno button, .dlg-choices button { font-size: 15px; min-width: 80px; }
}
/* phones (js/dialogue.js compact()): the box sits at the bottom over the stick / A button (a tap anywhere advances),
   never up over the quest card or minimap; YES / NO are two big buttons side by side right above it */
.dlg.dlg-box.dlg-compact { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); width: min(560px, calc(calc(100 * var(--uvw, 1vw)) - 24px)); min-width: 0; min-height: 84px; }
.dlg-yesno.dlg-compact { flex-direction: row; gap: 8px; padding: 6px; box-sizing: border-box; }
.dlg-yesno.dlg-compact button { flex: 1 1 0; justify-content: center; min-height: 52px; padding: 6px 10px; font-size: 18px; text-align: center; }
.dlg-yesno.dlg-compact button::before { display: none; }
.dlg-yesno.dlg-compact button[data-v="1"] { order: 2; background: linear-gradient(var(--gold, #ffcf4a), var(--gold-2, #f3a51e)); color: #3a2400; }   /* YES on the right, under the thumb */
.dlg-choices.dlg-compact { min-width: calc(52 * var(--uvw, 1vw)); max-width: calc(calc(100 * var(--uvw, 1vw)) - 24px); }
.dlg-choices.dlg-compact button { min-height: 48px; font-size: 16px; }
@media (prefers-reduced-motion: reduce) {
  .dlg-foot.show .dlg-next { animation: none; }
  .dlg { transition: none; }
}

/* ---------------------------------------------------------------- Nurse Joy's desk (js/pokecenter.js)
   One sheet at the bottom, in thumb reach: her line, the team with its HP, two big buttons. Same navy as the bubble. */
.pkc {
  position: fixed; z-index: 9; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: min(460px, calc(calc(100 * var(--uvw, 1vw)) - 24px)); box-sizing: border-box;
  transform: translate(-50%, 24px); opacity: 0; transition: opacity .18s, transform .22s var(--ease, ease-out);
  font-family: Nunito, system-ui, sans-serif; color: var(--text, #f4f7ff);
}
.pkc.open { transform: translate(-50%, 0); opacity: 1; }
.pkc-card {
  padding: 12px 14px 14px; border-radius: 16px;
  background: linear-gradient(#1b3f86, #0f2148); border: 2px solid #ffb3c8;
  box-shadow: 0 0 0 2px #0a1630, inset 0 0 0 1px rgba(255, 255, 255, .08), 0 10px 28px rgba(0, 0, 0, .5);
}
.pkc-name { color: #ffb3c8; font-size: 14px; font-weight: 900; letter-spacing: .6px; text-shadow: 0 2px 0 rgba(0, 0, 0, .45); }
.pkc-line { margin: 2px 0 10px; font-size: 16px; font-weight: 800; line-height: 1.4; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.pkc-line b { color: var(--ok, #3ee07a); }
.pkc-team { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.pkc-mon { display: grid; justify-items: center; gap: 4px; padding: 4px 2px 6px; border-radius: 10px; background: rgba(255, 255, 255, .07); }
.pkc-pic { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; max-width: 52px; }
.pkc-pic img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); }
.pkc-mon.fainted .pkc-pic img { filter: grayscale(1) brightness(.7); }
.pkc-mon.egg { opacity: .7; }
.pkc-hp { display: block; width: 84%; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.pkc-hp > i { display: block; height: 100%; background: var(--hp, #3ee07a); border-radius: 3px; transition: width .6s var(--ease, ease-out); }
.pkc-hp.mid > i { background: #ffcf4a; }
.pkc-hp.low > i { background: #ff5f6b; }
/* the heal: each Pokémon becomes a glowing ball for a moment, one after another, then the team sparkles */
.pkc-ball { position: absolute; inset: 18%; border-radius: 50%; opacity: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fff 0 18%, transparent 19%), linear-gradient(#ff6b8b 0 47%, #2a1030 47% 53%, #fff 53%);
  box-shadow: 0 0 14px 4px rgba(255, 179, 200, .8); }
.pkc.healing .pkc-pic img { animation: pkc-in .35s calc(var(--i) * .11s) both; }
.pkc.healing .pkc-ball { animation: pkc-ball .9s calc(var(--i) * .11s) both; }
.pkc.healed .pkc-mon { animation: pkc-glow .7s both; }
@keyframes pkc-in { to { transform: scale(.4); opacity: 0; } }
@keyframes pkc-ball { 0% { opacity: 0; transform: scale(.4); } 30%, 80% { opacity: 1; transform: scale(1); } 100% { opacity: 1; filter: brightness(1.6); } }
@keyframes pkc-glow { 0% { background: rgba(255, 179, 200, .55); box-shadow: 0 0 16px rgba(255, 179, 200, .7); } 100% { background: rgba(255, 255, 255, .07); } }
.pkc-acts { display: flex; gap: 10px; }
.pkc-acts .btn { flex: 1 1 0; min-height: 52px; font-size: 17px; font-weight: 900; border-radius: 14px; }
.pkc-acts .pkc-no { flex: .7 1 0; }
@media (max-height: 500px) {   /* phone landscape: a low, wide sheet; the team and the buttons share one row */
  .pkc { width: min(680px, calc(calc(100 * var(--uvw, 1vw)) - 24px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
  .pkc-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 8px 12px 10px; }
  .pkc-name, .pkc-line { grid-column: 1 / -1; }
  .pkc-line { font-size: 15px; margin-bottom: 6px; }
  .pkc-team { margin: 0; gap: 4px; }
  .pkc-pic { max-width: 34px; }
  .pkc-acts { grid-column: 2; width: min(300px, calc(44 * var(--uvw, 1vw))); }
  .pkc-team + .pkc-acts { grid-column: 2; }
  .pkc-acts:only-child, .pkc-line + .pkc-acts { grid-column: 1 / -1; width: auto; }
  .pkc-acts .btn { min-height: 46px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .pkc, .pkc-hp > i { transition: none; }
  .pkc.healing .pkc-pic img, .pkc.healing .pkc-ball, .pkc.healed .pkc-mon { animation: none; }
}
body:has(.pkc) #update-pill { display: none; }   /* the "new update" pill waits until the desk is closed (it sat on the sheet) */
