/* Police du logo : Barlow Condensed Bold (la plus proche du logo KIF Radio) */
@font-face {
  font-family: "Barlow Logo";
  src: url("fonts/BarlowCondensed-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0f0b09;
  --bone: #fff4e6;
  --bone-dim: #b9aa9a;
  --card: #1d1611;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --c: #ff7a1a;
  --c-rgb: 255, 122, 26;
}

* { box-sizing: border-box; margin: 0; }

html { -webkit-text-size-adjust: 100%; background: var(--ink); }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

/* Icônes centrées sans dépendre de la mise en page interne du bouton (Safari) */
.play, .expand { position: relative; display: block; }
.play svg, .expand svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.play svg { width: 52%; height: 52%; }
.expand svg { width: 50%; height: 50%; }

:focus-visible { outline: 3px solid var(--bone); outline-offset: 3px; }

/* En-tête */
.top {
  position: relative;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
}
.wordmark { font-family: "Barlow Logo", var(--font); font-size: 38px; font-weight: 700; letter-spacing: -0.01em; line-height: 1; }
.wordmark span { color: #ff7a1a; }
/* Bouton menu : trois barres à plat */
.menu-btn {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 122, 26, 0.5);
  color: #ff7a1a;
}
.menu-btn svg { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.menu-btn:active, .menu-btn[aria-expanded="true"] { background: rgba(255, 122, 26, 0.12); }

/* Petit menu sous le bouton : ni popup ni fond assombri */
.menu-panel {
  position: absolute;
  top: calc(100% - 4px);
  right: 12px;
  width: min(240px, calc(100vw - 24px));
  padding: 6px;
  background: #1d1611;
  border: 1px solid rgba(255, 244, 230, 0.18);
  border-radius: 18px;
}
.menu-panel[hidden] { display: none; }
.menu-item { display: block; width: 100%; padding: 10px; border-radius: 12px; text-align: left; color: var(--bone); text-decoration: none; }
.menu-item[hidden] { display: none; }
.menu-item:active { background: rgba(255, 244, 230, 0.06); }
.menu-row { display: flex; align-items: center; gap: 12px; }
.menu-ico { flex: none; width: 22px; height: 22px; color: #ff7a1a; }
.menu-label { font-size: 15px; font-weight: 700; }

/* Popup WhatsApp (couleur de ROCK) */
.wa-lines { margin: 8px 0 18px; font-size: 14px; line-height: 1.55; color: var(--bone-dim); text-align: center; }
.wa-lines b { color: var(--bone); font-weight: 700; }
.wa-call { position: relative; display: block; width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: var(--c); color: var(--ink); }
.wa-call svg { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; }
.wa-call:active { transform: scale(0.94); }

/* Très petits écrans : l'en-tête resserre ses marges pour que les trois éléments tiennent */
@media (max-width: 340px) {
  .top { padding-left: 12px; padding-right: 12px; }
  .wordmark { font-size: 34px; }
}

/* Les 4 cases */
.grid {
  flex: none;
  height: 45dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}

.tile {
  --c: #ff7a1a;
  position: relative;
  min-height: 0;
  border-radius: 24px;
  background: var(--c);
  color: var(--ink);
  text-align: left;
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}
.tile:active { transform: scale(0.97); }
/* Une radio joue : sa case reste telle quelle, les 3 autres sont légèrement transparentes */
.grid.has-live .tile:not(.is-playing) { opacity: 0.6; }
.tile[aria-current="true"] { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--bone); }

.tile-name { position: relative; font-family: "Barlow Logo", var(--font); font-size: 50px; font-weight: 700; letter-spacing: -0.01em; line-height: 0.85; }
.tile-short { position: relative; margin-top: 4px; font-size: 14px; font-weight: 500; line-height: 1.1; white-space: nowrap; overflow: hidden; }

.tile .vinyl {
  position: absolute;
  top: -22%;
  right: -26%;
  width: 72%;
  aspect-ratio: 1;
}

/* Vinyle des cases */
.vinyl {
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 62%, rgba(255, 255, 255, 0.08) 62.5%, transparent 64%),
    repeating-radial-gradient(circle, #15100d 0 2px, #211a15 2px 4px);
}
.vinyl::after {
  content: "";
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--ink);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bar { 0%, 100% { height: 30%; } 50% { height: 100%; } }

/* Lecteur : carte sombre, liseré et accents dans la couleur de la station */
.deck {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Néon léger : halo de la couleur de la station dans le fond, contour qui rougeoie */
  background:
    radial-gradient(110% 80% at 12% 0%, rgba(var(--c-rgb), 0.30), transparent 62%),
    radial-gradient(90% 70% at 100% 100%, rgba(var(--c-rgb), 0.20), transparent 60%),
    var(--card);
  color: var(--bone);
  border: 1px solid rgba(var(--c-rgb), 0.6);
  box-shadow: 0 0 18px rgba(var(--c-rgb), 0.28), inset 0 0 26px rgba(var(--c-rgb), 0.14);
  margin: 0 12px 8px;
  border-radius: 24px;
  padding: 18px 18px 16px;
  text-align: left;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.deck-body { flex: none; position: relative; z-index: 1; }

/* Fond qui vit pendant la lecture : halo qui dérive et deux vagues lentes. Tout est dans un cadre
   qui rogne ses contenus, donc rien n'agrandit le lecteur ni ne perturbe l'ajustement de la mise en page. */
.bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.is-live .bg { opacity: 1; }

.glow {
  position: absolute;
  left: -15%;
  top: -25%;
  width: 75%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--c-rgb), 0.42), transparent 65%);
  animation: drift 13s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.wave {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 200%;
  height: 52%;
  fill: rgba(var(--c-rgb), 0.2);
  animation: wave 15s linear infinite;
  animation-play-state: paused;
}
.wave-b {
  height: 42%;
  fill: rgba(var(--c-rgb), 0.13);
  animation-duration: 23s;
  animation-direction: reverse;
}
.is-live .glow, .is-live .wave { animation-play-state: running; }

@keyframes wave { to { transform: translateX(-50%); } }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(70%, 45%) scale(1.25); }
}

/* Petit cadre fin en bas, aux couleurs du lecteur actif ; masqué en vue agrandie */
.ver {
  flex: none;
  height: 26px;
  margin: 0 12px calc(10px + env(safe-area-inset-bottom));
  border: 1px solid rgba(var(--c-rgb), 0.5);
  border-radius: 13px;
  background: rgba(var(--c-rgb), 0.06);
  color: var(--c);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 24px;
  text-align: center;
  transition: border-color 0.3s ease, color 0.3s ease;
}
.deck.is-full ~ .ver { display: none; }
/* Bouton agrandir / réduire : sur la ligne du texte sous le nom, centré au-dessus du bouton lecture.
   Le bouton lecture est collé au bord droit : son centre est à --play / 2 du bord. */
.deck-id { position: static; }
.expand {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--bone-dim);
  background: rgba(255, 244, 230, 0.08);
}

/* Derniers titres (vue agrandie) */
.history { display: none; }
.history h3 { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.history ul { list-style: none; padding: 0; }
.history li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(255, 244, 230, 0.12);
}
.h-cover {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background: rgba(var(--c-rgb), 0.22) center / cover no-repeat;
}
.h-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.h-artist { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-title { font-size: 13px; color: var(--bone-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history time { flex: none; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c); }

/* Tête : pochette + nom */
.deck-head { display: flex; align-items: center; gap: 14px; }

.cover {
  position: relative;
  flex: none;
  width: 120px;
  height: 120px;
  border-radius: 16px;
  background: var(--c) center / cover no-repeat;
}
.cover-disc {
  position: absolute;
  top: 16%;
  right: 16%;
  bottom: 16%;
  left: 16%;
  border-radius: 50%;
  background: #15100d;
}
.cover-disc::after {
  content: "";
  position: absolute;
  top: 34%;
  right: 34%;
  bottom: 34%;
  left: 34%;
  border-radius: 50%;
  background: var(--c);
}
.cover.has-img .cover-disc { display: none; }
.is-live .cover-disc { animation: spin 5s linear infinite; }

.deck-id { position: relative; flex: 1; min-width: 0; }
.deck-name {
  font-family: "Barlow Logo", var(--font);
  font-size: 66px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 0.9;
  color: var(--c);
  text-shadow: 0 0 14px rgba(var(--c-rgb), 0.5);
}
/* Le texte laisse la place au bouton agrandir / réduire à sa droite (il passe à la ligne s'il est long) */
.deck-slogan { margin-top: 4px; padding-right: calc(var(--play) / 2 + 21px); font-size: 13px; color: var(--bone-dim); }

/* Artiste et titre */
.np { margin-top: 22px; }
.np-artist { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.np-title { margin-top: 2px; font-size: 17px; color: var(--bone-dim); }
.np-artist:empty, .np-title:empty { display: none; }

/* Pied : égaliseur / message à gauche, bouton lecture à droite */
.deck-foot { margin-top: 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.foot-left { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 24px; }
.bars i { width: 5px; height: 30%; background: var(--c); border-radius: 1px; }
.is-live .bars i { animation: bar 0.9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -0.2s; }
.bars i:nth-child(3) { animation-delay: -0.4s; }
.bars i:nth-child(4) { animation-delay: -0.6s; }
.bars i:nth-child(5) { animation-delay: -0.8s; }

/* Popup d'erreur : carte centrée, couleur de la station */
.pop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
}
.pop[hidden] { display: none; }
.pop-card {
  width: 100%;
  max-width: 310px;
  background: #1d1611;
  border: 1px solid rgba(255, 244, 230, 0.18);
  border-radius: 22px;
  padding: 22px 18px 18px;
  text-align: center;
}
.pop-ico {
  position: relative;
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(var(--c-rgb), 0.18);
  color: var(--c);
}
.pop-ico svg { position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; }
.pop-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.pop-text { margin: 6px 0 18px; font-size: 14px; color: var(--bone-dim); }
.pop-btns { display: flex; gap: 10px; }
.pop-btn { display: block; flex: 1; height: 44px; line-height: 42px; border-radius: 22px; font-size: 15px; font-weight: 700; text-align: center; }
.pop-close { border: 1px solid rgba(255, 244, 230, 0.25); color: var(--bone); }
.pop-retry { background: var(--c); color: var(--ink); }

/* Cookies : la page derrière est floutée, les deux choix ont le même poids */
.pop-consent {
  z-index: 110;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}
.pop-card:focus { outline: none; }

.play {
  flex: none;
  width: var(--play);
  height: var(--play);
  border-radius: 50%;
  background: var(--c);
  color: var(--ink);
  transition: transform 0.15s ease;
}
.play:active { transform: scale(0.94); }

/* Tout doit tenir dans la carte : les tailles suivent la hauteur de l'écran */
.deck { --play: clamp(56px, 8.6dvh, 72px); padding-top: clamp(12px, 3.2dvh, 22px); }
.cover { width: clamp(64px, 12.5dvh, 108px); height: clamp(64px, 12.5dvh, 108px); }
.deck-name { font-size: clamp(38px, 7.4dvh, 62px); }
.np { margin-top: clamp(8px, 2.6dvh, 22px); height: clamp(50px, 7.6dvh, 66px); overflow: hidden; }
.np-artist { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title {
  margin-top: 0;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.deck-foot { margin-top: clamp(8px, 2.4dvh, 20px); }

/* Vue agrandie : le lecteur prend tout l'écran, le contenu s'y ajuste (voir fit() dans app.js) */
/* Vue agrandie : le bouton réduire reste en face du nom, au milieu du bouton lecture */
.deck.is-full .deck-id { position: relative; }
.deck.is-full .expand { top: auto; right: calc(var(--play) / 2 - 17px); bottom: -8px; }

/* Vue agrandie : le bandeau du haut (au-dessus pour son menu) disparaît */
body.is-full .top { visibility: hidden; }

.deck.is-full {
  position: fixed;
  inset: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  margin: 0;
  box-shadow: 0 0 0 100vmax var(--ink), inset 0 0 26px rgba(var(--c-rgb), 0.14);
  overflow-y: auto;
  padding: 22px 20px 22px;
  --play: 80px;
}
.deck.is-full .cover { width: 100px; height: 100px; }
.deck.is-full .deck-name { font-size: 66px; }
.deck.is-full .np { margin-top: 20px; height: auto; overflow: visible; }
.deck.is-full .np-artist { font-size: 21px; white-space: normal; }
.deck.is-full .np-title { font-size: 19px; display: block; }
.deck.is-full .deck-foot { margin-top: 16px; }
.deck.is-full .history { display: block; margin-top: 22px; }
.deck.is-full .history[hidden] { display: none; }

/* Vue agrandie sur écran court (iPhone 8 : 667 px) : on resserre l'en-tête du lecteur pour que la liste
   des derniers titres garde ses miniatures à taille normale, au lieu de tout réduire */
@media (max-height: 740px) {
  .deck.is-full { padding: 18px 18px 14px; --play: 62px; }
  .deck.is-full .cover { width: 84px; height: 84px; }
  .deck.is-full .deck-name { font-size: 54px; }
  .deck.is-full .np { margin-top: 10px; }
  .deck.is-full .deck-foot { margin-top: 6px; }
  .deck.is-full .history { margin-top: 10px; }
  .history li { padding: 6px 0; }
}

/* Écrans très courts : les cases sont basses, le vinyle du coin rétrécit pour ne pas passer sous le texte */
@media (max-height: 560px) {
  .tile .vinyl { width: 52%; top: -28%; right: -20%; }
}

@media (max-height: 700px) {
  .tile-name { font-size: 40px; }
  .tile-short { font-size: 13px; }
  .top { padding-bottom: 8px; }
  .np-artist { font-size: 16px; }
  .np-title { font-size: 13px; line-height: 1.3; }
}

@media (prefers-reduced-motion: reduce) {
  .is-live .cover-disc, .is-live .bars i, .glow, .wave { animation: none; }
  .deck, .tile, .play { transition: none; }
}

@media (min-width: 560px) {
  body { max-width: 520px; margin: 0 auto; }
}

/* Popup de contact : formulaire dans une carte centrée (défile si le clavier prend la place) */
.pop-contact { align-items: flex-start; overflow-y: auto; }
.pop-contact .pop-card { margin: auto; max-width: 340px; }
.pop-contact form { text-align: left; margin-top: 4px; }
.pop-contact label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: var(--bone-dim); }
.pop-contact label span { display: block; margin-bottom: 4px; }
.pop-contact input, .pop-contact textarea {
  display: block; width: 100%; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--bone);
  background: rgba(255, 244, 230, 0.06); border: 1px solid rgba(255, 244, 230, 0.18); border-radius: 12px; resize: vertical;
}
.pop-contact input:focus, .pop-contact textarea:focus { outline: none; border-color: var(--c); box-shadow: 0 0 0 3px rgba(var(--c-rgb), 0.2); }
.pop-contact .bad { border-color: #ff4a5e; }
.pop-contact .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-err { margin: 2px 0 10px; font-size: 13px; color: #ff6b7a; }
.form-err[hidden], .contact-ok[hidden] { display: none; }
.pop-contact .pop-btns { margin-top: 6px; }
.pop-contact .pop-retry { border: 0; cursor: pointer; font-family: inherit; }
.pop-contact .pop-retry:disabled { opacity: 0.6; }
.contact-ok { padding: 6px 0 2px; }
.contact-ok .pop-title { margin-bottom: 16px; }
