/* Le jeu des candidats 2027. No external resources: system fonts only. */

:root {
  --bg: #0d1440;
  --bg-raised: #17215c;
  --bg-sunk: #0a0f30;
  --ink: #f4f6ff;
  --muted: #b9c2ea;
  --yellow: #ffd31a;
  --outline: #182a7e;
  --silhouette: #2a4cc8;
  --cyan: #7fe3ff;
  --red: #e3262f;
  --bad: #ffb0b0;
  --radius: 16px;
  --font-display: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, #23339a 0, transparent 60%),
    radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.06) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
}

body:has(dialog[open]) {
  overflow: hidden;
}

a {
  color: var(--cyan);
}

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

/* Display type: bold yellow with a dark outline drawn behind the fill. */
.display-title,
.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--yellow);
  -webkit-text-stroke: 0.09em var(--outline);
  paint-order: stroke fill;
  text-shadow: 0.03em 0.06em 0 var(--outline);
  text-wrap: balance;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 0.55em 1.1em;
  border: 2px solid rgb(255 255 255 / 0.55);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover:not(:disabled) {
  border-color: var(--ink);
  background: rgb(255 255 255 / 0.08);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #11195a;
}

.btn-primary:hover:not(:disabled) {
  border-color: #ffe366;
  background: #ffe366;
}

.btn-ghost {
  border-color: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.btn-light {
  border-color: #fff;
  background: #fff;
  color: #1a0306;
}

.btn-light:hover:not(:disabled) {
  background: #ffe9ea;
}

.btn-ghost-light {
  border-color: rgb(255 255 255 / 0.7);
  color: #fff;
}

/* ---------- Page ---------- */

.site-header {
  padding: clamp(1.25rem, 4vw, 2.5rem) 16px 0.75rem;
  text-align: center;
}

.site-header-inner,
.site-main,
.site-footer {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.site-title {
  font-size: clamp(2.1rem, 9vw, 4rem);
}

.site-title span {
  display: inline-block;
}

.site-tagline {
  margin: 0.6rem auto 0;
  max-width: 34rem;
  color: var(--muted);
}

.progress {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin: 1rem 0 0;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid rgb(255 255 255 / 0.12);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-stars {
  color: var(--yellow);
}

.offline-note {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.site-main {
  flex: 1;
  padding: 1rem 16px 2rem;
}

.site-footer {
  padding: 1rem 16px 2rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.status {
  max-width: 30rem;
  margin: 2rem auto;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--bg-raised);
  text-align: center;
}

.status:empty {
  display: none;
}

.status h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

.status p {
  margin: 0 0 1rem;
  color: var(--muted);
}

/* ---------- Grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 40vw), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 3px solid rgb(255 255 255 / 0.14);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tile:hover {
  transform: translateY(-3px);
  border-color: var(--yellow);
}

.tile.is-hidden {
  background:
    radial-gradient(circle at 50% 42%, rgb(127 227 255 / 0.55) 0, rgb(47 140 255 / 0.25) 30%, transparent 55%),
    repeating-conic-gradient(from 0deg at 50% 42%, #1d2c86 0deg 9deg, #16226b 9deg 18deg);
}

.tile.is-done {
  background: radial-gradient(circle at 50% 40%, #ffffff 0, #dfe6ff 70%);
  color: #11195a;
}

.tile-figure {
  position: absolute;
  inset: 8% 8% 20%;
  width: 84%;
  height: 72%;
}

img.tile-figure {
  object-fit: contain;
}

.tile-number {
  position: absolute;
  inset: auto 0 6% 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--yellow);
  -webkit-text-stroke: 0.08em var(--outline);
  paint-order: stroke fill;
}

.tile-caption {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.4rem 0.45rem;
  background: rgb(255 255 255 / 0.9);
  line-height: 1.2;
}

.tile-name {
  font-weight: 800;
  font-size: 0.9rem;
}

.tile-stars {
  color: #c48a00;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 0 0 2px #fff;
}

/* ---------- Silhouettes: the cutout used as a mask over a flat colour ---------- */

.silhouette {
  background: var(--silhouette);
  -webkit-mask: var(--mask) center / contain no-repeat;
  mask: var(--mask) center / contain no-repeat;
}

.silhouette.is-unknown {
  display: grid;
  place-items: center;
  -webkit-mask: none;
  mask: none;
  background: none;
}

.silhouette.is-unknown::after {
  content: "?";
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 6rem);
  color: var(--silhouette);
  -webkit-text-stroke: 0.04em #fff;
  paint-order: stroke fill;
}

/* ---------- Dialogs ---------- */

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(4 7 28 / 0.82);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 2px solid rgb(255 255 255 / 0.6);
  border-radius: 50%;
  background: rgb(10 15 48 / 0.85);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Guess screen ---------- */

.guess-dialog {
  width: min(720px, calc(100vw - 2rem));
  max-width: 100vw;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  border-radius: 20px;
  box-shadow: 0 0 0 4px var(--outline), 0 30px 80px rgb(0 0 0 / 0.6);
}

@media (max-width: 600px) {
  .guess-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

.guess-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 16px 1.5rem;
}

.guess-content .display-title {
  padding-right: 48px;
  font-size: clamp(1.8rem, 7.5vw, 3rem);
}

.guess-content .display-title:focus {
  outline: none;
}

.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: var(--radius);
  background: var(--red);
  isolation: isolate;
}

@media (min-width: 601px) {
  .stage {
    aspect-ratio: 16 / 9;
  }
}

/* Ray burst: blue-cyan glow at the centre fading into alternating red rays. */
.stage::before {
  content: "";
  position: absolute;
  inset: -50%;
  z-index: -1;
  background:
    radial-gradient(circle, #f2fdff 0 5%, var(--cyan) 12%, #2f8cff 22%, rgb(47 140 255 / 0) 36%),
    repeating-conic-gradient(from 0deg, #d21f2a 0deg 7deg, #ff6b3d 7deg 14deg);
  animation: spin 40s linear infinite;
}

.stage-figure {
  position: absolute;
  inset: 7% 30% 5% 6%;
  width: 64%;
  height: 88%;
}

.stage.is-revealed .stage-figure {
  inset: 5% 12%;
  width: 76%;
  height: 90%;
}

.stage-photo {
  object-fit: contain;
  filter: drop-shadow(0 6px 0 rgb(0 0 0 / 0.25));
}

.stage.flash .stage-photo {
  animation: pop 0.6s ease-out both;
}

.stage.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  pointer-events: none;
  animation: flash 0.7s ease-out forwards;
}

.big-question {
  position: absolute;
  top: 50%;
  right: 7%;
  font-family: var(--font-display);
  font-size: clamp(6rem, 30vw, 10rem);
  line-height: 1;
  color: var(--yellow);
  -webkit-text-stroke: 0.06em var(--outline);
  paint-order: stroke fill;
  text-shadow: 0.04em 0.05em 0 var(--outline);
  transform: translateY(-50%) rotate(10deg);
  animation: bob 2.4s ease-in-out infinite;
}

.guess-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.guess-form label {
  font-weight: 700;
}

.guess-row {
  display: flex;
  gap: 0.5rem;
}

.guess-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0.5rem 0.9rem;
  border: 2px solid rgb(255 255 255 / 0.4);
  border-radius: 12px;
  background: var(--bg-sunk);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
}

.guess-row input:focus {
  border-color: var(--yellow);
  outline: none;
}

.feedback {
  min-height: 1.5em;
  margin: 0;
  color: var(--bad);
  font-weight: 700;
}

.shake {
  animation: shake 0.4s ease;
}

.hints {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stars-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  font-weight: 700;
}

.stars {
  color: var(--yellow);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.anecdotes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding-left: 1.4rem;
}

.anecdotes:empty {
  display: none;
}

.anecdotes li::marker {
  color: var(--yellow);
  font-weight: 800;
}

.credit {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.reveal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.reveal-stats p {
  margin: 0;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--bg-raised);
}

.reveal-stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--yellow);
}

/* ---------- Challenger screen ---------- */

.challenger-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #2b0a10 0, #0b0406 70%);
  color: #fff;
  cursor: pointer;
}

.challenger-dialog::backdrop {
  background: #000;
}

.embers {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.challenger-scene {
  position: absolute;
  inset: 0;
  animation: quake 0.35s ease-out 0.75s;
}

.challenger-burst {
  position: absolute;
  top: 34%;
  left: 50%;
  z-index: 1;
  width: min(95vmin, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0, #fff4c4 12%, rgb(255 205 90 / 0.65) 28%, rgb(255 90 40 / 0.2) 48%, transparent 66%);
  transform: translate(-50%, -50%);
  animation: burst 0.6s ease-out both, glow 2.2s ease-in-out 0.6s infinite;
}

.challenger-figure {
  position: absolute;
  top: 5%;
  left: 50%;
  z-index: 3;
  width: min(70vw, 440px);
  height: 52%;
  background: #000;
  transform: translateX(-50%);
  animation: figure-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.challenger-band {
  position: absolute;
  top: 50%;
  left: -5%;
  z-index: 4;
  width: 110%;
  height: 27%;
  background: linear-gradient(90deg, #6d0712, #d9172a 35%, #ff3044 55%, #a20d1c);
  clip-path: polygon(0 22%, 100% 0, 100% 78%, 0 100%);
  box-shadow: 0 0 40px rgb(255 40 60 / 0.6);
  transform-origin: left center;
  animation: band-in 0.35s ease-out 0.1s both;
}

.challenger-title {
  position: absolute;
  top: 52%;
  left: 50%;
  z-index: 5;
  width: 94%;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 8vw, 4.6rem);
  font-style: italic;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  -webkit-text-stroke: 0.06em #2a0308;
  paint-order: stroke fill;
  text-shadow: 0.05em 0.07em 0 #3d0510;
  transform: translateX(-50%) rotate(-5deg) skewX(-10deg);
  animation: slam 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) 0.35s both;
}

.challenger-title span {
  display: block;
}

.challenger-sub {
  position: absolute;
  top: 80%;
  left: 0;
  z-index: 5;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0;
  border-block: 2px solid var(--red);
  background: rgb(20 3 6 / 0.9);
  font-size: clamp(0.8rem, 2.6vw, 1.1rem);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  color: #ffd9dc;
  animation: sub-in 0.4s ease-out 0.7s both;
}

.challenger-actions {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  padding: 0 16px;
}

.challenger-count {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffd9dc;
}

/* ---------- Motion ---------- */

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes bob {
  50% {
    transform: translateY(-56%) rotate(4deg);
  }
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    transform: scale(0.85);
  }
  60% {
    transform: scale(1.04);
  }
  to {
    transform: scale(1);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

@keyframes burst {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
}

@keyframes glow {
  50% {
    transform: translate(-50%, -50%) scale(1.06);
  }
}

@keyframes figure-in {
  from {
    opacity: 0;
    transform: translateX(10%) scale(1.15);
  }
}

@keyframes band-in {
  from {
    transform: scaleX(0);
  }
}

@keyframes slam {
  from {
    opacity: 0;
    transform: translateX(-50%) rotate(-5deg) skewX(-10deg) scale(2.8);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) rotate(-5deg) skewX(-10deg) scale(1);
  }
}

@keyframes sub-in {
  from {
    opacity: 0;
    transform: translateX(-12%);
  }
}

@keyframes quake {
  25% {
    transform: translate(-5px, 3px);
  }
  50% {
    transform: translate(4px, -3px);
  }
  75% {
    transform: translate(-2px, 2px);
  }
}

/* Static versions of both screens: no rotation, slam, shake, flash or particles. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .tile:hover {
    transform: none;
  }
}
