/* IMPROVISION — tiré des affiches : bleu royal, noir, blanc, grandes cartes arrondies, pastilles. */
@font-face {
  font-family: 'Lexend';
  src: url('/fonts/lexend.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bleu: #0046c1;
  --bleu-fonce: #00348f;
  --bleu-clair: #e6eefb;
  --noir: #1d1d1b;
  --blanc: #ffffff;
  --rouge: #d7262b;
  --rouge-fonce: #a91b1f;
  --gris: #6b6b68;
  --gris-clair: #ececea;
  --radius-xl: 32px;
  --radius-l: 22px;
  --pill: 999px;
  --gutter: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bleu);
  color: var(--noir);
  font-family: 'Lexend', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--noir); outline-offset: 3px; }
.on-dark :focus-visible, .pill-noir :focus-visible { outline-color: var(--blanc); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* --- Mise en page */
.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.page-wide { max-width: 1200px; }
.card {
  background: var(--blanc);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.card-noir { background: var(--noir); color: var(--blanc); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--gris); }
.card-noir .muted { color: #b9b9b5; }

/* --- Marque */
.wordmark { font-weight: 800; letter-spacing: 0.01em; line-height: 1; margin: 0; }
.wordmark b, .accent { color: var(--bleu); font-weight: 800; }
.card-noir .wordmark b, .card-noir .accent { color: #7ea6ff; }
.tagline { margin: 4px 0 0; font-size: 1.35rem; line-height: 1.1; font-weight: 400; }
.tagline b { color: var(--bleu); font-weight: 800; }
.logo { display: block; height: auto; }

/* --- Pastilles (comme « Chaque histoire est éphémère. ») */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--pill);
  padding: 12px 22px;
  font-weight: 600;
}
.pill-blanc { background: var(--blanc); color: var(--bleu); }
.pill-noir { background: var(--noir); color: var(--blanc); }
a.pill { text-decoration: none; }
a.pill:hover { filter: brightness(0.95); }

/* --- Barre du haut */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--noir);
  color: var(--blanc);
  border-radius: var(--pill);
  padding: 8px 8px 8px 10px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .brand-mark {
  background: var(--blanc);
  border-radius: var(--pill);
  padding: 6px 12px;
  display: flex;
}
.topbar .brand-mark img { height: 26px; width: auto; }
.topbar .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .date-chip {
  background: var(--bleu);
  border-radius: var(--pill);
  padding: 8px 16px;
  font-weight: 700;
  white-space: nowrap;
}

/* --- Formulaires */
label { font-weight: 600; display: block; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select {
  width: 100%;
  min-height: 54px;
  border: 2px solid var(--gris-clair);
  background: var(--blanc);
  border-radius: var(--radius-l);
  padding: 12px 18px;
  font-size: 1.05rem;
}
input:focus { border-color: var(--bleu); outline: none; box-shadow: 0 0 0 4px var(--bleu-clair); }
.btn {
  border: 0;
  border-radius: var(--pill);
  min-height: 54px;
  padding: 12px 26px;
  font-weight: 700;
  font-size: 1.05rem;
  background: var(--bleu);
  color: var(--blanc);
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:hover { background: var(--bleu-fonce); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-noir { background: var(--noir); }
.btn-noir:hover { background: #000; }
.btn-ghost { background: transparent; color: inherit; border: 2px solid currentColor; }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.06); }
.btn-rouge { background: var(--rouge); }
.btn-rouge:hover { background: var(--rouge-fonce); }
.btn-small { min-height: 40px; padding: 8px 16px; font-size: 0.95rem; }
.form-error {
  background: #fdecec;
  color: var(--rouge-fonce);
  border-radius: var(--radius-l);
  padding: 12px 16px;
  font-weight: 600;
  margin: 0;
}

/* --- Accueil */
.welcome { min-height: 100dvh; justify-content: center; }
.welcome .hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.welcome .hero .logo { width: 150px; }
.welcome .wordmark { font-size: 2.1rem; }
.welcome .pills { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* --- Menu des impros */
.menu-title { margin: 0 0 12px; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gris); }
.impro-menu {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.impro-chip {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--pill);
  border: 2px solid var(--gris-clair);
  background: var(--blanc);
  font-weight: 800;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease;
}
.impro-chip:hover { transform: scale(1.05); }
.impro-chip.is-closed { background: var(--gris-clair); color: var(--gris); }
.impro-chip.is-open { background: var(--bleu); border-color: var(--bleu); color: var(--blanc); animation: pulse 1.6s ease-out infinite; }
.impro-chip.is-selected { border-color: var(--noir); border-width: 3px; }
.impro-chip.is-open.is-selected { box-shadow: 0 0 0 3px var(--blanc), 0 0 0 6px var(--noir); }
.impro-chip .voted {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--blanc);
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  color: var(--blanc);
}
.voted.bleu { background: var(--bleu); }
.voted.rouge { background: var(--rouge); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 70, 193, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(0, 70, 193, 0); }
}
@media (min-width: 640px) { .impro-menu { grid-template-columns: repeat(10, 1fr); } }

/* --- Zone de vote */
.vote-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.vote-head h1 { margin: 0; font-size: 2.2rem; line-height: 1; font-weight: 800; }
.vote-head .impro-title { margin: 6px 0 0; font-size: 1.1rem; color: var(--gris); }
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--pill);
  padding: 8px 16px;
  font-weight: 700;
  background: var(--gris-clair);
  color: var(--noir);
  font-variant-numeric: tabular-nums;
}
.status.is-open { background: var(--bleu); color: var(--blanc); }
.status.is-open::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--blanc); animation: blink 1s steps(2) infinite; }
.status.is-urgent { background: var(--rouge); }
@keyframes blink { 50% { opacity: 0.2; } }

.vote-buttons { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 20px; }
@media (min-width: 560px) { .vote-buttons { grid-template-columns: 1fr 1fr; } }
.vote-btn {
  position: relative;
  min-height: max(150px, 24dvh);
  border: 0;
  border-radius: var(--radius-xl);
  color: var(--blanc);
  font-size: clamp(2.4rem, 11vw, 4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.vote-btn.bleu { background: var(--bleu); }
.vote-btn.rouge { background: var(--rouge); }
.vote-btn:hover:not(:disabled) { filter: brightness(1.08); }
.vote-btn:active:not(:disabled) { transform: scale(0.97); }
.vote-btn:disabled { cursor: not-allowed; opacity: 0.35; }
.vote-btn.is-mine { box-shadow: 0 0 0 5px var(--blanc), 0 0 0 10px var(--noir); }
.vote-btn.is-other { opacity: 0.45; }
.vote-btn .mine-tag {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blanc);
  color: var(--noir);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border-radius: var(--pill);
  padding: 4px 12px;
}
.vote-hint { text-align: center; margin: 14px 0 0; }

/* --- Résultats */
.results { margin-top: 22px; }
.results-bar {
  display: flex;
  height: 56px;
  border-radius: var(--pill);
  overflow: hidden;
  background: var(--gris-clair);
}
.results-bar > div {
  display: flex;
  align-items: center;
  color: var(--blanc);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0 18px;
  min-width: 0;
  white-space: nowrap;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.results-bar .bleu { background: var(--bleu); }
.results-bar .rouge { background: var(--rouge); justify-content: flex-end; }
.results-bar > div:empty { padding: 0; }
.results-legend { display: flex; justify-content: space-between; margin-top: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.results-legend .bleu { color: var(--bleu); }
.results-legend .rouge { color: var(--rouge); }
.winner { display: inline-block; margin-top: 10px; }

/* --- Alerte d'ouverture */
.alert {
  position: fixed;
  inset: auto var(--gutter) var(--gutter) var(--gutter);
  max-width: 728px;
  margin: 0 auto;
  z-index: 10;
  background: var(--noir);
  color: var(--blanc);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.alert strong { font-size: 1.3rem; display: block; }
.alert .btn { background: var(--blanc); color: var(--bleu); }
@keyframes rise { from { transform: translateY(120%); } to { transform: none; } }
.flash { animation: flash 0.9s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 8px #ffd400; } }

.offline {
  text-align: center;
  background: #ffd400;
  color: var(--noir);
  border-radius: var(--pill);
  padding: 8px 16px;
  font-weight: 600;
}

/* --- Tableaux (admin, historique) */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--gris-clair); vertical-align: middle; }
th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gris); }
.table-scroll { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Résultats (écran) */
.results-xl .results-bar { height: clamp(90px, 18vw, 200px); }
.results-xl .results-bar > div { font-size: clamp(1.6rem, 6vw, 4rem); padding: 0 clamp(14px, 3vw, 40px); }
.results-xl .results-legend { font-size: clamp(1.1rem, 2.4vw, 2rem); margin-top: 14px; }
.results-xl .winner { font-size: clamp(1.2rem, 3vw, 2.4rem); }
.hero-title { margin: 0; font-size: clamp(3rem, 11vw, 7rem); line-height: 1; font-weight: 800; }
.card-noir .impro-title { margin: 8px 0 0; font-size: clamp(1.2rem, 3.5vw, 2.4rem); color: var(--blanc); }
.card-noir .status { font-size: clamp(1.1rem, 3vw, 2rem); padding: 10px 22px; }
.grid-impros { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.grid-impros .tile { padding: 18px; gap: 8px; }
.tile.is-open { box-shadow: 0 0 0 4px #ffd400; }
.tile .results { margin-top: 0; }
.tile .results-bar { height: 36px; }
.tile .results-bar > div { font-size: 0.9rem; padding: 0 12px; }
.tile-head { justify-content: space-between; }
.night-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.night-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  text-align: left;
  background: var(--bleu-clair);
  border: 2px solid transparent;
  border-radius: var(--radius-l);
  padding: 14px 18px;
}
.night-btn:hover { border-color: var(--bleu); }

/* --- Admin */
.admin-head { justify-content: space-between; }
.impro-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto auto;
  gap: 10px 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-l);
  background: var(--gris-clair);
}
.impro-row.is-open { background: var(--bleu-clair); box-shadow: 0 0 0 3px var(--bleu); }
.impro-row .row { grid-column: 1 / -1; }
.impro-row select { width: auto; min-height: 40px; padding: 6px 14px; }
.impro-row input[type="text"] { min-height: 44px; padding: 8px 14px; }
.impro-num { font-size: 1.4rem; text-align: center; }
.impro-row .counts { font-variant-numeric: tabular-nums; white-space: nowrap; }
.impro-row .counts .bleu { color: var(--bleu); }
.impro-row .counts .rouge { color: var(--rouge); }
@media (min-width: 900px) {
  .impro-row { grid-template-columns: 2.2rem 1fr auto auto auto; }
  .impro-row .row { grid-column: auto; flex-wrap: nowrap; }
}
td input[type="date"], td input[type="number"] { min-height: 44px; padding: 6px 12px; }
td input[type="number"] { width: 90px; }
td input[type="date"] { width: auto; }
tr.is-active td { background: var(--bleu-clair); }
.tag { padding: 4px 12px; margin-left: 8px; font-size: 0.85rem; }
@media (max-width: 899px) {
  .impro-row input[type="text"] { grid-column: 2 / -1; }
  .impro-row .status { grid-column: 1 / 3; justify-self: start; }
}
.card-noir .results-legend .bleu { color: #7ea6ff; }
.card-noir .results-legend .rouge { color: #ff7a7e; }
td .winner { margin: 0; }
