/* Tu préfères (template/generator/tu-preferes.php, static/js/tu-preferes.js), on the table of the online Truth or Dare
   game (static/css/truth-dare-game.css): a card cut in two, one choice on each half (violet as Truth, pink as Dare),
   « ou » between them. Once a half is touched, each one shows the share of players who made its choice; the half
   picked stays bright, the other one fades. Below, the dilemmas as the cards of the game to swipe, one level per tab. */

/* ---- The card: two halves to touch ---- */
.tp-card__front {
  gap: 10px;
  padding: 14px 14px 12px;
}

/* The halves fill the card: no sign of the Truth or Dare card in the background. */
.tp-card .td-card__front::after {
  content: none;
}

.tp-split {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.tp-half {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin: 0;
  padding: 16px 22px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s var(--td-ease), color .45s ease, box-shadow .45s ease;
}

.tp-half--a {
  background:
    radial-gradient(90% 80% at 0% 0%, rgba(255, 255, 255, .2), transparent 60%),
    linear-gradient(150deg, #6c4dff 0%, #9b3dff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 10px 24px rgba(108, 77, 255, .28);
}

.tp-half--b {
  background:
    radial-gradient(90% 80% at 100% 100%, rgba(255, 255, 255, .16), transparent 60%),
    linear-gradient(150deg, #e0156f 0%, #f0503a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 10px 24px rgba(240, 40, 100, .28);
}

.tp-half:hover {
  transform: translateY(-1px);
}

.tp-half:active {
  transform: scale(.98);
}

.tp-half:focus-visible {
  outline: 3px solid rgba(255, 185, 56, .95);
  outline-offset: 2px;
}

.tp-half__text {
  display: block;
  font-size: clamp(1.12rem, 4.8vw, 1.4rem);
  font-weight: 850;
  line-height: 1.22;
  letter-spacing: -.01em;
  text-wrap: balance;
  text-shadow: 0 1px 12px rgba(42, 15, 51, .25);
  transition: text-shadow .45s ease;
}

.tp-half__text::first-letter {
  text-transform: uppercase;
}

/* « ou », on the seam of the two halves. */
.tp-or {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  color: var(--td-night);
  font-size: .82rem;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(10, 2, 18, .32), 0 0 0 5px rgba(255, 255, 255, .28);
  pointer-events: none;
  transition: opacity .35s ease, scale .35s var(--td-ease);
}

/* Once the choice is made, « ou » steps aside for the shares. */
.tp-card[data-step="reveal"] .tp-or {
  opacity: 0;
  scale: .6;
}

/* ---- The answer: the half picked stays bright, the other one turns lilac grey ---- */
.tp-card[data-step="reveal"] .tp-half {
  cursor: default;
}

.tp-card[data-step="reveal"] .tp-half:hover,
.tp-card[data-step="reveal"] .tp-half:active {
  transform: none;
}

.tp-half.is-mine {
  animation: tp-picked .4s var(--td-ease);
}

@keyframes tp-picked {
  50% { transform: scale(1.025); }
}

/* The grey of the other half is a layer under its text, so that it fades in. */
.tp-half::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(150deg, #f3eff7 0%, #e6dfee 100%);
  opacity: 0;
  transition: opacity .45s ease;
}

.tp-half.is-other {
  color: #6b5a74;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 6px 16px rgba(59, 22, 63, .08);
}

.tp-half.is-other::after {
  opacity: 1;
}

.tp-half.is-other .tp-half__text {
  text-shadow: none;
}

/* The share of players, in a badge under each choice once the votes are in: the text glides up to make room. */
.tp-half__pct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-height: 0;
  margin-top: 0;
  padding: 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #fff;
  color: #6c4dff;
  font-size: 1.28rem;
  font-weight: 950;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  scale: .8;
  transition: max-height .4s var(--td-ease), margin-top .4s var(--td-ease), padding .4s var(--td-ease), opacity .3s ease .1s, scale .4s var(--td-ease) .1s;
}

.tp-half--b .tp-half__pct {
  color: #e0156f;
}

.tp-half.is-other .tp-half__pct {
  background: rgba(59, 22, 63, .08);
  color: #5d4b66;
}

.tp-card.has-counts .tp-half__pct {
  max-height: 2.6em;
  margin-top: 10px;
  padding: 6px 16px;
  opacity: 1;
  scale: 1;
}

/* A tick before the share of the half picked, drawn so that it looks the same everywhere. */
.tp-half.is-mine .tp-half__pct::before {
  content: "";
  width: .3em;
  height: .58em;
  margin: -.12em .08em 0 0;
  border: solid currentColor;
  border-width: 0 .14em .14em 0;
  rotate: 45deg;
}

/* « Votre choix », for screen readers, on the half picked. */
.tp-half__mine {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tp-half:not(.is-mine) .tp-half__mine {
  display: none;
}

/* The end of a level, in place of the two halves. */
.tp-card .tp-end {
  display: none;
}

.tp-card[data-step="end"] .tp-split {
  display: none;
}

.tp-card[data-step="end"] .tp-end {
  display: flex;
}

/* ---- Under the card: what to do, then the verdict ---- */
.tp-verdict {
  grid-column: 1 / -1;
  min-height: 1.35em;
  margin: 0;
  color: rgba(255, 255, 255, .72);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.tp-actions.is-answered .tp-verdict {
  color: #fff;
  font-size: 1.12rem;
  font-weight: 900;
}

/* On short screens, the halves keep to the essentials. */
@media (max-height: 700px) {
  .tp-half {
    padding: 10px 18px;
  }

  .tp-half__text {
    font-size: clamp(1rem, 4.4vw, 1.18rem);
  }

  .tp-half__pct {
    font-size: 1.1rem;
  }

  .tp-card.has-counts .tp-half__pct {
    margin-top: 6px;
    padding: 4px 14px;
  }
}

/* Short phones: the card gives its signature to the two choices. */
@media (max-width: 599px) and (max-height: 720px) {
  .tp-card .td-card__brand {
    display: none;
  }
}

/* Wider screens: the two choices face each other, on a wider table. Without the two buttons of Truth or Dare
   under it, the card can take a little more of the height. */
@media (min-width: 600px) {
  .tp-page .td-game-shell {
    width: min(700px, 100%);
  }

  .tp-page .td-card-area {
    height: clamp(280px, calc(100svh - 350px), 420px);
  }

  .tp-page.td-has-sticky .td-card-area {
    height: clamp(260px, calc(100svh - 460px), 420px);
  }

  .tp-card__front {
    padding: 18px 18px 14px;
  }

  .tp-split {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
  }

  .tp-half {
    padding: 18px 24px;
  }

  .tp-half__text {
    font-size: clamp(1.1rem, 2.4vw, 1.32rem);
  }
}

/* ---- Below the game: the dilemmas as the cards of the game, to swipe, one level per tab ---- */
.tp-gallery__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 14px;
}

.tp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tp-tab {
  min-height: 38px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(42, 20, 45, .12);
  border-radius: 999px;
  background: #fff;
  color: #745f75;
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.tp-tab:hover {
  color: var(--td-ink);
}

.tp-tab[aria-selected="true"] {
  border-color: #3b163f;
  background: #3b163f;
  color: #fff;
  box-shadow: 0 8px 22px rgba(247, 37, 133, .3);
}

.tp-arrows {
  display: flex;
  flex: none;
  gap: 8px;
}

.tp-arrow {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(42, 20, 45, .12);
  border-radius: 50%;
  background: #fff;
  color: var(--td-ink);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .2s ease;
}

.tp-arrow:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(72, 22, 64, .12);
}

.tp-panels {
  display: grid;
}

.tp-panel {
  grid-area: 1 / 1;
  min-width: 0;
  transition: opacity .3s ease, visibility 0s linear 0s;
}

.tp-panel:not(.is-current) {
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .2s;
}

/* One row of cards that slides sideways, card by card, to the edges of the screen. */
.td-example-grid.tp-row {
  display: flex;
  gap: 14px;
  margin: 0 -16px;
  padding: 6px 16px 22px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  scrollbar-width: none;
  list-style: none;
}

.tp-row::-webkit-scrollbar {
  display: none;
}

.tp-row .tp-example {
  flex: 0 0 min(78%, 280px);
  scroll-snap-align: start;
  cursor: pointer;
}

.tp-example__play {
  align-self: flex-start;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--td-truth);
  font: inherit;
  font-weight: 950;
  cursor: pointer;
}

.td-example--dare .tp-example__play {
  color: var(--td-dare);
}

.tp-example__play::after {
  content: "\00A0\203A";
}

/* On a phone the cards are swiped: no arrows. */
@media (max-width: 599px) {
  .tp-arrows {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tp-half,
  .tp-half::after,
  .tp-half__text,
  .tp-half__pct,
  .tp-or,
  .tp-panel {
    transition: none;
  }

  .tp-half.is-mine {
    animation: none;
  }
}
