/* ==========================================================================
   Cartes — un projet = une carte à jouer
   Publié : face visible. À venir : face cachée (dos texturé).
   Structure :
     li.deck__item          (sujet de la timeline de scroll, perspective)
       article.card         (apparition)
         div.card__flipper  (rotation 3D : retournement mobile / inclinaison desktop)
           div.card__face--front
           div.card__face--back
   ========================================================================== */

.deck__item {
  display: flex;
  perspective: var(--perspective);
  /* Marge de débattement : padding + marge négative égale = mise en page inchangée,
     mais la zone de rognage de content-visibility est repoussée bien au-delà de la carte
     (soulèvement, retournement 3D, inclinaison au survol). */
  box-sizing: content-box;
  padding: var(--card-room-y) var(--card-room-x);
  margin: calc(-1 * var(--card-room-y)) calc(-1 * var(--card-room-x));
  /* Au clavier, la carte ciblée défile vers le centre (zone où elle est à plat). */
  scroll-margin-block: 25svh;
  /* Les cartes hors écran ne sont ni peintes ni composées (gain important sur mobile) ;
     « auto » mémorise la taille réelle une fois la carte affichée. */
  content-visibility: auto;
  contain-intrinsic-size: auto 22rem auto 32rem;
}

.card {
  --suit-color: var(--color-suit-dark);
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.card[data-suit="diamonds"],
.card[data-suit="hearts"] {
  --suit-color: var(--color-suit-light);
}

.card__flipper {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  transform-style: preserve-3d;
  border-radius: var(--radius-card);
}

.card__face {
  border-radius: var(--radius-card);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* --- Recto ---------------------------------------------------------------- */

.card__face--front {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  aspect-ratio: var(--card-ratio);  /* proportion minimale : la carte s'allonge si le contenu l'exige */
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-4);
  background: var(--color-card);
  color: var(--color-card-text);
  box-shadow: var(--shadow-card);
  /* Liseré intérieur, comme le filet d'une carte imprimée. */
  outline: 1px solid rgb(11 31 59 / 0.08);
  outline-offset: -6px;
}

.card__top,
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.5rem;
}

/* Index de coin : rang + couleur, comme sur une vraie carte. */
.card__index {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 1.75rem;
  color: var(--suit-color);
  line-height: 1;
}

.card__rank {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
}

.card__suit {
  width: 0.875rem;
  height: 0.875rem;
  fill: currentColor;
}

.card__index--end {
  transform: rotate(180deg);
}

.card__status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.75em;
  border-radius: var(--radius-pill);
  background: var(--paper-100);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  color: var(--color-card-muted);
  white-space: nowrap;
}

.card__status::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--color-live);
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--paper-100);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out);
}

.card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--space-2);
  padding-inline: var(--space-2);
}

.card__meta {
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--color-card-muted);
}

.card__heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Icône du projet (favicon ou logo du site), comme un blason à côté du titre. */
.card__icon {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: 0 0 0 1px var(--paper-100), 0 2px 6px rgb(11 31 59 / 0.15);
}

.card__title {
  font-size: var(--fs-h2);
  font-weight: 400;
  line-height: var(--lh-snug);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.card__link {
  text-decoration: none;
  outline: none;
}

/* Lien étiré : toute la carte est cliquable, le nom accessible reste le titre. */
.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: var(--radius-card);
}

.card__desc {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-card-muted);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
}

.card__tag {
  padding: 0.15em 0.6em;
  border: 1px solid var(--color-card-line);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  color: var(--color-card-muted);
}

.card__foot {
  padding-left: var(--space-2);
  border-top: 1px solid var(--paper-100);
  padding-top: var(--space-3);
  min-height: 0;
}

.card__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  color: var(--steel-600);
}

.card__cta svg {
  width: 1.1em;
  height: 1.1em;
  transition: transform var(--dur-base) var(--ease-out);
}

/* Focus clavier : l'anneau entoure toute la carte. */
.card:has(.card__link:focus-visible) .card__face--front {
  outline: 3px solid var(--color-focus);
  outline-offset: 4px;
}

/* --- Verso (dos de carte) ----------------------------------------------- */

.card__face--back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

/* Ombre de la carte soulevée (retournement mobile) : portée par chaque face,
   elle tourne AVEC la carte (de profil, l'ombre est aussi fine que la carte).
   Ombre extérieure uniquement : elle ne recouvre jamais le contenu.
   Invisible au repos, son opacité suit le scroll (css/animations.css). */
.card__face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 30px 44px -10px rgb(3 10 22 / 0.85), 0 10px 18px -4px rgb(3 10 22 / 0.5);
  opacity: 0;
  pointer-events: none;
}

.card__face--back {
  background-color: var(--paper-50);
  box-shadow: var(--shadow-card);
}

/* Le dos : marge blanche + panneau holographique + motif + filet + emblème central.
   Empilement : fond navy → .card__holo (couleurs) → ::before (motif, filets)
   → ::after (emblème) → .card__glare (reflet). Les couleurs et le reflet
   évoluent avec le scroll : voir css/animations.css (« Holographie »). */
.card__back {
  position: absolute;
  inset: 8px;
  overflow: hidden;
  border-radius: calc(var(--radius-card) - 6px);
  background-color: var(--uniform-blue);
  isolation: isolate;
}

.card__holo,
.card__glare,
.card__back::before,
.card__back::after {
  position: absolute;
  pointer-events: none;
}

/* Calque de couleur : bleu brillant au repos, sa teinte tourne avec le scroll
   (bleu → vert → jaune → rouge → magenta). Seul « filter » est animé. */
.card__holo {
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(90% 60% at 18% 12%, rgb(255 255 255 / 0.38), transparent 60%),
    radial-gradient(80% 55% at 85% 90%, rgb(255 255 255 / 0.22), transparent 60%),
    linear-gradient(135deg, var(--holo-1) 0%, var(--holo-2) 26%, var(--holo-3) 44%, var(--holo-4) 54%, var(--holo-2) 72%, var(--holo-1) 100%);
  filter: hue-rotate(var(--holo-hue, 0deg)) saturate(1.35);
}

/* Motif répété + double filet intérieur. */
.card__back::before {
  content: "";
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: var(--card-back-texture) center / var(--card-back-size);
  box-shadow: inset 0 0 0 1px rgb(244 246 248 / 0.45), inset 0 0 0 6px rgb(11 31 59 / 0.35), inset 0 0 0 7px rgb(244 246 248 / 0.55);
}

/* Emblème central. */
.card__back::after {
  content: "";
  inset: 0;
  z-index: 2;
  background: url("/assets/logos/logo-mark.svg") center / 34% auto no-repeat;
}

/* Reflet : bande lumineuse diagonale qui balaie la carte avec le scroll. */
.card__glare {
  top: -40%;
  bottom: -40%;
  left: 25%;
  width: 50%;
  z-index: 3;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.12) 30%, rgb(255 255 255 / 0.5) 50%, rgb(255 255 255 / 0.12) 70%, transparent);
  transform: translateX(var(--glare-x, -160%)) rotate(18deg);
}

/* --- Carte à venir : sa face (révélée en la retournant) ------------------- */

/* Grand index central (rang + couleur), à la place de la capture. */
.card__pip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(135deg, transparent 0 10px, rgb(47 93 138 / 0.05) 10px 11px),
    var(--paper-100);
  color: var(--suit-color);
}

.card__pip-rank {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 2.4rem + 3vw, 4.25rem);
  font-weight: 700;
  line-height: 1;
}

.card__pip-suit {
  width: clamp(2.25rem, 1.8rem + 2vw, 3rem);
  height: auto;
  aspect-ratio: 1;
  fill: currentColor;
}

.card--coming_soon .card__title {
  font-style: italic;
}

.card__planned {
  font-size: var(--fs-small);
  font-style: italic;
  color: var(--steel-600);
}

/* Pastille « À venir » : point creux, au lieu du point vert « En ligne ». */
.card__status--soon::before {
  background: transparent;
  border: 1px solid var(--steel-600);
}

.card__cta--soon {
  color: var(--color-card-muted);
}

/* --- Survol (souris uniquement) ------------------------------------------ */

@media (hover: hover) and (pointer: fine) {
  .card--published .card__flipper {
    transform: translateY(var(--lift, 0)) rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg));
    transition: transform var(--dur-slow) var(--ease-out);
  }

  .card--published:hover .card__flipper {
    --lift: -6px;
    transition-duration: var(--dur-fast);
  }

  .card--published .card__face--front {
    transition: box-shadow var(--dur-base) var(--ease-out);
  }

  .card--published:hover .card__face--front {
    box-shadow: var(--shadow-lift);
  }

  .card--published:hover .card__media img {
    transform: scale(1.04);
  }

  .card--published:hover .card__cta svg {
    transform: translateX(4px);
  }

  .card--published:hover .card__title {
    color: var(--steel-600);
  }
}
