/* =========================================================
   Style visuel — mode sombre (violet/turquoise) et
   mode clair (ciel bleu) d'après les maquettes Figma
   ========================================================= */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --border: 2px solid var(--line);
  --gap: 14px;
}

/* ---------- Mode sombre (par défaut) ---------- */
:root,
:root[data-theme="dark"] {
  --page: #000;
  --line: #ffffff;
  --panel: rgba(28, 28, 30, .94);
  --panel-blur: 0px;
  --text: #ffffff;
  --text-dim: #9a9aa3;
  --player-top: #6c55b0;
  --player-bot: #2a1f4d;
  --info-bg: #5a4699;
  --thumb-bg: #2e2e33;
  --accent: #b77dff;
  --pill-top: #ffffff;
  --pill-bot: #b9b9b9;
  --pill-text: #111;
  --band-a: #8a00d4;
  --band-b: #0b6f86;
  --band-c: #5a0aa0;
}

/* ---------- Mode clair ---------- */
:root[data-theme="light"] {
  --page: #1d5aa8;
  --line: #ffffff;
  --panel: rgba(96, 150, 196, .55);
  --panel-blur: 10px;
  --text: #ffffff;
  --text-dim: #e1ecf8;
  --player-top: #9cc0f0;
  --player-bot: #1f4c9c;
  --info-bg: #2f70c4;
  --thumb-bg: rgba(255, 255, 255, .25);
  --accent: #ffffff;
  --pill-top: #ffffff;
  --pill-bot: #c2c2c2;
  --pill-text: #111;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .4s;
}
img { display: block; max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Arrière-plan animé ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg span {
  position: absolute; width: 22vmax; height: 180vmax; top: -40vmax;
  border-radius: 50%; filter: blur(30px); opacity: .9;
  transform: rotate(28deg);
  transition: background .6s, opacity .6s, border-radius .6s, width .6s, height .6s, filter .6s;
  animation: drift 24s ease-in-out infinite alternate;
}
:root[data-theme="dark"] .bg span:nth-child(1) { left: -8vw;  background: linear-gradient(var(--band-b), transparent 70%); }
:root[data-theme="dark"] .bg span:nth-child(2) { left: 16vw;  background: linear-gradient(transparent, var(--band-a) 40%, transparent 90%); animation-delay: -6s; }
:root[data-theme="dark"] .bg span:nth-child(3) { left: 44vw;  background: linear-gradient(transparent 10%, var(--band-c) 50%, transparent); width: 14vmax; animation-delay: -12s; }
:root[data-theme="dark"] .bg span:nth-child(4) { left: 64vw;  background: linear-gradient(var(--band-a), transparent 60%); animation-delay: -3s; }
:root[data-theme="dark"] .bg span:nth-child(5) { left: 88vw;  background: linear-gradient(transparent, var(--band-b) 60%); animation-delay: -9s; }

/* Mode clair : ciel + nuages */
:root[data-theme="light"] body {
  background: linear-gradient(180deg, #0d3f8f 0%, #2a6fc0 55%, #4f93d4 100%);
}
:root[data-theme="light"] .bg span {
  background: radial-gradient(closest-side, #fff 0%, #e8f3ff 45%, rgba(255,255,255,0) 100%);
  border-radius: 45% 55% 50% 50%;
  width: 34vmax; height: 22vmax; transform: none; filter: blur(8px); opacity: .95;
  animation-name: cloud; animation-duration: 60s;
}
:root[data-theme="light"] .bg span:nth-child(1) { left: -6vw; top: 4vh; }
:root[data-theme="light"] .bg span:nth-child(2) { left: 30vw; top: -6vh; width: 40vmax; }
:root[data-theme="light"] .bg span:nth-child(3) { left: 78vw; top: 6vh; }
:root[data-theme="light"] .bg span:nth-child(4) { left: 0vw;  top: 60vh; width: 26vmax; }
:root[data-theme="light"] .bg span:nth-child(5) { left: 60vw; top: 70vh; width: 44vmax; }

@keyframes drift { to { transform: rotate(32deg) translateX(4vw); } }
@keyframes cloud { to { transform: translateX(6vw); } }
@media (prefers-reduced-motion: reduce) { .bg span { animation: none; } }

/* ---------- Mise en page ---------- */
.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 16px 24px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 200px;
  grid-template-areas:
    "top top top"
    "lib main rec"
    "pop pop pop"
    "foot foot foot";
  gap: var(--gap);
}
.topbar   { grid-area: top; }
.side:first-of-type { grid-area: lib; }
.stage-wrap { grid-area: main; }
.side:last-of-type  { grid-area: rec; }
.popular  { grid-area: pop; }
.credit   { grid-area: foot; text-align: center; font-size: 12px; color: var(--text-dim); opacity: .8; }

.panel {
  background: var(--panel);
  border: var(--border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(var(--panel-blur));
  backdrop-filter: blur(var(--panel-blur));
  transition: background .4s;
}
h2 { margin: 0 0 12px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }

/* ---------- En-tête ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 14px; }
.account { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--text);
  transition: transform .15s, background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.home svg { width: 28px; height: 28px; }

.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }

.pill {
  display: inline-block;
  padding: 8px 18px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--pill-top), var(--pill-bot));
  color: var(--pill-text); font-size: 13px; font-weight: 600; text-decoration: none;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 2px 6px rgba(0,0,0,.25);
  transition: transform .15s, filter .15s;
}
.pill:hover { filter: brightness(1.06); }
.pill:active { transform: translateY(1px); }

/* ---------- Colonnes latérales ---------- */
.side { padding: 14px 10px 14px 12px; display: flex; flex-direction: column; }
.track-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.track {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 4px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left;
}
.track:hover, .track.current { background: rgba(255,255,255,.1); }
.track img { width: 50px; height: 50px; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--thumb-bg); flex: none; }
.track span { min-width: 0; }
.track strong, .track small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track strong { font-size: 12px; font-weight: 600; }
.track small { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.side > .pill, .side-btns { align-self: center; }
.side-btns { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.side-btns .pill { min-width: 120px; padding: 6px 14px; font-size: 12px; }
.empty { font-size: 12px; color: var(--text-dim); padding: 8px 4px; }

/* ---------- Lecteur ---------- */
.stage-wrap { padding: 18px; display: flex; }
.player {
  flex: 1; border: var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--player-top) 0%, var(--player-bot) 100%);
  padding: 8px 16px 18px;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
}
.player-top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.playing-from { margin: 0; font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playing-from strong { font-weight: 700; }
.quality select {
  appearance: none; -webkit-appearance: none;
  height: 26px; padding: 0 26px 0 12px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #fff, #cfcfcf) no-repeat,
              #fff;
  color: #111; font-size: 12px; font-weight: 600;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23111' stroke-width='2.5'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #fff, #cfcfcf);
  background-size: 14px, 100% 100%;
  background-position: right 8px center, 0 0;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Diaporama */
.stage {
  position: relative; margin: 14px 0 12px;
  width: min(100%, 420px); aspect-ratio: 1 / 1;
  border-radius: 14px; overflow: hidden;
  background: rgba(0,0,0,.25);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.slides { position: absolute; inset: 0; }
/* Fond flou derrière la photo : la photo entière reste visible dans le cadre carré.
   Pour remplir le cadre (recadrage), mettez --fit: cover sur .stage */
.stage-blur {
  position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(28px) brightness(.7) saturate(1.2); transition: background-image .8s;
}
.slide {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: var(--fit, contain); opacity: 0; transform: scale(1.03);
  transition: opacity .8s ease, transform 5s ease;
}
.slide.active { opacity: 1; transform: scale(1); }
.arrow {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.35); color: #fff;
  opacity: 0; transition: opacity .2s, background .2s;
}
.arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.arrow.prev { left: 10px; } .arrow.next { right: 10px; }
.stage:hover .arrow, .arrow:focus-visible { opacity: 1; }
.arrow:hover { background: rgba(0,0,0,.6); }
@media (hover: none) { .arrow { opacity: .85; } }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dot { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 99px; background: rgba(255,255,255,.5); transition: width .3s, background .3s; }
.dot.active { width: 20px; background: #fff; }
.fs-exit { display: none; position: absolute; top: 14px; right: 14px; background: rgba(0,0,0,.45); }

/* Plein écran */
.stage:fullscreen, .stage:-webkit-full-screen, .stage.pseudo-fs {
  width: 100vw; height: 100vh; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 0; background: #000;
}
.stage.pseudo-fs { position: fixed; inset: 0; z-index: 100; }
.stage:fullscreen .slide, .stage:-webkit-full-screen .slide, .stage.pseudo-fs .slide { object-fit: contain; }
.stage:fullscreen .fs-exit, .stage:-webkit-full-screen .fs-exit, .stage.pseudo-fs .fs-exit { display: grid; }
.stage:fullscreen .arrow, .stage.pseudo-fs .arrow { opacity: .8; width: 52px; height: 52px; }

/* Lecture en cours */
.now { width: min(100%, 420px); display: flex; align-items: center; gap: 10px; }
.now img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.35); }
.now-text { flex: 1; min-width: 0; }
.now-title { margin: 0; font-size: 13px; font-weight: 600; }
.now-sub { margin: 2px 0 0; font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav.on svg { fill: #ff5fa2; stroke: #ff5fa2; }

/* Barre de progression */
.progress { width: min(100%, 420px); margin-top: 10px; }
#seek {
  --fill: 0%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; margin: 6px 0; border-radius: 99px;
  background: linear-gradient(90deg, #fff var(--fill), rgba(255,255,255,.3) var(--fill));
  cursor: pointer;
}
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.2); }
#seek::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #fff; }
.times { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Commandes */
.controls { width: min(100%, 420px); display: flex; justify-content: space-between; align-items: center; margin: 8px 0 14px; }
.controls .icon-btn svg { stroke-width: 1.7; }
.play { width: 54px; height: 54px; }
.play svg { width: 32px; height: 32px; }
.play .i-play { fill: currentColor; stroke: none; }
.play .i-pause { display: none; fill: none; stroke: currentColor; stroke-width: 1.6; }
.play.is-playing .i-pause { display: block; }
.play.is-playing .i-play { display: none; }
#prevBtn svg path:last-child, #nextBtn svg path:last-child { fill: none; }
#muteBtn .i-mute { display: none; }
#muteBtn.muted .i-mute { display: block; }
#muteBtn.muted .i-vol { display: none; }

/* Boîte d'infos (style « Lyrics ») */
.lyrics {
  width: min(100%, 360px); padding: 10px 14px 12px;
  background: var(--info-bg); border-radius: 14px;
}
.lyrics p { margin: 0; }
.lyrics-label { font-size: 10px; font-weight: 600; opacity: .85; margin-bottom: 8px !important; }
.lyrics-line { font-size: 15px; font-weight: 600; }
.lyrics-line.dim { font-size: 12px; font-weight: 500; opacity: .75; line-height: 1.45; }
.lyrics-dim { opacity: .5; line-height: 1; margin: 4px 0 !important; }

/* ---------- Titres populaires ---------- */
.popular { padding: 12px 14px 14px; min-width: 0; }
.popular h2 { margin-bottom: 10px; }
.tiles {
  list-style: none; margin: 0; padding: 0 0 4px;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(96px, 1fr);
  gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.tile { width: 100%; padding: 0; border: 0; background: none; text-align: left; scroll-snap-align: start; }
.tile img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--thumb-bg); transition: transform .2s, box-shadow .2s; }
.tile:hover img, .tile.current img { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.tile.current img { outline: 2px solid #fff; outline-offset: 2px; }
.tile strong, .tile small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile strong { margin-top: 6px; font-size: 11px; font-weight: 600; }
.tile small { font-size: 10px; color: var(--text-dim); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "top top" "main main" "lib rec" "pop pop" "foot foot";
  }
}
@media (max-width: 600px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main" "pop" "lib" "rec" "foot"; padding-top: 16px; gap: 12px; }
  .stage-wrap { padding: 10px; }
  .player { padding: 8px 12px 16px; }
  .tiles { grid-auto-columns: 110px; }
}

/* ---------- Version simplifiée ---------- */
.site-title { margin: 0; font-size: 15px; font-weight: 600; }
.track, .tile { cursor: pointer; }
.controls { margin-top: 14px; }
