/* ==========================================================================
   BRM Remote — feuille de style commune (page viewer + mentions légales)
   Identité : charte BRM Digital (marine #1e3a5f / #142846, accent #3884de,
   bleu clair #78aaeb, typo Poppins). Thème clair / sombre automatique.
   Pour changer la couleur d'accent du produit : modifier --accent et --primary.
   ========================================================================== */

/* Poppins auto-hébergée (fichiers dans /fonts) : aucune requête vers un tiers. */
@font-face {
  font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap;
  src: local("Poppins Regular"), local("Poppins-Regular"), url("fonts/Poppins-Regular.woff") format("woff");
}
@font-face {
  font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap;
  src: local("Poppins Medium"), local("Poppins-Medium"), url("fonts/Poppins-Medium.woff") format("woff");
}
@font-face {
  font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap;
  src: local("Poppins Bold"), local("Poppins-Bold"), url("fonts/Poppins-Bold.woff") format("woff");
}

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1e3a5f;
  --muted: #5b6b7d;
  --border: #e1e8f1;
  --link: #2c6fc5;
  --primary: #2c6fc5;
  --primary-hover: #245ca3;
  --accent: #4fb0ff;
  --ok: #1fa971;
  --warn: #d9930d;
  --danger: #d33a3a;
  --logo-navy: #1e3a5f;
  --logo-light: #78aaeb;
  --logo-accent: #3884de;
  --footer-bg: #f7f9fc;
  --footer-text: #5b6b7d;
  --shadow: 0 10px 30px rgba(20, 40, 70, .10);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1a2e;
    --surface: #142846;
    --text: #e8eef7;
    --muted: #9fb3c8;
    --border: #243c5e;
    --link: #78aaeb;
    --primary: #2f78d4;
    --primary-hover: #3a86e6;
    --danger: #ff7b7b;
    --logo-navy: #f2f6fc;
    --footer-bg: #142846;
    --footer-text: #9fb3c8;
    --shadow: 0 10px 30px rgba(0, 0, 0, .40);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--link); }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.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;
}

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding-inline: 20px; }

/* ---- En-tête produit --------------------------------------------------- */
.top {
  /* Fine grille diagonale : rappel discret du motif du logo BRM Remote */
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 26px),
    linear-gradient(135deg, #142846 0%, #1e3a5f 62%, #24507f 100%);
  color: #fff;
  padding: calc(22px + env(safe-area-inset-top)) 0 22px;
}
.top .wrap { display: flex; align-items: center; gap: 16px; }
.remote-logo {
  width: 64px; height: 64px; flex: none; border-radius: 16px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.top h1 { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.top .tagline { margin: 4px 0 0; color: #b8cbe3; font-size: .92rem; }

/* ---- Contenu ----------------------------------------------------------- */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 8px 20px 36px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
}
.connect { max-width: 460px; margin: 28px auto 0; text-align: center; }
.connect h2 { margin: 0 0 6px; font-size: 1.25rem; }
.connect p { margin: 0 0 18px; color: var(--muted); font-size: .95rem; }

.code {
  width: 100%;
  font: 700 2rem/1 var(--font);
  letter-spacing: .5em;
  text-align: center;
  padding: 16px 8px 16px calc(8px + .5em);
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 14px;
}
.code::placeholder { color: var(--muted); opacity: .45; }
.code:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(56, 132, 222, .25); }

.btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px;
  font: 600 1rem/1 var(--font);
  border: 0; border-radius: 12px; cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn.ghost:hover { background: rgba(120, 170, 235, .12); }

/* ---- Ligne d'état ------------------------------------------------------ */
.status {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 18px 0 0; min-height: 1.7em;
  color: var(--muted); font-size: .92rem; text-align: center;
}
.status::before {
  content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #9aa8b8;
}
body.connecting .status::before { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
body.live .status::before { background: var(--ok); animation: none; }
body.touch-off .status { color: var(--danger); font-weight: 600; }
body.touch-off .status::before { background: var(--danger); animation: none; }

/* ---- Écran distant ----------------------------------------------------- */
.stage { display: none; margin-top: 18px; }
body.connecting .stage { display: block; }
body.connecting .connect { display: none; }

.stage-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 42px; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.actions .btn { min-height: 42px; padding: 9px 14px; font-size: .9rem; }
.t-quit { display: none; }
body.live .t-quit { display: inline; }
body.live .t-cancel { display: none; }

.screen-wrap {
  position: relative; overflow: hidden;
  background: #050d18; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow);
}
.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-height: 240px; padding: 30px; color: #9fb3c8; text-align: center;
}
.placeholder p { margin: 0; font-size: .95rem; }
body.live .placeholder { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .16); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

#screenImg {
  display: none;
  width: 100%; height: auto;
  max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px);
  object-fit: contain;
  cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-user-drag: none;
}
#screenImg:fullscreen { width: 100vw; height: 100vh; max-height: none; background: #000; }

.hint { display: none; margin: 12px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
body.live .hint { display: block; }

/* ---- Mentions légales -------------------------------------------------- */
.legal { max-width: 780px; margin: 22px auto 0; }
.legal .back { display: inline-block; margin-bottom: 8px; font-size: .92rem; text-decoration: none; }
.legal h2 { margin: 30px 0 8px; font-size: 1.15rem; }
.legal h2:first-of-type { margin-top: 12px; }
.legal p, .legal li { color: var(--text); font-size: .95rem; }
.legal ul { padding-left: 1.2em; }
.legal .muted { color: var(--muted); font-size: .85rem; }
.legal dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.legal dt { color: var(--muted); font-size: .9rem; }
.legal dd { margin: 0; font-size: .95rem; }
@media (max-width: 520px) {
  .legal dl { grid-template-columns: 1fr; gap: 0; }
  .legal dd { margin-bottom: 10px; }
}

/* ---- Pied de page BRM Digital ----------------------------------------- */
.site-footer {
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
  color: var(--footer-text);
  font-size: .8rem;
  text-align: center;
}
.site-footer .brand { display: inline-block; height: 44px; margin-bottom: 12px; }
.brm-logo { display: block; height: 100%; width: auto; }
.site-footer .links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 18px;
  margin: 4px 0 8px; font-size: .82rem;
}
.site-footer .links a { white-space: nowrap; text-decoration: none; }
.site-footer .links a:hover { text-decoration: underline; }
.site-footer p { margin: 4px 0; }
.site-footer .siret { font-size: .75rem; opacity: .85; }

/* Logo BRM Digital en ligne (suit le thème clair / sombre) */
.lg-navy-s { stroke: var(--logo-navy); }
.lg-light-s { stroke: var(--logo-light); }
.lg-accent-s { stroke: var(--logo-accent); }
.lg-navy-f { fill: var(--logo-navy); }
.lg-brm { fill: var(--logo-navy); font: 700 78px var(--font); }
.lg-digital { fill: var(--logo-accent); font: 500 40px var(--font); }

/* ---- Animations -------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (min-width: 720px) {
  .top h1 { font-size: 1.9rem; }
  .remote-logo { width: 72px; height: 72px; }
}
