/* ============================================================================
   DRILL MANUAL — first-time experience chrome        prom/css/drill-manual.css
   ============================================================================
   The look for the three FTUE engines every drill shares:
     · the ? button (.dm-help) that mountDrill puts in every drill's chrome
     · the TUTORIAL coach layer (.tut-*) — the dim, the gold ring, the pointer
       hints, the host's card
     · the GOAL chip and verdict (.dk-goal*) — "顾客 3/6" and the end-of-drill
       win/lose call against the goal the drill stated up front
   JS: prom/js/drills/manual.js + tutorial.js; goalHTML/goalTick in minigames.js.

   Loaded AFTER drill-kit.css and leans on its tokens (--dk-*). Materials here
   are the kit's materials — cream stock, ink line, night lacquer — which are
   THEME-STABLE by design, so both themes are already handled; nothing in this
   file reads a theme-sensitive token for a surface that carries text.
   Type stays on the kit's four roles: hanzi ≥ 20px, Latin/support ≥ 16px. Every animation dies under reduced motion and
   no STATE lives only in a motion.
   ========================================================================= */

/* ------------------------------------------------------------ the ? button
   Quiet, always in the same corner of every drill, drawn not typed. Its own
   z-index (above play, below the book) also keeps PROM.uiCheck honest. */
.minigame .dm-help {
  position: fixed; top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: var(--prom-target-min, 44px); height: var(--prom-target-min, 44px); padding: 0;
  background: transparent; border: 0; cursor: pointer;
  /* above the tutorial's shades (70) — "always visible" includes mid-walkthrough,
     where the ? is the door back to the manual — and under the open book (80) */
  z-index: 76; opacity: 0.82;
  transition: opacity 0.12s, transform 0.12s;
}
.minigame .dm-help svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 0 rgba(14, 6, 24, 0.6)); }
.minigame .dm-help:hover { opacity: 1; transform: translateY(-1px); }
.minigame .dm-help:focus-visible { opacity: 1; outline: 3px solid var(--dk-gold, #ffc84a); outline-offset: 2px; border-radius: 999px; }
/* ------------------------------------------------- the 试玩 escape hatch
   Second coin in the same corner, docked rather than floating — see the long
   note over ensurePlaytestExit in game.js for why it left the bottom-left
   (measured: it was taking the tap in eight of thirteen drills, four of them
   the tutorial's own 下一步). It is chrome, so like the ? its position and its
   layer live here and its markup lives in JS.
   z-index 81, one above the book (80) and five above the ?: an escape hatch a
   modal can cover is not an escape hatch, and this is the one control that has
   to survive every layer a drill can raise. Under the iris (90), which is a
   pointer-transparent scene wipe. */
.minigame > .dk-playtest {
  position: fixed; top: max(10px, env(safe-area-inset-top));
  right: calc(max(10px, env(safe-area-inset-right)) + 52px);
  width: var(--prom-target-min, 44px); height: var(--prom-target-min, 44px); padding: 0;
  background: transparent; border: 0; cursor: pointer;
  z-index: 81; opacity: 0.82;
  transition: opacity 0.12s, transform 0.12s;
}
/* a drill that has not landed its FTUE yet shows no ?, so the hatch simply
   takes the corner rather than leaving a 46px hole where a coin isn't */
.minigame:not(.has-manual) > .dk-playtest { right: max(10px, env(safe-area-inset-right)); }
.minigame > .dk-playtest svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 0 rgba(14, 6, 24, 0.6)); }
.minigame > .dk-playtest:hover { opacity: 1; transform: translateY(-1px); }
.minigame > .dk-playtest:focus-visible { opacity: 1; outline: 3px solid var(--dk-gold, #ffc84a); outline-offset: 2px; border-radius: 999px; }
/* The head chrome clears the corner the coin lives in. This used to be scoped
   to max-width:760px on the assumption that only a phone head could grow far
   enough right to reach the ? — untrue once the goal chip landed: lyric's head
   ("唱好 0/5 sung well") reaches x=1250 at 1280 and collided with the coin by
   20x8px. The head is centred with translateX(-50%), so the reserved gutter
   shifts its content left by half of 46px, which is imperceptible and cheap
   compared with a ? disc hanging off the head plate's corner.
   !important, and not by preference: several drills set their light-theme head
   with the `padding` SHORTHAND at a higher specificity
   (:root[data-theme="light"] .minigame.rush2 > .mg-head { padding: 2px 13px 3px }
   — same in haggle2, and the same shape in clinic and history), which silently
   resets this gutter to 13px. That is how the coin ended up sitting on the
   score line in light theme at 375px on exactly those four drills and nowhere
   else. The corner the coin lives in is a kit-wide invariant; a drill choosing
   its own head padding must not be able to reclaim it by accident. */
.minigame.has-manual .mg-head { padding-right: 52px !important; }
/* …and 46 more when the 试玩 hatch is docked beside it. THIS RULE IS THE WHOLE
   POINT of docking it: the gutter is what makes the overlap impossible, so the
   gutter has to know there are two coins in the corner now. :has() rather than
   a class because game.js appends the button from the overlay watcher and the
   head must widen on the same frame, whoever mounted first. Same !important as
   its twin above, and for the same reason — several drills set their head
   padding with the SHORTHAND at a higher specificity. */
.minigame.has-manual:has(> .dk-playtest) .mg-head { padding-right: 104px !important; }
.minigame:not(.has-manual):has(> .dk-playtest) .mg-head { padding-right: 52px !important; }
/* …and a matching gutter on the LEFT, because Settings now floats over the
   board too (Lau: "settings should be accessible everywhere and anytime").
   The gear crosses to the left corner while a drill is up so it does not fight
   the ?, but on a phone the head is 96vw and spans the whole top edge, so it
   collided there instead — rush's 对 0/4 chip and stream's title, measured by
   ftue-hud at 375 in both themes. The head is centred with translateX(-50%),
   so a symmetric pair of gutters keeps it centred and simply narrows it.
   Same !important as its twin above, and for the same reason: several drills
   set their head padding with the SHORTHAND at a higher specificity and would
   otherwise silently reclaim the corner. */
body:has(.global-gear) .minigame .mg-head { padding-left: 52px !important; }

/* --------------------------------------------------------- the coach layer */
.tut-layer { position: absolute; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.tut-layer.hushed, .tut-card.hushed { visibility: hidden; }
.minigame.tut-reserved { top: var(--tut-reserve); }
.minigame.tut-reserved::before { content: ""; position: fixed; top: 0; left: 0; right: 0;
  height: var(--tut-reserve); background: #191026; pointer-events: none; z-index: 69; }
.tut-card.reserved { position: fixed; z-index: 70; }
.tut-layer.out { opacity: 0; transition: opacity 0.35s; }
.tut-ring {
  position: absolute; pointer-events: none; border-radius: 12px;
  border: 3px solid var(--dk-gold, #ffc84a);
  box-shadow: 0 0 0 3px rgba(255, 200, 74, 0.35), 0 0 20px rgba(255, 200, 74, 0.4);
  animation: tutPulse 1.4s ease-in-out infinite;
}
.tut-ring.done { border-color: var(--dk-jade, #3ee6c4); box-shadow: 0 0 0 3px rgba(62, 230, 196, 0.4), 0 0 20px rgba(62, 230, 196, 0.45); animation: none; }
@keyframes tutPulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 200, 74, 0.35), 0 0 20px rgba(255, 200, 74, 0.4); } 50% { box-shadow: 0 0 0 6px rgba(255, 200, 74, 0.2), 0 0 26px rgba(255, 200, 74, 0.55); } }

/* pointer hints — drawn gestures, centred on the target */
.tut-hint { position: absolute; pointer-events: none; width: 0; height: 0; }
.tut-hint.tap i {
  position: absolute; left: 0; top: 0; width: 46px; height: 46px; border-radius: 999px;
  border: 3px solid var(--dk-gold, #ffc84a); transform: translate(-50%, -50%);
  animation: tutRipple 1.3s ease-out infinite; opacity: 0;
}
.tut-hint.tap i:nth-child(2) { animation-delay: 0.45s; }
@keyframes tutRipple { 0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.45); } 80% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } 100% { opacity: 0; } }
.tut-fingertip {
  position: absolute; left: 0; top: 0; width: 15px; height: 15px; border-radius: 999px;
  background: var(--dk-gold, #ffc84a); border: 2.5px solid var(--dk-ink, #241335);
  transform: translate(-50%, -50%); animation: tutTapDot 1.3s ease-out infinite;
}
@keyframes tutTapDot { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 12% { transform: translate(-50%, -50%) scale(0.72); } 26% { transform: translate(-50%, -50%) scale(1); } }
.tut-hint.hold svg { position: absolute; left: 0; top: 0; width: 52px; height: 52px; transform: translate(-50%, -50%) rotate(-90deg); }
.tut-hold-track { fill: none; stroke: rgba(242, 239, 233, 0.4); stroke-width: 5; }
.tut-hold-fill {
  fill: none; stroke: var(--dk-gold, #ffc84a); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 100; animation: tutHold 1.5s linear infinite;
}
@keyframes tutHold { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.tut-hint.drag svg { position: absolute; left: 0; top: 0; overflow: visible; }
.tut-drag-line {
  fill: none; stroke: var(--dk-gold, #ffc84a); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 3 9; filter: drop-shadow(0 1.5px 0 rgba(14, 6, 24, 0.7));
}
.tut-drag-bead { fill: var(--dk-gold, #ffc84a); stroke: var(--dk-ink, #241335); stroke-width: 2; }

/* Opaque correspondence note; only its own controls receive pointer events. */
.tut-card {
  position: absolute; display: flex; flex-direction: column; gap: 8px;
  background: #21172d; color: #f2efe9; border: 1px solid #8a7b9c;
  border-radius: 12px; padding: 12px; pointer-events: auto;
  max-width: calc(100% - 16px); overflow: hidden;
}
.tut-card.compact { flex-direction: row; align-items: center; padding: 8px; }
.tut-card.compact .tut-en { flex: 1; max-height: 52px; }
.tut-card.compact .tut-btns { margin: 0; flex-wrap: nowrap; }
.tut-card.compact .tut-btns button { padding: 4px; }
.tut-card .tut-en { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #8a7b9c #21172d; min-height: 0; overscroll-behavior: contain; }
.tut-card button:focus-visible { outline: 3px solid var(--dk-gold); outline-offset: -3px; }
@keyframes dmPop { from { opacity: 0; } to { opacity: 1; } }
.tut-en { margin: 0; font-size: var(--dk-label, 16px); font-weight: 650; line-height: 1.4; color: #d6cce0; }
.tut-en:empty { display: none; }
.tut-btns { display: flex; flex: none; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 5px; }
.tut-btns button {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; gap: 8px; cursor: pointer;
  background: transparent; border-radius: 999px; padding: 4px 14px;
  font-size: var(--dk-label, 16px); font-weight: 700;
}
/* display:inline-flex above would defeat the UA's [hidden] — restate it, or
   明白了 outlives its observe step (caught by the first screenshot pass) */
.tut-btns button[hidden] { display: none; }
.tut-btns .han { font-family: var(--han, "PingFang SC", sans-serif); font-size: var(--dk-read, 20px); font-weight: 800; }
.tut-next { border: 2.5px solid var(--dk-gold, #ffc84a); color: var(--dk-gold, #ffc84a); }
/* THE EXIT IS NOT A SECOND PILL. It used to wear the same shape and the same
   size as 下一步 with a paler border — two matching buttons side by side, one of
   which quietly ends the walkthrough for good. Matching shapes say "these are
   two options of the same kind"; they are not. It reads as the aside it is:
   smaller, underlined like a link, no capsule competing with the real verb. */
.tut-skip {
  border: none; border-radius: 0; padding: 4px 2px;
  color: #d6cce0; opacity: 1;
  font-size: var(--dk-label, 16px); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(242, 239, 233, 0.38);
}
.tut-skip .han { font-size: var(--dk-label, 16px); font-weight: 700; }
.tut-skip:hover { color: var(--paper, #f2efe9); text-decoration-color: rgba(242, 239, 233, 0.75); }
.tut-next:hover { opacity: 1; filter: brightness(1.08); }
.tut-btns button:focus-visible { outline: 3px solid var(--dk-gold, #ffc84a); outline-offset: 2px; }

/* ------------------------------------------------- the goal chip + verdict */
/* NO .dk-goal-flag. The chip carried a 20x24 pennant rendered at 14x17; twelve
   of fifteen blind judges could not name it and eleven said it meant nothing.
   At ship size, inside a dense head line, it read as a rendering fault. The
   chip is type now — see goalHTML() in minigames.js for the full note. */
.dk-goal { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.dk-goal-zh { font-family: var(--han, "PingFang SC", sans-serif); font-size: var(--dk-read, 20px); font-weight: 800; }
.dk-goal-count { font-size: var(--dk-label, 16px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; display: inline-flex; align-items: baseline; }
.dk-goal-count i { font-style: normal; opacity: 0.6; padding: 0 1px; }
.dk-goal.met .dk-goal-n, .dk-goal.met .dk-goal-total { color: var(--dk-jade, #3ee6c4); }
.dk-goal-en { font-size: var(--dk-caption, 14px); font-weight: 700; opacity: 0.8; }
.dk-goal.tick .dk-goal-count { animation: dkGoalTick 0.45s ease-out; }
.dk-goal.flinch .dk-goal-count { animation: dkGoalFlinch 0.45s ease-out; }
@keyframes dkGoalTick { 30% { transform: translateY(-3px) scale(1.12); } 100% { transform: none; } }
@keyframes dkGoalFlinch { 25% { transform: translateX(-3px); } 55% { transform: translateX(3px); } 100% { transform: none; } }
/* the end-of-drill call against the stated goal: rides above the finale scrim,
   stays until the drill leaves the stage — never an auto-dismissing card */
.dk-goal-verdict {
  position: absolute; left: 50%; top: 15%; transform: translateX(-50%); z-index: 8;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  animation: dmPop 0.25s ease-out;
}
.dk-goal-verdict .dk-goal-verdict-zh { font-family: var(--han, "PingFang SC", sans-serif); font-size: var(--dk-display, 28px); font-weight: 900; line-height: 1.2; }
.dk-goal-verdict .dk-goal-verdict-en { font-size: var(--dk-label, 16px); font-weight: 700; color: var(--dk-ink-soft, rgba(36, 19, 53, 0.68)); }
.dk-goal-verdict.win { border-color: var(--dk-jade-deep, #0d6b57); }
.dk-goal-verdict.win .dk-goal-verdict-zh { color: var(--dk-jade-deep, #0d6b57); }
.dk-goal-verdict.lose .dk-goal-verdict-zh { color: var(--dk-verm-deep, #a8231a); }

/* ------------------------------------------------------------ still hands
   Motion off, information intact: the ripple parks as one visible ring, the
   hold ring parks half-filled, the drag keeps its arrow (the bead's SMIL node
   is simply not emitted — tutorial.js checks the same media query). */
@media (prefers-reduced-motion: reduce) {
  .tut-ring, .tut-layer.out, .dk-goal-verdict,
  .dk-goal.tick .dk-goal-count, .dk-goal.flinch .dk-goal-count { animation: none !important; transition: none !important; }
  .tut-hint.tap i { animation: none; opacity: 0.6; transform: translate(-50%, -50%) scale(1.15); }
  .tut-hint.tap i:nth-child(2) { display: none; }
  .tut-fingertip { animation: none; }
  .tut-hold-fill { animation: none; stroke-dashoffset: 45; }
}
