/* Calendrier de l'Avent */

#avent {
  --sombre: rgb(14 14 20 / .85);
  --pale: rgb(255 255 255 / .7);
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  font-family: inherit;
  line-height: 1.4;
  color: #fff;
}

#avent button {
  all: unset;
  cursor: pointer;
}

#avent button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Scène : l'image de fond et les boules posées dessus */

.av-scene {
  position: relative;
  aspect-ratio: 996 / 606;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  container-type: inline-size;
}

.av-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--image) center / cover no-repeat;
  transform-origin: 72% 55%;
  transition: transform 6s ease-out;
}

.av-scene.en-lecture::before {
  transform: scale(1.06);
}

#avent .av-boule {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 5.6%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 18px var(--c);
  font-family: "Marcellus", Georgia, serif;
  font-size: clamp(12px, 2cqw, 24px);
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 4px rgb(0 0 0 / .4);
  transition: transform .2s, opacity .4s;
}

#avent .av-boule:hover {
  transform: scale(1.12);
}

#avent .av-boule.noel {
  width: 8%;
  font-size: clamp(16px, 2.8cqw, 32px);
}

/* Boule 0 : un peu plus grande, avec le mois en petit sous le jour */
#avent .av-boule.zero {
  width: 6.5%;
}

#avent .av-boule.zero small {
  font-size: max(.45em, 11px);
  letter-spacing: .06em;
  margin-top: .12em;
}

#avent .av-boule.fermee {
  background: rgb(255 255 255 / .14);
  box-shadow: none;
  color: rgb(255 255 255 / .45);
  text-shadow: none;
  cursor: default;
}

#avent .av-boule.aujourdhui::after {
  content: "";
  position: absolute;
  inset: -14%;
  border: 1.5px solid #fff;
  border-radius: 50%;
  animation: av-onde 2.2s infinite;
}

#avent .av-boule.active {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

#avent .en-lecture .av-boule:not(.active) {
  opacity: .35;
}

#avent .av-boule.secousse {
  animation: av-secousse .4s;
}

/* Message « Patience » et fenêtre d'attente, centrés sur l'image */

.av-message,
.av-bientot {
  position: absolute;
  left: 50%;
  z-index: 3;
  translate: -50% -50%;
  border-radius: 18px;
  background: var(--sombre);
  text-align: center;
}

.av-message {
  top: 40%;
  width: max-content;
  max-width: 90%;
  scale: .9;
  padding: .6em 1.2em;
  font-size: clamp(20px, 3.4cqw, 40px);
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  transition: opacity .25s, scale .25s;
  pointer-events: none;
}

.av-message.visible {
  opacity: 1;
  scale: 1;
}

/* Avant le 29 novembre */

.av-bientot {
  top: 50%;
  display: none;
  width: 52%;
  padding: 2.4cqw 2.8cqw;
  border: 1px solid rgb(255 255 255 / .14);
  backdrop-filter: blur(6px);
}

.av-bientot strong {
  display: block;
  font-size: clamp(20px, 2.8cqw, 36px);
  line-height: 1.15;
}

.av-bientot span {
  display: block;
  margin-top: .6em;
  font-size: clamp(13px, 1.4cqw, 18px);
  color: var(--pale);
}

.av-scene.bientot .av-bientot {
  display: block;
}

.av-scene.bientot::before {
  filter: grayscale(1) brightness(.5);
}

.av-scene.bientot .av-boules {
  opacity: .5;
  pointer-events: none;
}

/* Lecteur */

.av-lecteur {
  position: absolute;
  left: 3%;
  bottom: 4%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 70%;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--sombre);
  backdrop-filter: blur(10px);
  opacity: 0;
  translate: 0 20px;
  pointer-events: none;
  transition: opacity .35s, translate .35s;
}

.av-lecteur.visible {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}

#avent .av-play {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--c);
}

/* icône lecture (triangle) ou pause (deux barres) */
#avent .av-play::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 16px;
  background: #fff;
  clip-path: polygon(15% 0, 100% 50%, 15% 100%);
}

#avent .av-lecteur.joue .av-play::before {
  clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100%, 65% 0);
}

.av-infos {
  flex: 1;
  min-width: 0;
}

/* Lecteur sur deux étages : titre + croix en haut, progression + durée + PDF en bas */
.av-ligne-haut,
.av-ligne-bas {
  display: flex;
  align-items: center;
  gap: 12px;
}

.av-ligne-bas {
  margin-top: 8px;
}

.av-titre {
  flex: 1;
  min-width: 0;
  display: block;
  overflow: hidden;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#avent .av-progression {
  display: block;
  flex: 1;
  min-width: 0;
  width: auto;
  margin: 0;
  accent-color: var(--c);
  cursor: pointer;
}

.av-temps {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--pale);
}

/* Lien vers le PDF du jour */
#avent .av-pdf {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / .35);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.2;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

#avent .av-pdf:hover {
  border-color: #fff;
  background: rgb(255 255 255 / .1);
}

#avent .av-pdf:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#avent .av-pdf[hidden] {
  display: none;
}

#avent .av-pdf svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#avent .av-fermer {
  flex: none;
  padding: 0 4px;
  font-size: 18px;
  color: var(--pale);
}

#avent .av-fermer:hover {
  color: #fff;
}

@keyframes av-onde {
  from { transform: scale(.85); opacity: .9; }
  to { transform: scale(1.4); opacity: 0; }
}

@keyframes av-secousse {
  20%, 60% { transform: translateX(-6%); }
  40%, 80% { transform: translateX(6%); }
}

/* Mobile : format portrait, l'image en bas à droite, les bulles au-dessus */

@media (max-width: 640px) {
  .av-scene {
    aspect-ratio: 9 / 14;
  }

  .av-scene::before {
    background-size: 135% auto;
    background-position: right bottom;
    transform-origin: 70% 80%;
  }

  #avent .av-boule,
  #avent .av-boule.noel {
    left: var(--mx);
    top: var(--my);
    width: 12%;
    font-size: 16px;
  }

  #avent .av-boule.zero {
    width: 13%;
  }

  .av-bientot {
    top: 35%;
    width: 88%;
    padding: 16px;
  }

  .av-lecteur {
    left: 3%;
    right: 3%;
    bottom: 3%;
    width: auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .av-temps {
    display: none;
  }

  /* sur mobile, le titre peut passer sur deux lignes */
  .av-titre {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.25;
  }

  .av-ligne-haut {
    align-items: flex-start;
  }

  #avent .av-pdf {
    padding: 6px 10px;
  }

  .av-pdf-long {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #avent *,
  #avent *::before,
  #avent *::after {
    animation: none !important;
    transition: none !important;
  }
}