/*
 * Board Parlor tutorial kit: coach-mark overlay and first-visit chip. Pair with tutorial.js.
 * Theme it per game by setting these on :root in the game's style.css (all optional):
 *   --tut-accent       ring, Next button, marks          --tut-accent-ink  text on the accent
 *   --tut-bubble       bubble background                  --tut-ink         bubble text
 *   --tut-muted        counter, Skip, secondary text      --tut-dim         dimmed page around the spotlight
 *   --tut-ring         spotlight ring (defaults to the accent)
 *   --tut-font         font stack (defaults to the page's) --tut-z          overlay stacking level (default 1000)
 *   --tut-chip-z       first-visit chip level (default 12: under game menus/dialogs, which start at 15–20)
 */
.tut-layer {
  position: fixed; inset: 0; z-index: var(--tut-z, 1000);
  pointer-events: none;           /* taps reach the page; tutorial.js filters them */
  font: 15px/1.4 var(--tut-font, inherit);
  -webkit-tap-highlight-color: transparent;
}
.tut-spot {
  position: fixed; left: 0; top: 0; width: 0; height: 0;
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--tut-ring, var(--tut-accent, #f2b33d)), 0 0 0 200vmax var(--tut-dim, rgba(16, 12, 24, .55));
  transition: transform .3s cubic-bezier(.3, .7, .3, 1), width .3s cubic-bezier(.3, .7, .3, 1), height .3s cubic-bezier(.3, .7, .3, 1),
    box-shadow .25s ease, border-radius .3s;
  pointer-events: none;
}
.tut-spot::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit;
  border: 2px solid var(--tut-ring, var(--tut-accent, #f2b33d));
  animation: tut-ring 1.8s ease-out infinite;
}
.tut-nospot .tut-spot { box-shadow: 0 0 0 0 transparent, 0 0 0 200vmax var(--tut-dim, rgba(16, 12, 24, .55)); }
.tut-nospot .tut-spot::after, .tut-busy .tut-spot::after { display: none; }
.tut-busy .tut-spot { box-shadow: 0 0 0 0 transparent, 0 0 0 200vmax transparent; }
.tut-spot.tut-ping::after { animation: tut-ping .5s ease-out 2, tut-ring 1.8s ease-out 1s infinite; }

.tut-bubble {
  position: fixed; left: 0; top: 0;
  box-sizing: border-box;
  width: max-content; min-width: min(250px, calc(100vw - 24px)); max-width: min(340px, calc(100vw - 24px));
  padding: 14px 16px 8px; border-radius: 16px;
  background: var(--tut-bubble, #fffdf8); color: var(--tut-ink, #2b2320);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .14);
  pointer-events: auto; outline: none;
  transition: opacity .22s ease, transform .3s cubic-bezier(.3, .7, .3, 1);
}
.tut-bubble:focus, .tut-bubble:focus-visible { outline: none; }  /* focus anchor for screen readers only */
.tut-bubble.tut-hide { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s ease, visibility 0s .15s; }
.tut-bubble.tut-shake { animation: tut-shake .38s ease; }
.tut-arrow {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: var(--tut-bubble, #fffdf8); transform: rotate(45deg); border-radius: 3px;
  display: none;
}
.tut-bubble[data-side="below"] .tut-arrow { display: block; top: 0; }
.tut-bubble[data-side="above"] .tut-arrow { display: block; top: 100%; }
.tut-bubble[data-side="right"] .tut-arrow { display: block; left: 0; margin: -7px 0 0 -7px; }
.tut-bubble[data-side="left"] .tut-arrow { display: block; left: 100%; margin: -7px 0 0 -7px; }
.tut-text { position: relative; margin: 0; font-size: 16px; font-weight: 600; line-height: 1.38; }
.tut-sub { margin: 4px 0 0; font-size: 14px; color: var(--tut-muted, #7b6f66); }
.tut-sub:empty, .tut-nudge:empty { display: none; }
.tut-nudge { margin: 6px 0 0; font-size: 13.5px; font-weight: 600; color: var(--tut-accent-deep, var(--tut-muted, #7b6f66)); }
.tut-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.tut-count { flex: 1; font-size: 13px; color: var(--tut-muted, #7b6f66); font-variant-numeric: tabular-nums; }
.tut-foot button {
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 650; touch-action: manipulation;
}
.tut-skip { background: transparent; color: var(--tut-muted, #7b6f66); }
.tut-skip:hover { text-decoration: underline; }
.tut-next { background: var(--tut-accent, #f2b33d); color: var(--tut-accent-ink, #2b1d06); padding: 0 18px; }
.tut-foot button:focus { outline: none; }
.tut-foot button:focus-visible { outline: 2px solid var(--tut-ink, #2b2320); outline-offset: 2px; }
.tut-foot button[hidden] { display: none; }
.tut-mark { display: none; }

/* the closing card */
.tut-bubble.tut-final { text-align: center; padding: 22px 22px 16px; min-width: min(290px, calc(100vw - 24px)); }
.tut-final .tut-mark {
  display: block; width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--tut-accent, #f2b33d); position: relative;
  animation: tut-pop .4s cubic-bezier(.3, 1.6, .5, 1);
}
.tut-final .tut-mark::after {
  content: ""; position: absolute; left: 16px; top: 10px; width: 10px; height: 19px;
  border: solid var(--tut-accent-ink, #2b1d06); border-width: 0 4px 4px 0; transform: rotate(45deg);
}
.tut-final .tut-text { font-size: 21px; font-weight: 800; }
.tut-final .tut-foot { justify-content: center; margin-top: 14px; }
.tut-final .tut-count { display: none; }
.tut-final .tut-next { min-width: 150px; min-height: 46px; font-size: 16px; }

/* first-visit chip */
.tut-chip {
  position: fixed; z-index: var(--tut-chip-z, 12);  /* above the page, under the game's own menus and dialogs */ left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; max-width: calc(100vw - 24px);
  padding: 3px 3px 3px 4px; border-radius: 999px;
  background: var(--tut-bubble, #fffdf8); color: var(--tut-ink, #2b2320);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22), 0 1px 3px rgba(0, 0, 0, .12);
  font: 14px/1.2 var(--tut-font, inherit);
  animation: tut-chip-in .4s ease-out;
}
.tut-chip button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
.tut-chip-go { min-height: 40px; padding: 0 8px 0 12px; font-weight: 650; white-space: nowrap; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; }
.tut-chip-go::before {
  content: "?"; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%; font-size: 13px; font-weight: 800;
  background: var(--tut-accent, #f2b33d); color: var(--tut-accent-ink, #2b1d06);
}
.tut-chip-x { width: 40px; height: 40px; border-radius: 50%; font-size: 20px !important; line-height: 1; color: var(--tut-muted, #7b6f66) !important; }
.tut-chip button:hover { background: rgba(127, 127, 127, .12); }
.tut-chip button:focus-visible { outline: 3px solid var(--tut-accent, #f2b33d); outline-offset: 1px; }

@keyframes tut-ring { 0% { opacity: .9; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(1.08); } }
@keyframes tut-ping { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.18); } }
@keyframes tut-shake { 0%, 100% { translate: 0; } 25% { translate: -5px 0; } 60% { translate: 4px 0; } }
@keyframes tut-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tut-chip-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) {
  .tut-spot, .tut-bubble { transition: opacity .2s !important; }
  .tut-spot::after, .tut-bubble.tut-shake, .tut-final .tut-mark, .tut-chip { animation: none !important; }
}
