/* Musique quotidienne – appli de l'utilisatrice.
   Gros caractères, gros boutons, fort contraste, aucune ressource externe. */

:root {
  --bg: #fbf4ea;
  --surface: #ffffff;
  --surface-2: #f4e7d6;
  --text: #2b1a10;
  --text-soft: #5c4433;
  --accent: #b44a17;          /* boutons principaux (contraste AA avec blanc) */
  --accent-strong: #8f3a10;
  --on-accent: #ffffff;
  --border: #d9c3aa;
  --like: #1f6b3a;
  --like-bg: #dff1e4;
  --dislike: #7a3c00;
  --dislike-bg: #fbe6d2;
  --fav: #9c1d4f;
  --fav-bg: #f9dfe9;
  --focus: #1b4fd6;
  --shadow: 0 2px 10px rgba(80, 40, 10, 0.12);
  --radius: 18px;
  --player-h: 0px;
  font-size: 21px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d140e;
    --surface: #2a1d15;
    --surface-2: #35261c;
    --text: #fbefe2;
    --text-soft: #dcc6b2;
    --accent: #f08a4b;
    --accent-strong: #ffa56b;
    --on-accent: #1d140e;
    --border: #5a4434;
    --like: #8ee0a8;
    --like-bg: #1f3a28;
    --dislike: #ffc48a;
    --dislike-bg: #46301a;
    --fav: #ff9cc3;
    --fav-bg: #4a2232;
    --focus: #9db8ff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.tracks.section-gap { margin-top: 18px; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none; /* pas de « tirer pour rafraîchir » */
}

body {
  padding-bottom: calc(var(--player-h) + 24px + env(safe-area-inset-bottom));
}

img { max-width: 100%; display: block; }

h1, h2, h3, p { margin: 0; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible, .main:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

button:disabled { cursor: not-allowed; opacity: 0.55; }

/* ---------- En-tête ---------- */

.preview-banner {
  background: #1b4fd6;
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 10px 16px;
}

.app-header {
  padding: calc(18px + env(safe-area-inset-top)) 20px 10px;
  text-align: center;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-strong);
  letter-spacing: 0.01em;
}

.app-date {
  font-size: 1.05rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 16px;
}

.main:focus { outline: none; }

.loading, .empty, .state {
  text-align: center;
  padding: 40px 12px;
  font-size: 1.1rem;
}

.state h2 { font-size: 1.3rem; margin-bottom: 14px; }
.state p { margin-bottom: 18px; color: var(--text-soft); }

/* ---------- Boutons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-size: 1.25rem;
  min-height: 72px;
}

.btn-primary:active { background: var(--accent-strong); }

.btn-back {
  margin-bottom: 18px;
  justify-content: flex-start;
}

.nav-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 26px 0 8px;
}

.nav-buttons .btn { min-height: 72px; font-size: 1.05rem; }

@media (max-width: 380px) {
  .nav-buttons { grid-template-columns: 1fr; }
}

/* ---------- Publication ---------- */

.pub {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pub-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-2);
}

.pub-cover-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  background: var(--surface-2);
  color: var(--accent);
}

.pub-body { padding: 18px 18px 22px; }

.pub-when {
  display: inline-block;
  background: var(--surface-2);
  color: var(--accent-strong);
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.pub-title { font-size: 1.55rem; line-height: 1.2; font-weight: 800; }
.pub-subtitle { font-size: 1.15rem; color: var(--text-soft); margin-top: 4px; }
.pub-meta { font-size: 0.95rem; color: var(--text-soft); margin-top: 6px; }
.pub-body .btn-primary { margin-top: 18px; }

.message {
  margin-top: 20px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 6px solid var(--accent);
}

.message-from { font-weight: 800; margin-bottom: 6px; }
.message-text { white-space: pre-line; font-size: 1.05rem; }
.message .btn { margin-top: 12px; }

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 28px 4px 12px;
}

/* ---------- Pistes ---------- */

.tracks { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.track {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  padding: 14px;
}

.track.is-playing { border-color: var(--accent); }

.track-head { display: flex; gap: 14px; align-items: center; }

.track-cover {
  width: 64px; height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: var(--surface-2);
}

.track-num {
  width: 48px; height: 48px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 800;
}

.track-text { min-width: 0; flex: 1; }
.track-title { font-size: 1.1rem; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.track-artist { color: var(--text-soft); font-size: 0.95rem; overflow-wrap: anywhere; }
.track-duration { color: var(--text-soft); font-size: 0.9rem; }

.now-playing {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
}

.track .btn-play-track { margin-top: 12px; min-height: 56px; }

.track-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.track-actions .btn-fav { grid-column: 1 / -1; }

.opt {
  min-height: 56px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.98rem;
  font-weight: 700;
  padding: 8px 10px;
  line-height: 1.2;
}

.opt[aria-pressed="true"].btn-like { background: var(--like-bg); border-color: var(--like); color: var(--like); }
.opt[aria-pressed="true"].btn-dislike { background: var(--dislike-bg); border-color: var(--dislike); color: var(--dislike); }
.opt[aria-pressed="true"].btn-fav { background: var(--fav-bg); border-color: var(--fav); color: var(--fav); }

.track-unavailable { margin-top: 10px; color: var(--dislike); font-weight: 700; }

/* ---------- Artiste ---------- */

.about {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.about-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.about-photo { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.about-name { font-size: 1.25rem; font-weight: 800; }
.about-facts { color: var(--text-soft); font-size: 0.95rem; }
.about-album { color: var(--text-soft); font-size: 0.95rem; margin-bottom: 10px; }
.about-bio { white-space: pre-line; }
.about-bio.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.about-source { color: var(--text-soft); font-size: 0.85rem; margin-top: 8px; }
.about .btn { margin-top: 12px; min-height: 56px; }

/* ---------- Historique ---------- */

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.history-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.history-head { display: flex; gap: 14px; align-items: center; }
.history-cover { width: 92px; height: 92px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
.history-cover-placeholder {
  width: 92px; height: 92px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; background: var(--surface-2); color: var(--accent);
}
.history-when { font-weight: 800; color: var(--accent-strong); font-size: 0.95rem; }
.history-title { font-size: 1.1rem; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.history-sub { color: var(--text-soft); font-size: 0.95rem; }
.history-item .btn { margin-top: 12px; min-height: 56px; }

.page-title { font-size: 1.4rem; font-weight: 800; margin: 4px 4px 16px; }
.page-intro { color: var(--text-soft); margin: 0 4px 16px; }

/* ---------- Bienvenue ---------- */

.welcome { display: grid; gap: 16px; }
.welcome-ok {
  background: var(--like-bg);
  color: var(--like);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 1.2rem; margin-bottom: 8px; }
.card p, .card ol { margin: 0 0 12px; }
.card ol { padding-left: 1.3em; }
.result { font-weight: 700; margin-top: 10px; }

/* ---------- Lecteur ---------- */

.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 18px rgba(60, 30, 10, 0.18);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

.player > * { max-width: 720px; margin-left: auto; margin-right: auto; }

.player-info { display: flex; gap: 12px; align-items: center; }
.player-cover { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; }
.player-text { min-width: 0; }
.player-title { font-weight: 800; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { color: var(--text-soft); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-progress { margin-top: 8px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s linear; }
.player-time { font-size: 0.85rem; color: var(--text-soft); text-align: right; margin-top: 2px; font-variant-numeric: tabular-nums; }

.player-controls {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.ctrl {
  min-height: 60px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  padding: 4px;
}

.ctrl span { font-size: 0.8rem; }

.ctrl-main {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.player-seek {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.ctrl-small {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 700;
}

/* ---------- Message éphémère ---------- */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--player-h) + 18px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

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

@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}
