/* ============================================================
   The play shell — a bar that stays, and the game beneath it.
   Used both by the in-page #playShell in index.html (so Echo Show 10
   never drops Fullscreen or WakeLock) and by standalone play.html.
   Loaded after hub.css, which supplies the palette and type sets.
   ============================================================ */

body.playing {
  display: flex;
  flex-direction: column;
  block-size: 100dvh;
  overflow: clip;
  background: var(--paper);
}

/* In-page full-viewport game shell inside index.html */
.play-shell {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  block-size: 100dvh;
  inline-size: 100%;
  background: var(--paper);
}

.play-shell[hidden] {
  display: none;
}

.bar {
  flex: none;
  display: flex;
  align-items: safe center;
  justify-content: space-between;
  gap: clamp(0.5rem, 1.4dvw, 1.1rem);
  padding: 0 clamp(0.65rem, 1.6dvw, 1.25rem);
  block-size: clamp(54px, 8.2dvh, 68px);
  background: var(--paper);
  border-block-end: 2.2px solid var(--ink);
  box-shadow: 0 2px 0 rgb(61 55 44 / .16), 0 6px 14px rgb(61 55 44 / .16);
  position: relative;
  z-index: 2;
}

/* Big enough to hit without looking, small enough not to be the main event. */
.bar__home {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  min-block-size: 46px;
  padding: .3em .9em .3em .7em;
  border: 2.2px solid var(--ink);
  border-radius: 14px 10px 13px 11px;
  background: var(--butter);
  box-shadow: 0 2px 0 rgb(61 55 44 / .22), 0 5px 9px rgb(61 55 44 / .26);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 0.5rem + 1.2dvh, 1.25rem);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .18s cubic-bezier(.2,.9,.3,1.2);
}
.bar__home svg { inline-size: 1.2em; block-size: 1.2em; flex: none; }
@media (hover: hover) { .bar__home:hover { transform: translateY(-1px) scale(1.03); } }
.bar__home:active { transform: scale(.96); transition-duration: .08s; }
.bar__home:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.bar__title-btn {
  border: 0;
  background: transparent;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  text-align: start;
  min-inline-size: 0;
  -webkit-tap-highlight-color: transparent;
}
.bar__title-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  border-radius: 8px;
}

.bar__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 0.5rem + 1.15dvh, 1.22rem);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Toddler Quick-Hop Character Switcher --------------- */

.bar__switcher {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 0.75dvw, 0.6rem);
  margin-inline: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-block-size: 44px;
  padding: 0.22em 0.68em 0.22em 0.42em;
  border: 2px solid var(--ink);
  border-radius: 13px 10px 12px 11px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 0.45rem + 0.85dvw, 1.02rem);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 2px 0 rgb(61 55 44 / .18);
  transition: transform .16s cubic-bezier(.2,.9,.3,1.2), background-color .16s ease;
}

.switcher-btn img {
  inline-size: clamp(26px, 3.6dvh, 34px);
  block-size: clamp(26px, 3.6dvh, 34px);
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 1px 2px rgb(61 55 44 / .28));
}

.switcher-btn.is-current {
  background: var(--btn-wash, var(--butter));
  box-shadow: 0 2px 0 rgb(61 55 44 / .28), 0 4px 8px rgb(61 55 44 / .2);
  transform: translateY(-1px);
}

@media (hover: hover) {
  .switcher-btn:hover {
    transform: translateY(-1px) scale(1.04);
  }
}
.switcher-btn:active {
  transform: scale(.95);
}
.switcher-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .switcher-btn span {
    display: none;
  }
  .switcher-btn {
    padding-inline: 0.45em;
  }
}

.bar__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
}

.bar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0.35em;
  border: 2px solid var(--ink);
  border-radius: 12px 10px 11px 10px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 2px 0 rgb(61 55 44 / .18);
  transition: transform .16s ease;
}
.bar__icon-btn svg {
  inline-size: 1.35rem;
  block-size: 1.35rem;
}
.bar__icon-btn:active {
  transform: scale(.94);
}
.bar__icon-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.frame {
  flex: 1 1 auto;
  inline-size: 100%;
  border: 0;
  display: block;
  background: var(--paper);
}

/* ---------- while the game builds itself ----------------------- */

.loading {
  position: absolute;
  inset: auto 0 0 0;
  top: clamp(54px, 8.2dvh, 68px);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vmin;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: clamp(1rem, 0.5rem + 1.8dvh, 1.35rem);
  transition: opacity .35s ease;
}
.loading.is-done { opacity: 0; pointer-events: none; }
.loading p { margin: 0; font-weight: 700; color: var(--ink); }

.loading__art {
  inline-size: clamp(84px, 15vmin, 130px);
  block-size: auto;
  filter: drop-shadow(0 6px 12px rgb(61 55 44 / .25));
  animation: loadingBounce 1.1s ease-in-out infinite;
}

@keyframes loadingBounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-8px) rotate(2deg); }
}

.loading__dots { display: flex; gap: .5em; }
.loading__dots i {
  inline-size: 1.1vmin; block-size: 1.1vmin; min-inline-size: 7px; min-block-size: 7px;
  border-radius: 50%;
  background: var(--ink);
  opacity: .3;
  animation: dot 1.05s ease-in-out infinite;
}
.loading__dots i:nth-child(2) { animation-delay: .16s; }
.loading__dots i:nth-child(3) { animation-delay: .32s; }
@keyframes dot { 0%,100% { opacity: .25; } 45% { opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  .bar__home,
  .switcher-btn,
  .loading {
    transition: none;
  }
  .loading__art,
  .loading__dots i {
    animation: none;
    opacity: .75;
  }
}
