/* ============================================================
   Télé — image plein cadre, chrome discret.
   Le rétro passe par la typo, le grain et la palette : aucun
   meuble, aucun bouton en relief.
   ============================================================ */

:root {
  --bg: #0a0a0b;
  --panel: rgba(18, 18, 20, .82);
  --panel-line: rgba(255, 255, 255, .09);

  --ink: #ece7df;
  --ink-dim: #8e8880;

  /* Ambre de phosphore : l'unique accent, rétro sans pastiche. */
  --accent: #ffb45e;
  --accent-soft: rgba(255, 180, 94, .16);

  --radius: 12px;
  --chrome-h: 60px;

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .9, .3, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* Le curseur disparaît avec le chrome, en lecture seulement. */
.app[data-chrome="hidden"][data-state="playing"] { cursor: none; }

/* ============================================================
   Image
   ============================================================ */

.stage { position: absolute; inset: 0; }

#video, #noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#video {
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity .3s ease;
}
#video[data-live="1"] { opacity: 1; }

#noise {
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity .2s linear;
}
#noise[data-on="1"] { opacity: .5; }

/* Décrochage vertical bref au changement de chaîne. */
.app[data-roll="1"] #video,
.app[data-roll="1"] #noise { animation: roll .34s linear; }

@keyframes roll {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-4%); }
  75%  { transform: translateY(2%); }
  100% { transform: translateY(0); }
}

/* ── Couches CRT : présentes mais tenues très bas ─────────────────────────
   L'écran d'un poste moderne ne fait pas de rayures visibles ; c'est
   l'impression qu'on cherche, pas l'imitation. */

.crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.crt--scan {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .22) 0 1px,
    transparent 1px 3px);
  opacity: .35;
  mix-blend-mode: multiply;
}

/* Grain : un bruit SVG figé, bien moins coûteux qu'un canvas animé. */
.crt--grain {
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.crt--vignette {
  background: radial-gradient(125% 110% at 50% 48%,
    transparent 55%, rgba(0, 0, 0, .5) 100%);
}

/* ============================================================
   Incrustations
   ============================================================ */

.osd {
  position: absolute;
  top: clamp(20px, 5vh, 54px);
  left: clamp(20px, 4vw, 54px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .28s var(--ease), transform .28s var(--ease);
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .9);
}
.osd[data-show="1"] { opacity: 1; transform: none; }

.osd-num {
  font-family: var(--mono);
  font-size: clamp(40px, 7vw, 84px);
  font-weight: 600;
  line-height: .9;
  letter-spacing: -.02em;
  color: var(--accent);
}

.osd-name {
  font-size: clamp(11px, 1.5vw, 16px);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink);
}

.status {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  margin: 0;
  transform: translate(-50%, -50%);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(8px);
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.status[data-show="1"] { opacity: 1; }

/* ============================================================
   Barre de commande
   ============================================================ */

.chrome {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 3vh, 30px);
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--chrome-h);
  max-width: min(760px, calc(100vw - 24px));
  width: max-content;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--panel-line);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}

.app[data-chrome="hidden"] .chrome {
  opacity: 0;
  transform: translateX(-50%) translateY(14px);
  pointer-events: none;
}

.spacer { flex: 1; min-width: 4px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .09); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:where(.icon-btn, .badge, .tab, .splash-btn):focus-visible,
.search:focus-visible,
.range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.now {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  min-width: 0;
}

/* Aucun fond ni cadre : les logos sont des PNG détourés, et le moindre aplat
   derrière eux se voit comme une vignette rapportée. `contain` parce que les
   proportions varient du tout au tout d'une chaîne à l'autre. */
.now-logo {
  flex: none;
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .45));
}

/* Une largeur plancher : sans elle, la barre d'avancement se réduit à un
   trait de quelques pixels quand le nom de l'émission est court. */
.now-text {
  min-width: min(230px, 40vw);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.now-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }

.now-num {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.now-name {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

.now-prog {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--ink-dim);
}

.now-prog-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30ch;
}

.now-prog-left { flex: none; font-family: var(--mono); font-size: 10.5px; }

/* Barre d'avancement, partagée par la barre de commande et la liste. */
.bar {
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .18);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s linear;
}

/* Celle de la chaîne à l'antenne : pleine largeur et légèrement plus marquée,
   c'est l'information que l'on regarde en cours de lecture. */
.now-bar {
  width: 100%;
  height: 4px;
  box-shadow: 0 0 10px -2px var(--accent);
}

/* ── Volume ── */

.volume { display: flex; align-items: center; gap: 2px; }

.range {
  width: 84px;
  height: 22px;
  flex: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 70%),
                              rgba(255, 255, 255, .18) var(--fill, 70%));
}
.range::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255,255,255,.18); }
.range::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
.range::-webkit-slider-thumb {
  appearance: none;
  width: 11px; height: 11px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--ink);
}
.range::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--ink); }

.badge {
  flex: none;
  padding: 5px 9px;
  border: 1px solid var(--panel-line);
  border-radius: 7px;
  background: transparent;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.badge:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   Tiroir des chaînes
   ============================================================ */

.drawer {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  z-index: 30;
  width: min(370px, 88vw);
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 14, .93);
  backdrop-filter: blur(20px) saturate(1.2);
  border-right: 1px solid var(--panel-line);
  transform: translateX(-101%);
  transition: transform .32s var(--ease);
}
.drawer[data-open="1"] { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 10px;
}

.search {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .05);
  font-size: 14px;
}
.search::placeholder { color: var(--ink-dim); }
.search:focus { border-color: var(--accent); outline: none; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--panel-line);
}

.category {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.category:focus { border-color: var(--accent); outline: none; }
/* Le menu déroulant est dessiné par le système : sans fond sombre explicite,
   ses options s'affichent en clair sur clair chez plusieurs navigateurs. */
.category option { background: #16161a; color: var(--ink); }

.chan-list {
  flex: 1;
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.chan {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.chan:hover { background: rgba(255, 255, 255, .06); }
.chan[aria-current="true"] { background: var(--accent-soft); }
.chan[aria-current="true"] .chan-name { color: var(--accent); }

.chan-num {
  flex: none;
  width: 2.5ch;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink-dim);
}

.chan-logo {
  flex: none;
  width: 32px;
  height: 32px;
  object-fit: contain;
  /* Une fois détourés, les logos sombres — le « 2 » noir de France 2 — se
     fondent dans le fond. Ce halo très léger les décolle sans rien ajouter
     qui ressemble à un cadre. */
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .45));
}
/* Une chaîne sans logo garde son gabarit : sans cela la colonne des noms
   danse d'une ligne à l'autre. */
.chan-logo[data-empty="1"] { visibility: hidden; }

.chan-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.chan-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chan-prog {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--ink-dim);
  min-width: 0;
}
.chan-prog-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chan-bar { flex: none; width: 42px; }

.chan-fav {
  flex: none;
  width: 26px;
  text-align: center;
  font-size: 13px;
  line-height: 1;
  color: rgba(255, 255, 255, .18);
  transition: color .15s ease, transform .1s ease;
}
.chan-fav[data-fav="1"] { color: var(--accent); }
.chan-fav:hover { transform: scale(1.25); color: var(--accent); }

.drawer-note {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--panel-line);
}
.drawer-note b { color: var(--accent); font-weight: 500; }

.drawer-foot {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--panel-line);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ============================================================
   Accueil
   ============================================================ */

.splash {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(80% 60% at 50% 40%, #141416 0%, var(--bg) 70%);
  transition: opacity .45s ease, visibility .45s;
}
/* Une fois le poste allumé, l'accueil ne revient jamais : lister ici les états
   « réussis » le ferait réapparaître sur un échec d'accord, en travers du
   message d'erreur. C'est l'état initial qui l'affiche, et lui seul. */
.app:not([data-state="idle"]) .splash { opacity: 0; visibility: hidden; }

.splash-title {
  margin: 0;
  font-size: clamp(38px, 9vw, 76px);
  font-weight: 300;
  letter-spacing: .34em;
  text-indent: .34em;
  text-transform: uppercase;
  color: var(--accent);
}

.splash-sub {
  margin: -8px 0 0;
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* Avertissement : phrase entière, donc ni majuscules ni interlettrage forcés. */
.splash-sub[data-warn="1"] {
  max-width: 52ch;
  text-transform: none;
  letter-spacing: .01em;
  line-height: 1.5;
  color: var(--accent);
}

.splash-btn {
  padding: 13px 40px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, opacity .2s ease;
}
.splash-btn:hover:not(:disabled) { background: var(--accent); color: #14100a; }
.splash-btn:disabled { opacity: .35; cursor: default; border-color: var(--ink-dim); color: var(--ink-dim); }

.splash-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  margin-right: 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .5);
  color: var(--ink);
}

/* ============================================================
   Petits écrans
   ============================================================ */

@media (max-width: 560px) {
  :root { --chrome-h: 54px; }
  .chrome { gap: 2px; padding: 0 6px; left: 12px; right: 12px; transform: none; width: auto; max-width: none; }
  .app[data-chrome="hidden"] .chrome { transform: translateY(14px); }
  .now-name { display: none; }
  .range { width: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .app[data-roll="1"] #video,
  .app[data-roll="1"] #noise { animation: none; }
  .drawer, .chrome, .osd, .splash { transition-duration: .01ms; }
}
