/* picker.css — the three theme cards in the lobby: the one choice the host
   makes before the show starts, so it has to read as an object, not a link.

   Each card is a slab of dark glass with a bevel, a CSS-drawn motif and its own
   accent bleeding from the bottom edge. Two states have to be legible at three
   metres AT THE SAME TIME and without relying on colour:
     focus     -> gold ring + scale + glow (the house rule for the D-pad)
     selected  -> accent border, a tick badge, and the card sits raised
   Everything animated here is transform/opacity only. */

.picker {
  display: grid;
  /* Room for the focus ring to grow without touching the label. */
  gap: 1.05rem;
}

.picker__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

/* ---------- The card ---------- */

.theme-card {
  --acc-1: var(--hot);
  --acc-2: var(--gold);

  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.3rem;
  padding: 1.15rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(168deg, rgb(255 255 255 / 0.07), rgb(255 255 255 / 0.015) 46%),
    linear-gradient(180deg, var(--bg-raise), var(--bg-sink));
  color: var(--ink);
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.09),
    inset 0 -1px 0 rgb(0 0 0 / 0.5),
    0 1rem 2.4rem rgb(0 0 0 / 0.5);
  transition:
    transform var(--dur) var(--ease-out),
    border-color var(--dur-fast) linear,
    box-shadow var(--dur-fast) linear;
}

/* The accent lying under the card, strongest at the bottom edge. */
.theme-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -70% -20%;
  height: 120%;
  background: radial-gradient(50% 60% at 50% 100%, var(--acc-1) 0%, transparent 72%);
  opacity: 0.18;
  transition: opacity var(--dur) linear;
  pointer-events: none;
}

/* A hairline of pure accent along the bottom lip: gives the slab thickness. */
.theme-card::after {
  content: "";
  position: absolute;
  inset: auto 12% 0 12%;
  height: 0.18rem;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--acc-1), var(--acc-2), transparent);
  opacity: 0.55;
  transition: opacity var(--dur) linear;
}

.theme-card:hover:not(:disabled) {
  transform: none;
}

/* ---------- Type: name 32px, tagline 24px at 1080p ---------- */

.theme-card__text {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.theme-card__name {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.theme-card__tag {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-dim);
  text-wrap: balance;
}

/* ---------- Motifs, drawn in CSS ---------- */

.theme-card__glyph {
  position: relative;
  width: 4.2rem;
  height: 4.2rem;
  flex: none;
  transition: transform var(--dur) var(--ease-slam);
}

.theme-card__glyph::before,
.theme-card__glyph::after {
  content: "";
  position: absolute;
  background: linear-gradient(150deg, var(--acc-1), var(--acc-2));
  filter: drop-shadow(0 0 0.5rem rgb(0 0 0 / 0.6));
}

/* fiesta: two sparks, one big one small */
[data-mode="fiesta"] {
  --acc-1: #ff8a2b;
  --acc-2: #e0356f;
}

[data-mode="fiesta"] .theme-card__glyph::before {
  inset: 4% 18% 12% 0;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
}

[data-mode="fiesta"] .theme-card__glyph::after {
  inset: 52% 0 4% 62%;
  clip-path: polygon(50% 0%, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0% 50%, 38% 38%);
}

/* familia: a house with the hearth lit inside */
[data-mode="familia"] {
  --acc-1: #e6b24e;
  --acc-2: #6bc26b;
}

[data-mode="familia"] .theme-card__glyph::before {
  inset: 8% 4% 8% 4%;
  clip-path: polygon(
    50% 0%,
    100% 44%,
    86% 44%,
    86% 100%,
    14% 100%,
    14% 44%,
    0% 44%
  );
}

[data-mode="familia"] .theme-card__glyph::after {
  inset: 56% 38% 8% 38%;
  border-radius: 0.2rem 0.2rem 0 0;
  background: linear-gradient(180deg, #fff2cf, var(--acc-1));
}

/* pareja: two lobes closing into a heart */
[data-mode="pareja"] {
  --acc-1: #ff6f9c;
  --acc-2: #9a6bd9;
}

/* Two lobes rotated 45 degrees off the same bottom point: they close into one
   heart with no gap between them. */
[data-mode="pareja"] .theme-card__glyph::before,
[data-mode="pareja"] .theme-card__glyph::after {
  top: 6%;
  width: 50%;
  height: 80%;
  border-radius: 50% 50% 0 0;
}

[data-mode="pareja"] .theme-card__glyph::before {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

[data-mode="pareja"] .theme-card__glyph::after {
  left: 50%;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

/* ---------- Selected: tick badge + accent border + a raised card ---------- */

.theme-card__mark {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--acc-1), var(--acc-2));
  box-shadow: 0 0.3rem 0.9rem rgb(0 0 0 / 0.55);
  transform: scale(0);
  opacity: 0;
  transition:
    transform var(--dur) var(--ease-slam),
    opacity var(--dur-fast) linear;
}

.theme-card__mark::before {
  content: "";
  width: 0.7rem;
  height: 1.15rem;
  margin-top: -0.25rem;
  border: 0.22rem solid #10131a;
  border-top: 0;
  border-left: 0;
  transform: rotate(42deg);
}

.theme-card.is-selected,
.theme-card[aria-pressed="true"] {
  border-color: var(--acc-1);
  transform: translateY(-0.3rem);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.14),
    inset 0 0 0 1px color-mix(in srgb, var(--acc-1) 45%, transparent),
    0 1.4rem 3rem rgb(0 0 0 / 0.6);
}

.theme-card.is-selected::before,
.theme-card[aria-pressed="true"]::before {
  opacity: 0.42;
}

.theme-card.is-selected::after,
.theme-card[aria-pressed="true"]::after {
  opacity: 1;
}

.theme-card.is-selected .theme-card__mark,
.theme-card[aria-pressed="true"] .theme-card__mark {
  transform: scale(1);
  opacity: 1;
}

.theme-card.is-selected .theme-card__glyph,
.theme-card[aria-pressed="true"] .theme-card__glyph {
  transform: scale(1.08);
}

/* ---------- Focus: the D-pad must be impossible to lose ---------- */

.theme-card:focus,
.theme-card:focus-visible {
  outline: 0.22rem solid var(--gold);
  outline-offset: 0.35rem;
  transform: scale(1.055);
  border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.16),
    0 0 0 0.5rem rgb(217 201 74 / 0.1),
    0 1.8rem 3.6rem rgb(0 0 0 / 0.65);
}

.theme-card.is-selected:focus,
.theme-card.is-selected:focus-visible,
.theme-card[aria-pressed="true"]:focus,
.theme-card[aria-pressed="true"]:focus-visible {
  transform: scale(1.055) translateY(-0.3rem);
}

.theme-card:focus::before,
.theme-card:focus-visible::before {
  opacity: 0.5;
}

.theme-card:focus .theme-card__glyph,
.theme-card:focus-visible .theme-card__glyph {
  transform: scale(1.12) rotate(-4deg);
}

.theme-card.is-selected:focus .theme-card__glyph,
.theme-card.is-selected:focus-visible .theme-card__glyph,
.theme-card[aria-pressed="true"]:focus .theme-card__glyph,
.theme-card[aria-pressed="true"]:focus-visible .theme-card__glyph {
  transform: scale(1.18) rotate(-4deg);
}

/* ============================================================================
   Language pills — the settings line under the cards.

   Hierarchy on purpose: the deck is the show, the language is a preference the
   host sets once. So the pills are half the height of a card, keep native
   casing (English / Español / Português are proper nouns), sit right-aligned
   under the last card, and carry no accent colour of their own — the mood
   belongs to the deck.

   Same two states, same rules as the cards, both legible at three metres and
   both readable at once:
     focus     -> gold ring OUTSIDE the pill + scale (house D-pad language)
     selected  -> tick glyph + bright ink + a lit lip INSIDE the pill
   Focus lives outside the edge, selection lives inside it, so neither hides the
   other. Nothing here depends on colour: the tick is a shape, and it occupies
   its slot whether it is drawn or not, so nothing reflows when it appears.
   ========================================================================== */

/* The closing band of the selection block: languages on the left, the tally and
   START on the right. Same row, so the block ends where the decision is made. */
.picker__settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Room for the focus ring to breathe against the seats band below. */
  gap: 1.1rem;
  padding-top: 0.2rem;
}

.picker__langs {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

/* Quieter than the section label above it: same size (24px floor), less ink. */
.picker__sublabel {
  color: var(--ink-faint);
}

.lang-row {
  display: flex;
  gap: 0.8rem;
}

/* ---------- The pill ---------- */

.lang-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.15rem 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  /* Dark glass: a sheen across the top, a translucent body so the mood behind
     tints it without ever lifting the surface into the text's contrast. */
  background:
    linear-gradient(170deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.01) 55%),
    linear-gradient(180deg, rgb(20 26 37 / 0.82), rgb(9 12 17 / 0.88));
  color: var(--ink-dim);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-transform: none;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.07),
    0 0.5rem 1.2rem rgb(0 0 0 / 0.4);
  transition:
    transform var(--dur) var(--ease-out),
    border-color var(--dur-fast) linear,
    color var(--dur-fast) linear,
    box-shadow var(--dur-fast) linear;
}

.lang-pill:hover:not(:disabled) {
  transform: none;
}

/* The lit lip along the bottom of a chosen pill: the same trick that gives the
   cards their thickness, at a quarter of the volume. */
.lang-pill::after {
  content: "";
  position: absolute;
  inset: auto 26% 0 26%;
  height: 0.14rem;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity var(--dur) linear;
}

.lang-pill__name {
  line-height: 1.15;
}

/* ---------- The tick slot: always there, so nothing moves ---------- */

.lang-pill__tick {
  position: relative;
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
  border: 0.12rem solid var(--line);
  border-radius: 50%;
  transition:
    background-color var(--dur-fast) linear,
    border-color var(--dur-fast) linear;
}

/* The check itself, drawn as two borders of a rotated box. */
.lang-pill__tick::before {
  content: "";
  position: absolute;
  left: 0.34rem;
  top: 0.08rem;
  width: 0.3rem;
  height: 0.58rem;
  border: 0.16rem solid #10131a;
  border-top: 0;
  border-left: 0;
  transform: rotate(42deg) scale(0);
  transform-origin: 50% 60%;
  opacity: 0;
  transition:
    transform var(--dur) var(--ease-slam),
    opacity var(--dur-fast) linear;
}

/* ---------- Selected ---------- */

/* Deliberately NOT a gold ring: the ring is the D-pad's word, and it must never
   have to compete. A chosen pill is a lifted piece of glass with a tick. */
.lang-pill.is-selected,
.lang-pill[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--gold) 26%, var(--line));
  color: var(--ink);
  background:
    linear-gradient(170deg, rgb(255 255 255 / 0.14), rgb(255 255 255 / 0.04) 60%),
    linear-gradient(180deg, rgb(32 39 52 / 0.9), rgb(16 21 29 / 0.92));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.16),
    inset 0 -0.7rem 1.2rem rgb(217 201 74 / 0.07),
    0 0.6rem 1.4rem rgb(0 0 0 / 0.45);
}

.lang-pill.is-selected::after,
.lang-pill[aria-pressed="true"]::after {
  opacity: 0.9;
}

.lang-pill.is-selected .lang-pill__tick,
.lang-pill[aria-pressed="true"] .lang-pill__tick {
  border-color: var(--gold);
  background: var(--gold);
}

.lang-pill.is-selected .lang-pill__tick::before,
.lang-pill[aria-pressed="true"] .lang-pill__tick::before {
  transform: rotate(42deg) scale(1);
  opacity: 1;
}

/* ---------- Focus ---------- */

.lang-pill:focus,
.lang-pill:focus-visible {
  outline: 0.2rem solid var(--gold);
  outline-offset: 0.3rem;
  transform: scale(1.07);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.14),
    0 0 0 0.4rem rgb(217 201 74 / 0.1),
    0 0.9rem 2rem rgb(0 0 0 / 0.55);
}

/* ---------- Budget ---------- */

:root[data-perf="lite"] .lang-pill,
:root[data-perf="lite"] .lang-pill:focus,
:root[data-perf="lite"] .lang-pill:focus-visible,
:root[data-perf="lite"] .lang-pill.is-selected,
:root[data-perf="lite"] .lang-pill[aria-pressed="true"] {
  box-shadow: none;
}

/* Lite drops the translucency (one less blend per pill) but keeps the value
   step between chosen and unchosen — that step is a legibility cue, not decor. */
:root[data-perf="lite"] .lang-pill {
  background: linear-gradient(180deg, var(--bg-raise), var(--bg-sink));
}

:root[data-perf="lite"] .lang-pill.is-selected,
:root[data-perf="lite"] .lang-pill[aria-pressed="true"] {
  background: linear-gradient(180deg, #202734, #101519);
}

:root[data-perf="lite"] .theme-card {
  box-shadow: none;
}

:root[data-perf="lite"] .theme-card::before {
  display: none;
}

:root[data-perf="lite"] .theme-card__glyph::before,
:root[data-perf="lite"] .theme-card__glyph::after {
  filter: none;
}

:root[data-perf="lite"] .theme-card:focus,
:root[data-perf="lite"] .theme-card:focus-visible {
  box-shadow: none;
}

/* ============================================================================
   Idle life: the three decks breathe.

   Two keyframe sets because the chosen card already sits on a translateY, and
   an animation would otherwise flatten it back onto the row. Focus turns the
   loop OFF so the focus scale is never overwritten — the D-pad ring outranks
   the decoration, always.
   ========================================================================== */

.theme-card {
  animation: card-breathe 5.4s ease-in-out infinite;
}

.picker__row .theme-card:nth-child(2) {
  animation-delay: 1.7s;
}

.picker__row .theme-card:nth-child(3) {
  animation-delay: 3.3s;
}

.theme-card.is-selected,
.theme-card[aria-pressed="true"] {
  animation-name: card-breathe-lifted;
}

.theme-card:focus,
.theme-card:focus-visible {
  animation: none;
}

/* The accent pooled under each card glows on a slower clock than the scale, so
   the two never beat together. */
.theme-card::before {
  animation: card-pool 8.2s ease-in-out infinite;
}

.picker__row .theme-card:nth-child(2)::before {
  animation-delay: 2.6s;
}

.picker__row .theme-card:nth-child(3)::before {
  animation-delay: 5.1s;
}

/* The chosen deck keeps its brighter pool while it breathes, and focus freezes
   the loop so the focus value wins outright. */
.theme-card.is-selected::before,
.theme-card[aria-pressed="true"]::before {
  animation-name: card-pool-lit;
}

.theme-card:focus::before,
.theme-card:focus-visible::before {
  animation: none;
}

@keyframes card-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.014);
  }
}

@keyframes card-breathe-lifted {
  0%,
  100% {
    transform: translateY(-0.3rem) scale(1);
  }
  50% {
    transform: translateY(-0.44rem) scale(1.014);
  }
}

@keyframes card-pool {
  0%,
  100% {
    opacity: 0.16;
  }
  50% {
    opacity: 0.34;
  }
}

@keyframes card-pool-lit {
  0%,
  100% {
    opacity: 0.36;
  }
  50% {
    opacity: 0.58;
  }
}

:root[data-perf="lite"] .theme-card,
:root[data-perf="lite"] .theme-card::before {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .theme-card,
  .theme-card::before {
    animation: none;
  }
}

/* ---------- Modo ligero: las cartas grandes matan a los sticks ----------
   Medido en un Fire TV real: 2-3 fps y hasta 1285 ms por fotograma al mover el
   foco entre cartas (las pastillas de idioma, mucho mas pequenas, iban bien).
   Culpables: transiciones de box-shadow y drop-shadow sobre superficies
   grandes, mas las capas de brillo. Aqui se apagan por completo. */

:root[data-perf="lite"] .theme-card,
:root[data-perf="lite"] .theme-card.is-selected,
:root[data-perf="lite"] .theme-card[aria-pressed="true"],
:root[data-perf="lite"] .theme-card:focus,
:root[data-perf="lite"] .theme-card:focus-visible {
  box-shadow: none;
  filter: none;
  transition: transform 0.12s linear, border-color 0.12s linear;
  animation: none !important;
}

:root[data-perf="lite"] .theme-card::before,
:root[data-perf="lite"] .theme-card::after {
  display: none;
}

:root[data-perf="lite"] .theme-card__glyph,
:root[data-perf="lite"] .theme-card__mark {
  filter: none;
  animation: none !important;
}

/* El foco se sigue viendo clarisimo, pero sin repintar la carta entera. */
:root[data-perf="lite"] .theme-card:focus,
:root[data-perf="lite"] .theme-card:focus-visible {
  outline: 0.28rem solid var(--gold);
  outline-offset: 0.3rem;
  transform: scale(1.03);
}

:root[data-perf="lite"] .lang-pill {
  box-shadow: none;
  transition: transform 0.12s linear;
}
