/*
 * PHASE 8Q.4-I/J -- THE GRAND PRIZE FINALE: the player page (#/grand-prize),
 * the TV screen (#/grand-prize-tv) and the Admin area.
 *
 * Mobile-first: one column, nothing with a fixed pixel width, inputs at 16px
 * so iOS never zooms. The TV opts out of the phone shell exactly as the Event
 * host screen does (phase8.css, `[data-route="host"]`): no tab bar, no width
 * cap, type sized for across a room. Every animation is decoration over a
 * stored result and is switched off by prefers-reduced-motion.
 *
 * Only the app.css tokens are read; the gold of the finale is a literal, so no
 * rule here can depend on a token that does not exist.
 */

/* ---- shared --------------------------------------------------------------- */

[data-grand-prize="root"] {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.gp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.gp-kicker {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f5cf63;
  overflow-wrap: anywhere;
}

.gp-state {
  margin: 0;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.gp-status:empty { display: none; }
.gp-status { margin: 0; color: var(--warn); font-size: 0.9rem; }

.gp-rules { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; }

/* ---- teaser ---------------------------------------------------------------- */

.gp-teaser {
  display: grid;
  gap: 8px;
  padding: 18px var(--gutter);
  border: 1px solid #8a6d1f;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--bg-elev-2), var(--bg-elev));
  text-align: center;
}

.gp-teaser__count {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  color: #f5cf63;
  overflow-wrap: anywhere;
}

.gp-teaser__line { margin: 0; color: var(--text-dim); }

.gp-teaser__strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}

.gp-teaser__chip {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  min-width: 0;
}

.gp-teaser__rank { font-weight: 800; color: #f5cf63; }
.gp-teaser__name { font-size: 0.9rem; overflow-wrap: anywhere; }

/* ---- prize cards ----------------------------------------------------------- */

.gp-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

/* As many columns as fit (1 to 10 prizes, migration 060); a single prize stays card-width. */
@media (min-width: 700px) {
  .gp-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .gp-cards--n1 { grid-template-columns: minmax(0, 420px); justify-content: center; }
}

.gp-card {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  min-width: 0;
}

.gp-card--published { border-color: #8a6d1f; }

.gp-card__rank { margin: 0; font-weight: 800; color: #f5cf63; letter-spacing: 0.06em; }
.gp-card__title { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.gp-card__subtitle, .gp-card__soon, .gp-card__pool { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.gp-card__value { margin: 0; font-weight: 700; }
.gp-card__desc { margin: 0; overflow-wrap: anywhere; }
.gp-card__thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-card__thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); }

.gp-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
}

.gp-img--empty,
.gp-stage__img.gp-img--empty,
.gp-results__img.gp-img--empty,
.gp-stage__trio-img.gp-img--empty {
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  color: #f5cf63;
}

/* ---- allocation ------------------------------------------------------------ */

.gp-alloc {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  min-width: 0;
}

.gp-alloc__title { margin: 0; }
.gp-alloc__balance { margin: 0; font-size: 1.4rem; font-weight: 800; color: #f5cf63; }
.gp-alloc__rows { display: grid; gap: 8px; }

.gp-alloc__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
}

.gp-alloc__label { overflow-wrap: anywhere; }

.gp-alloc__input {
  width: 100%;
  min-height: var(--tap);
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

.gp-alloc__status { margin: 0; font-weight: 700; }
.gp-alloc__status--over { color: var(--danger); }
.gp-alloc__note { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.gp-alloc__note--warn { color: var(--warn); }
.gp-alloc__note:empty { display: none; }
.gp-alloc__save { min-height: var(--tap); justify-self: start; }
.gp-alloc__entered { margin: 0; padding-left: 1.1rem; }

.gp-tickets { min-width: 0; }
.gp-tickets__fallback { margin: 0; color: var(--text-dim); }
.gp-replay { justify-self: start; min-height: var(--tap); }

/* ---- the stage (phone and TV) ---------------------------------------------- */

.gp-stage {
  position: relative;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  padding: 20px var(--gutter);
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% 0%, var(--bg-elev-2), var(--bg));
  border: 1px solid #8a6d1f;
  overflow: hidden;
  min-width: 0;
}

.gp-stage__title {
  margin: 0;
  font-size: clamp(1.3rem, 6vw, 2.2rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.gp-stage__title--hero { color: #f5cf63; letter-spacing: 0.04em; }
.gp-stage__line, .gp-stage__desc, .gp-stage__pool { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.gp-stage__img { display: block; width: 100%; max-width: 560px; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); }

.gp-stage__trio {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  width: 100%;
}
.gp-stage__trio--n1 { grid-template-columns: minmax(0, 240px); justify-content: center; }
.gp-stage__trio--n2 { grid-template-columns: repeat(2, minmax(0, 200px)); justify-content: center; }

.gp-stage__trio-img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.gp-stage__totals { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }

.gp-stage__vault {
  margin: 0;
  font-size: clamp(1.1rem, 5vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #f5cf63;
  animation: gp-pulse 1.4s ease-in-out infinite;
}

.gp-stage__wins {
  margin: 0;
  font-size: clamp(1.8rem, 9vw, 3.4rem);
  font-weight: 900;
  color: #f5cf63;
  overflow-wrap: anywhere;
  animation: gp-pop 600ms ease-out both;
}

.gp-stage__you, .gp-results__you { margin: 0; color: var(--accent); font-weight: 800; }
.gp-stage__paused, .gp-stage__replay { margin: 0; color: var(--text-dim); font-style: italic; }

/* The celebration: a ring of light behind the winner. Decoration only. */
.gp-celebrate::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg, transparent, rgba(245, 207, 99, 0.25), transparent 30%);
  animation: gp-spin 6s linear infinite;
  pointer-events: none;
}

.gp-celebrate > * { position: relative; }

/* ---- results ---------------------------------------------------------------- */

.gp-results { display: grid; gap: 12px; width: 100%; }
.gp-results__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }

.gp-results__item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}

.gp-results__img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); }
.gp-results__prize { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.gp-results__winner { margin: 0; font-size: 1.25rem; font-weight: 800; overflow-wrap: anywhere; }

/* ---- the TV ------------------------------------------------------------------ */

:root[data-route="grand-prize-tv"] .tabbar { display: none; }

:root[data-route="grand-prize-tv"] .main {
  max-width: none;
  padding: 0;
}

:root[data-route="grand-prize-tv"] .view { animation: none; }

.gptv {
  display: grid;
  gap: clamp(0.75rem, 1.6vw, 2rem);
  padding: clamp(0.75rem, 2vw, 2.5rem);
  min-height: 100vh;
  align-content: center;
  color: var(--text);
  font-size: clamp(1rem, 1.6vw, 1.6rem);
}

.gptv__status:empty { display: none; }
.gptv__status { margin: 0; color: var(--warn); text-align: center; }

.gp-stage--tv { padding: clamp(1rem, 3vw, 3rem); }
.gp-stage--tv .gp-stage__title { font-size: clamp(2rem, 4.5vw, 4.5rem); }
.gp-stage--tv .gp-stage__wins { font-size: clamp(2.5rem, 7vw, 7rem); }
.gp-stage--tv .gp-stage__vault { font-size: clamp(1.6rem, 3.5vw, 3.5rem); }
.gp-stage--tv .gp-stage__img { max-width: min(70vw, 1100px); max-height: 55vh; }

/*
 * THE REVEAL ON A WIDE SCREEN: photo left, words right, so "<NAME> WINS!" is
 * on screen without scrolling on a 1080p (or 720p) television. Every child but
 * the photo goes in the right-hand column; the photo spans the rows.
 */
@media (min-width: 1000px) {
  .gp-stage--tv.gp-stage--suspense,
  .gp-stage--tv.gp-stage--revealed {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(1rem, 3vw, 3rem);
  }
  .gp-stage--tv.gp-stage--suspense > *,
  .gp-stage--tv.gp-stage--revealed > * { grid-column: 2; }
  .gp-stage--tv.gp-stage--suspense > .gp-stage__img,
  .gp-stage--tv.gp-stage--revealed > .gp-stage__img {
    grid-column: 1;
    grid-row: 1 / span 8;
    max-height: 70vh;
  }
  /* Sized to the right-hand column, and a long name breaks between words first. */
  .gp-stage--tv.gp-stage--suspense .gp-stage__title,
  .gp-stage--tv.gp-stage--revealed .gp-stage__title { font-size: clamp(1.8rem, 3.4vw, 4rem); }
  .gp-stage--tv.gp-stage--revealed .gp-stage__wins { font-size: clamp(2rem, 4.4vw, 5.5rem); overflow-wrap: break-word; }
  .gp-stage--tv.gp-stage--suspense .gp-stage__desc,
  .gp-stage--tv.gp-stage--revealed .gp-stage__desc { display: none; }
}

/* The final winners on a TV: the photos give way so every name fits on one screen (1 to 10 prizes). */
.gp-stage--tv .gp-results__img { max-height: 28vh; }
.gp-stage--tv .gp-results__item { align-content: start; }
.gp-stage--tv .gp-results .gp-stage__title { font-size: clamp(1.8rem, 3.6vw, 4rem); }
.gp-stage--tv .gp-results__prize { font-size: clamp(0.9rem, 1.3vw, 1.4rem); }
.gp-stage--tv .gp-results__list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.gp-stage--tv .gp-results__list--n1 { grid-template-columns: minmax(0, 560px); justify-content: center; }
.gp-stage--tv .gp-results__list--n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gp-stage--tv .gp-results__list--n4 .gp-results__img { max-height: 22vh; }
.gp-stage--tv :is(.gp-results__list--n5, .gp-results__list--n6) .gp-results__img { max-height: 20vh; }
.gp-stage--tv :is(.gp-results__list--n7, .gp-results__list--n8, .gp-results__list--n9, .gp-results__list--n10) .gp-results__img { max-height: 14vh; }
.gp-stage--tv :is(.gp-results__list--n7, .gp-results__list--n8, .gp-results__list--n9, .gp-results__list--n10) .gp-results__winner { font-size: clamp(1rem, 1.8vw, 2rem); }
@media (min-width: 1000px) {
  .gp-stage--tv :is(.gp-results__list--n5, .gp-results__list--n6) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gp-stage--tv :is(.gp-results__list--n7, .gp-results__list--n8) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .gp-stage--tv :is(.gp-results__list--n9, .gp-results__list--n10) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.gp-stage--tv .gp-results__item { grid-template-columns: minmax(0, 1fr); text-align: center; }
.gp-stage--tv .gp-results__img { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.gp-stage--tv .gp-results__winner { font-size: clamp(1.4rem, 2.6vw, 2.8rem); }

/* ---- the Admin area ----------------------------------------------------------- */

.gp-admin__state { margin: 0; font-weight: 800; }
.gp-admin__checks { margin: 0; padding-left: 1.1rem; display: grid; gap: 4px; }
.gp-admin__check--ok { color: var(--accent); }
.gp-admin__check--bad { color: var(--danger); }
.gp-admin__prize { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line-soft); min-width: 0; }
.gp-admin__prize-title { margin: 0; overflow-wrap: anywhere; }
.gp-admin__field { display: grid; gap: 4px; }
.gp-admin__input, .gp-admin__select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 16px;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.gp-admin__gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gp-admin__tile { margin: 0; display: grid; gap: 4px; justify-items: start; }
.gp-admin__thumb { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); }
/* A file input's intrinsic width ("Choose Files  No file chosen") is wider than a 320 px card: cap it. */
.gp-admin__file { font-size: 16px; width: 100%; max-width: 100%; min-width: 0; min-height: var(--tap); padding: 8px 0; box-sizing: border-box; }
[data-gp-admin="root"] .ac__block { min-width: 0; }
[data-gp-admin="root"] .ac__quick { flex-wrap: wrap; }
.gp-admin__preview { display: grid; gap: 8px; padding: 10px 0; border-top: 1px dashed var(--line); min-width: 0; }
.gp-admin__controls .btn { min-height: var(--tap); }

/* ---- motion ------------------------------------------------------------------- */

@keyframes gp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes gp-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes gp-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .gp-stage__vault,
  .gp-stage__wins,
  .gp-celebrate::before {
    animation: none;
  }
  .gp-celebrate::before { display: none; }
}

/* ---- Phase 8Q.4 follow-up: the gold ticket, "not announced yet", the Admin board ---- */

.gp-teaser__icon, .gp-stage__icon { justify-self: center; }
.gp-alloc__title { display: flex; align-items: center; gap: 8px; }

.gp-quiet {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  text-align: center;
}
.gp-quiet__line { margin: 0; font-weight: 800; color: var(--warn); }
.gp-quiet__sub { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }

.gp-admin__state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gp-admin__board { display: grid; gap: 4px; margin: 8px 0; }
.gp-admin__board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.gp-admin__board-row dt { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.gp-admin__board-row dd { margin: 0; font-weight: 800; text-align: right; }
.gp-admin__board-value--active, .gp-admin__board-value--on, .gp-admin__board-value--published, .gp-admin__board-value--open { color: var(--accent); }
.gp-admin__board-value--off, .gp-admin__board-value--private, .gp-admin__board-value--closed { color: var(--text-dim); }
.gp-admin__board-value--partial, .gp-admin__board-value--locked { color: var(--warn); }
.gp-admin__structure { margin: 4px 0 8px; }
