/* ==========================================================
   MODALES
   Carte postale « En savoir plus » — Figma : Frame 1 (carte 837 × 559 px)
   ========================================================== */

/* ---------- Fenêtre modale ---------- */

.modale {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  overflow: auto;
  overscroll-behavior: contain;
}

.modale[open] {
  display: grid;
}

/* Le reste du portfolio est assombri et flouté */
.modale::backdrop {
  background-color: rgba(28, 24, 14, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: modale-fond-entree 0.4s ease both;
}

.modale--fermeture::backdrop {
  animation: modale-fond-sortie 0.3s ease both;
}

/* ---------- Carte postale ----------
   Toutes les mesures suivent la carte Figma : --c = 1 px Figma */

.carte-postale {
  --c: calc(100cqw / 837);
  position: relative;
  container-type: inline-size;
  /* La carte garde ses proportions et tient toujours dans l'écran */
  width: min(837px, 100%, calc((100dvh - 48px) * 837 / 559));
  aspect-ratio: 837 / 559;
  margin: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  animation: carte-depose 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modale--fermeture .carte-postale {
  animation: carte-retrait 0.3s ease-in both;
}

.carte-postale__fond {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.carte-postale__texte {
  position: absolute;
  top: calc(60.5 * var(--c));
  left: calc(28 * var(--c));
  color: var(--noir);
  font-family: var(--police-mono);
  font-size: calc(12.5 * var(--c));
  line-height: calc(17.04 * var(--c));
  white-space: nowrap;
}

.carte-postale__texte p {
  margin: 0 0 calc(17.04 * var(--c));
}

.carte-postale__texte p:last-child {
  margin-bottom: 0;
}

/* Polaroid, trombone et bisou : positions relatives au Polaroid */
.carte-postale__photo {
  position: absolute;
  top: calc(40 * var(--c));
  left: calc(478 * var(--c));
  width: calc(291 * var(--c));
  aspect-ratio: 291 / 493;
}

.carte-postale__photo img {
  position: absolute;
  max-width: none;
  pointer-events: none;
}

.carte-postale__polaroid {
  inset: 0;
  width: 100%;
  height: 100%;
}

.carte-postale__trombone {
  top: -8.72%;
  left: -12.03%;
  width: 42.96%;
}

.carte-postale__bisou {
  top: 68.36%;
  left: 54.64%;
  width: 72.51%;
  transform: rotate(-6deg);
}

/* Croix de fermeture (absente de Figma) : discrète, dans le coin libre de la carte */
.carte-postale__fermer {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--marron);
  font-family: var(--police-texte);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.carte-postale__fermer:hover,
.carte-postale__fermer:focus-visible {
  background-color: rgba(47, 28, 13, 0.08);
  opacity: 1;
}

.carte-postale__fermer:focus-visible {
  outline: 2px solid var(--vert-olive);
  outline-offset: 2px;
}

/* ---------- Téléphone : texte lisible, Polaroid sous le texte ----------
   Le papier est agrandi et calé à gauche : la ligne centrale reste hors champ. */

@media (max-width: 700px) {
  .modale {
    padding: 16px;
  }

  .carte-postale {
    width: min(440px, 100%);
    aspect-ratio: auto;
    container-type: normal;
    padding: 48px 22px 64px;
    background: url("../../images/web/modales/carte-a-propos.webp") left top / auto 100% no-repeat;
  }

  .carte-postale__fond {
    display: none;
  }

  .carte-postale__texte {
    position: static;
    font-size: 13px;
    line-height: 1.6;
    white-space: normal;
  }

  .carte-postale__texte p {
    margin-bottom: 1.6em;
  }

  .carte-postale__texte br {
    display: none;
  }

  .carte-postale__photo {
    position: relative;
    top: auto;
    left: auto;
    width: 64%;
    margin: 48px auto 0;
  }
}

/* ---------- Pétales et étincelles (créés par js/interactions.js) ---------- */

.modale__effets {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.petale,
.etincelle {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform, opacity;
}

.petale {
  width: 12px;
  height: 16px;
  border-radius: 80% 0 80% 0;
  background: linear-gradient(135deg, #ffe1e8, var(--rose) 45%, #f4a7b9);
  box-shadow: inset 0 0 2px rgba(255, 255, 255, 0.6);
}

.etincelle {
  width: 9px;
  height: 9px;
  background: linear-gradient(135deg, #fff3c4, #e2b450);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 3px rgba(242, 201, 108, 0.9));
}

/* ---------- Animations ---------- */

@keyframes modale-fond-entree {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modale-fond-sortie {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* La carte descend légèrement en se redressant, comme posée sur une table */
@keyframes carte-depose {
  from {
    opacity: 0;
    transform: translateY(-28px) rotate(-2.5deg) scale(0.96);
  }
  60% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes carte-retrait {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .carte-postale {
    animation-name: modale-fond-entree;
    animation-duration: 0.2s;
  }

  .modale--fermeture .carte-postale {
    animation-name: modale-fond-sortie;
    animation-duration: 0.2s;
  }
}
