/* Boredom Buster, digital (play/boredom_buster.templ).
   One bright card in front of a fanned deck, a picker above for the kinds,
   the "another one" button under the thumb. Same layout at every width: it's
   one card, so a wide screen just gets more table around it. */
.bb [x-cloak] { display: none; }
.bb {
  --bb-font: "Fredoka", "Montserrat", system-ui, sans-serif;
  display: grid;
  justify-items: center;
}

/* One colour per category (ids from busterCards in play/boredom_buster.go).
   --c is the card, --band the wave at its foot, --ink what reads on both.
   Yellow and green are too light for white text, so they take a dark ink. */
.bb-c-move    { --c: #f24b3c; --band: #c8301f; --ink: #fff; }
.bb-c-silly   { --c: #ffd23a; --band: #ffa51f; --ink: #4a2208; }
.bb-c-pretend { --c: #9160f5; --band: #6b3bd8; --ink: #fff; }
.bb-c-think   { --c: #1f94e0; --band: #1168ad; --ink: #fff; }
.bb-c-music   { --c: #f46d12; --band: #c2490a; --ink: #fff; }
.bb-c-calm    { --c: #3fd27e; --band: #22b060; --ink: #0d3d22; }

.bb-lede {
  justify-self: stretch;
  margin: 0 0 1rem;
  max-width: 46ch;
  color: var(--slate);
  font-size: 0.95rem;
  line-height: 1.45;
}

/* ---- Kind picker -----------------------------------------------------
   The button is the site's .worksheet-select; the panel copies the
   character-set select's ::picker (base.css) so the two read as one control.
   A dot per ticked kind; the rainbow one is the whole deck. */
.bb-pick { position: relative; justify-self: stretch; max-width: 22rem; }
.bb-pick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  text-align: left;
  cursor: pointer;
}
.bb-pick-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bb-pick-count {
  flex: none;
  min-width: 1.75rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(26, 56, 40, 0.07);
  color: #4a5c50;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.bb-dots { display: flex; flex: none; }
.bb-dots .bb-dot + .bb-dot { margin-left: -5px; }
.bb-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(#f24b3c 0 60deg, #f46d12 0 120deg, #ffd23a 0 180deg, #3fd27e 0 240deg, #1f94e0 0 300deg, #9160f5 0);
  box-shadow: 0 0 0 2px #fff;
}
.bb-dot[class*="bb-c-"] { background: var(--c); }

.bb-pick-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 2px;
  padding: 6px;
  max-height: min(22rem, 60vh);
  overflow-y: auto;
  border: 1.5px solid rgba(26, 56, 40, 0.14);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(26, 56, 40, 0.14);
}
.bb-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.bb-opt:hover,
.bb-opt:has(:focus-visible) { background: rgba(27, 140, 138, 0.08); }
.bb-opt:has(:checked) .bb-opt-name { font-weight: 700; }
.bb-opt input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--teal);
  cursor: pointer;
}
.bb-opt input:focus-visible { outline: 2px solid var(--teal-hover); outline-offset: 2px; }
.bb-opt-name { flex: 1; min-width: 0; }
/* "All cards" sits apart from the kinds it stands for. */
.bb-opt:first-child { margin-bottom: 4px; box-shadow: 0 5px 0 -4px rgba(26, 56, 40, 0.1); }

/* ---- The table: fan behind, card in front ---------------------------- */
/* The stage bleeds into the page gutter, so the fan is clipped at the screen
   edge rather than at the text column. On a phone the card is sized so the
   tilted corners (about a fifth of the card's width past each side) still
   land inside the screen; the clip only stops a sliver ever widening the page. */
.bb-stage {
  --w: clamp(12.5rem, 64vw, 20rem);
  position: relative;
  display: grid;
  justify-items: center;
  width: calc(100% + 2 * var(--pad));
  margin-inline: calc(-1 * var(--pad));
  padding: 2.25rem 0 1.5rem;
  overflow-x: clip;
}
.bb-fan,
.bb-slot { grid-area: 1 / 1; width: var(--w); }
.bb-fan { position: relative; }
.bb-fan-card {
  position: absolute;
  inset: 0;
  border: 4px solid #fff;
  border-radius: 22px;
  background:
    radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.28) 1.6px, transparent 0) 0 0 / 16px 16px,
    var(--c);
  box-shadow: 0 10px 24px rgba(26, 56, 40, 0.12);
  transform-origin: 50% 110%;
}
.bb-fan-card:nth-child(1) { transform: rotate(-8deg); }
.bb-fan-card:nth-child(2) { transform: rotate(-4deg); }
.bb-fan-card:nth-child(3) { transform: rotate(7.5deg); }
.bb-fan-card:nth-child(4) { transform: rotate(3.5deg); }

.bb-slot {
  position: relative;
  display: grid;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bb-slot:focus-visible { outline: none; }
.bb-slot:focus-visible > * { outline: 3px solid var(--teal-hover); outline-offset: 4px; }

.bb-back,
.bb-card {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  aspect-ratio: 5 / 7;
  border: 4px solid #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(26, 56, 40, 0.2);
}

/* Face down: every colour in the deck, a question mark in the middle. */
.bb-back {
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background:
    radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.3) 1.6px, transparent 0) 0 0 / 16px 16px,
    repeating-linear-gradient(135deg,
      #f24b3c 0 2.2rem, #f46d12 0 4.4rem, #ffd23a 0 6.6rem,
      #3fd27e 0 8.8rem, #1f94e0 0 11rem, #9160f5 0 13.2rem);
  color: var(--forest);
  font-family: var(--bb-font);
}
.bb-back-mark {
  display: grid;
  place-items: center;
  width: 6.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  font-size: 4.25rem;
  font-weight: 700;
  box-shadow: 0 6px 0 rgba(26, 56, 40, 0.15);
  animation: bb-bob 2.4s ease-in-out infinite;
}
.bb-back-hint {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Face up: the screenshot's playing card — number in the corner, the name
   big across the top, the picture, then a wave with the colour and the
   instruction under it. */
.bb-card {
  position: relative;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.38), transparent 52%),
    var(--c);
  color: var(--ink);
  font-family: var(--bb-font);
  text-align: center;
  animation: bb-deal 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25);
  transition: transform 0.28s ease-in, opacity 0.28s ease-in;
}
.bb-card.is-leaving {
  transform: translate(-115%, -6%) rotate(-24deg);
  opacity: 0;
}
.bb-no {
  position: absolute;
  top: 0.7rem;
  left: 0.95rem;
  color: color-mix(in srgb, var(--band) 45%, #2a0a0a);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}
.bb-title {
  padding: 3.1rem 1rem 0;
  font-size: clamp(1.55rem, 7.5vw, 1.95rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
  text-shadow: 0 2px 0 color-mix(in srgb, var(--band) 60%, transparent);
}
.bb-art {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  font-size: clamp(3.75rem, 22vw, 6.25rem);
  line-height: 1;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.14));
}
.bb-foot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 1rem 1.1rem;
  background: var(--band);
}
.bb-wave {
  position: absolute;
  left: 0;
  bottom: calc(100% - 1px);
  width: 100%;
  height: 1.6rem;
  fill: var(--band);
}
.bb-wave-soft { opacity: 0.45; }
.bb-badge {
  position: absolute;
  right: 0.8rem;
  top: -2.1rem;
  display: grid;
  place-items: center;
  width: 2.9rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  font-size: 1.45rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}
.bb-cat {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.bb-text {
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.3;
  text-wrap: balance;
}

/* ---- Another one: under the thumb ------------------------------------ */
.bb-next {
  position: sticky;
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 2;
  min-width: min(100%, 17rem);
  min-height: 3.25rem;
  padding: 0 1.75rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 700 17px/1 "Montserrat", Helvetica, Arial, sans-serif;
  cursor: pointer;
  transition: filter 0.15s;
}
.bb-next:hover { filter: brightness(1.12); }
.bb-next:focus-visible { outline: 2px solid var(--teal-hover); outline-offset: 3px; }

@keyframes bb-deal {
  from { transform: translateY(2.5rem) rotate(9deg) scale(0.86); opacity: 0; }
  60% { transform: translateY(-0.4rem) rotate(-2deg) scale(1.03); opacity: 1; }
  to { transform: none; }
}
@keyframes bb-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}

@media (min-width: 760px) {
  .bb-lede { font-size: 1.05rem; }
  .bb-stage { --w: 21rem; padding: 3rem 0 2rem; }
  .bb-fan-card:nth-child(1) { transform: rotate(-10deg); }
  .bb-fan-card:nth-child(3) { transform: rotate(9deg); }
  .bb-title { font-size: 2.1rem; }
  .bb-text { font-size: 1.05rem; }
  .bb-next { position: static; margin-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-card { animation: none; transition: none; }
  .bb-back-mark { animation: none; }
}
