/* RPM Live — styles (même univers que relaispopulaire.fr) */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --bg: #050605;
  --bg-2: #0b0e0c;
  --bg-3: #111613;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.18);
  --text: #f3f5f2;
  --text-2: #b6bdb7;
  --text-3: #8a938c;
  --green: #2fa346;
  --red: #ff4d3d;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En-tête */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.03em; text-decoration: none; font-size: 1.15rem; }
.sphere {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 70% 31%, #3cae51 0%, #208435 24%, #125c27 54%, #093d1c 84%, #052b14 100%);
  box-shadow: 0 0 18px rgba(35, 145, 58, 0.45);
}
.top__link { color: var(--text-2); text-decoration: none; font-size: 0.92rem; }
.top__link:hover { color: var(--text); }

/* Mise en page lecteur + chat */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: calc(100vh - 57px);
}
.stage { padding: clamp(14px, 2.4vw, 28px); min-width: 0; }
.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 57px); position: sticky; top: 0; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: none; height: 70vh; position: static; }
}

/* Lecteur */
.player {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: #000; aspect-ratio: 16 / 9;
  box-shadow: 0 0 0 1px var(--line);
}
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player__badges { position: absolute; z-index: 3; top: 12px; left: 12px; display: flex; gap: 8px; pointer-events: none; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(5, 6, 5, 0.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pill--live { background: var(--red); color: #fff; }
.pill--live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.player__unmute {
  position: absolute; z-index: 3; right: 12px; top: 12px;
  border: 0; border-radius: 999px; padding: 9px 14px; cursor: pointer;
  background: #fff; color: #050605; font-weight: 700; font-size: 0.9rem;
}
.player__offline {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(60% 80% at 70% 20%, rgba(35, 145, 58, 0.35), transparent 60%), #070a08;
}
.player__offline .sphere { display: block; width: clamp(56px, 10vw, 110px); height: clamp(56px, 10vw, 110px); margin: 0 auto 18px; }
.player__offline h2 { margin: 0 0 6px; font-size: clamp(1.3rem, 3vw, 2rem); letter-spacing: -0.03em; }
.player__offline p { margin: 0; color: var(--text-2); max-width: 46ch; }
[hidden] { display: none !important; }

.info { margin-top: 18px; }
.info h1 { margin: 0; font-size: clamp(1.25rem, 2.4vw, 1.8rem); letter-spacing: -0.03em; line-height: 1.15; }
.info p { margin: 8px 0 0; color: var(--text-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  text-decoration: none; font-weight: 650; font-size: 0.92rem; cursor: pointer;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.5); }
.btn--green { background: var(--green); border-color: var(--green); color: #03130a; }
.btn--danger { border-color: rgba(255, 77, 61, 0.5); color: #ffb3aa; }

/* Chat */
.chat__head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chat__head h2 { margin: 0; font-size: 1rem; }
.chat__state { color: var(--text-3); font-size: 0.82rem; }
.chat__list { list-style: none; margin: 0; padding: 12px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.chat__msg { font-size: 0.94rem; line-height: 1.4; overflow-wrap: anywhere; }
.chat__msg b { color: #7fd48f; font-weight: 700; margin-right: 6px; }
.chat__empty { color: var(--text-3); font-size: 0.9rem; }
.chat__form { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 8px; }
.chat__form input {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: #070908;
}
.chat__form input:focus { outline: none; border-color: var(--green); }
.chat__row { display: flex; gap: 8px; }
.chat__row input { flex: 1; }
.chat__error { color: #ffb3aa; font-size: 0.84rem; min-height: 1em; margin: 0; }

/* Intégration (iframe sur relaispopulaire.fr) */
body.embed { background: #000; overflow: hidden; }
body.embed .player { border-radius: 0; box-shadow: none; height: 100vh; aspect-ratio: auto; }
body.embed.with-chat { display: grid; grid-template-columns: minmax(0, 1fr) 320px; height: 100vh; }
body.embed.with-chat .player { height: 100vh; }
body.embed.with-chat .side {
  height: 100vh; max-height: 100vh; position: static; min-height: 0;
  border-top: 0; border-left: 1px solid var(--line); background: var(--bg);
}
@media (max-width: 720px) {
  body.embed.with-chat { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  body.embed.with-chat .player { height: auto; aspect-ratio: 16 / 9; }
  body.embed.with-chat .side { height: auto; max-height: none; border-left: 0; border-top: 1px solid var(--line); }
}

/* Administration */
.admin { max-width: 980px; margin: 0 auto; padding: clamp(16px, 3vw, 36px); }
.admin h1 { letter-spacing: -0.04em; margin: 0 0 6px; }
.card { border: 1px solid var(--line); background: var(--bg-2); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 0.86rem; color: var(--text-2); font-weight: 600; }
.field input[type=text], .field input[type=password] {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: #070908; width: 100%;
}
.copy { display: flex; gap: 8px; }
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 10px 12px; border-radius: 10px; background: #070908; border: 1px solid var(--line); font-size: 0.86rem; }
.muted { color: var(--text-3); font-size: 0.88rem; }
.stat { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: #070908; border: 1px solid var(--line); font-size: 0.9rem; }
.list li span { overflow-wrap: anywhere; }
.list li .btn { min-height: 32px; padding: 0 10px; font-size: 0.8rem; flex: none; }
.toggle { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

/* Administration : compléments */
.top__right { display: flex; align-items: center; gap: 14px; }
.btn--small { min-height: 34px; padding: 0 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.is-armed { background: var(--red); border-color: var(--red); color: #fff; }
.admin > h1, .admin [data-dash] > h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); margin-top: 8px; }
.admin h3 { margin: 22px 0 10px; font-size: 0.95rem; color: var(--text-2); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.grid3 .card { margin-top: 16px; }
.stat { margin: 0; }
.stat.is-live { color: var(--red); }
.card p { margin: 0 0 10px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card__head h2 { margin: 0; }
.login { max-width: 460px; margin: 8vh auto 0; }
.login h1 { font-size: 1.5rem; margin-bottom: 4px; }
.form-error { color: #ffb3aa; font-size: 0.9rem; min-height: 1.2em; margin: 10px 0 0; }
.notice { border: 1px solid rgba(255, 77, 61, 0.45); background: rgba(255, 77, 61, 0.1); color: #ffd0ca; border-radius: 12px; padding: 12px 14px; }
.field .label { font-size: 0.86rem; color: var(--text-2); font-weight: 600; }
.copy code.is-masked { letter-spacing: 0.12em; color: var(--text-3); }
.copy .btn { flex: none; }
.more { margin: 4px 0 14px; }
.more summary { cursor: pointer; color: var(--text-2); font-size: 0.9rem; margin-bottom: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 10px; }
.list li .actions { display: flex; gap: 6px; flex: none; }
.list li .msg b { color: #7fd48f; margin-right: 2px; }
.list li small { font-size: 0.78rem; }
.toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.toast {
  position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translateX(-50%);
  margin: 0; padding: 10px 16px; border-radius: 999px; max-width: calc(100vw - 32px);
  background: #f3f5f2; color: #050605; font-weight: 650; font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
@media (max-width: 640px) {
  .copy { flex-wrap: wrap; }
  .copy code { flex-basis: 100%; }
  .admin-page .top__link { display: none; }
}

/* Attente : connexion au direct, coupure 4G, chargement */
.player__wait {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center;
  background: rgba(5, 6, 5, 0.55); pointer-events: none;
}
.player__wait p { margin: 0; font-weight: 650; font-size: 0.95rem; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .pill--live::before { animation: none; }
}

/* Petits écrans : le bouton « Activer le son » passe en bas, au-dessus des commandes */
@media (max-width: 520px) {
  .player__unmute { top: auto; bottom: 54px; right: 10px; padding: 7px 12px; font-size: 0.82rem; }
  .pill { font-size: 0.68rem; padding: 4px 9px; }
}

/* Partage entre spectateurs */
.p2p { margin: 14px 0 0; color: var(--text-3); font-size: 0.82rem; line-height: 1.45; max-width: 70ch; }
.p2p__btn {
  background: none; border: 0; padding: 0; margin-left: 6px; cursor: pointer;
  color: var(--text-2); font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.p2p__btn:hover { color: var(--text); }
.p2p--small { margin: 0; padding: 0 12px 10px; font-size: 0.74rem; }
/* Pendant un message d'attente, le bouton « Activer le son » s'efface pour ne pas le cacher */
.player__wait:not([hidden]) ~ .player__unmute { display: none; }
.lan { border: 1px solid rgba(47, 163, 70, 0.45); background: rgba(47, 163, 70, 0.08); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.lan p { margin: 0 0 8px; }
.lan .copy + p { margin-top: 10px; }
