/* Bibliothèque : cartes des ressources et formulaire d'accès. Partagé par la home et /bibliotheque/. */
.items { display: grid; gap: 16px; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center;
  background: var(--ink-raise); border: 3px solid var(--outline); padding: 18px;
  box-shadow: 5px 5px 0 var(--outline); text-decoration: none; color: var(--sand);
  transition: transform .18s ease, box-shadow .18s ease;
}
a.item:hover { transform: translate(-3px, -3px); box-shadow: 8px 8px 0 var(--outline); }
.item h3 { margin: 0 0 2px; font-size: 1.1rem; }
.tag-front {
  display: inline-block; vertical-align: middle; margin-left: .3em;
  font-family: var(--f-body); font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  line-height: 1; text-transform: uppercase; color: var(--outline); background: var(--wip);
  padding: .3em .5em; border: 2px solid var(--outline); box-shadow: 2px 2px 0 var(--outline);
  transform: rotate(4deg);
}
.tag-front.back { background: var(--sky); }
.item p { margin: 0; color: var(--sand-dim); font-size: .95rem; }
/* Badge d'accès (components/AccessBadge.astro) : libre et débloqué en vert, réservé en terra, bientôt grisé */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 700 .8rem/1.2 var(--f-body); white-space: nowrap;
  padding: 5px 8px; border: 2px solid var(--outline); background: var(--ok); color: var(--outline);
}
.badge.reserve { background: var(--terra); color: var(--sand); }
.badge.bientot { background: transparent; color: var(--sand-dim); border-color: var(--line); }
.item-go { font-weight: 700; font-size: .92rem; color: var(--ok); white-space: nowrap; }
.item.soon { background: transparent; box-shadow: none; border-color: var(--line); color: var(--sand-dim); }

/* FORMULAIRE D'ACCÈS */
.gate {
  scroll-margin-top: 90px;
  background: var(--ink-deep); border: 3px solid var(--terra); box-shadow: 10px 10px 0 var(--outline);
  padding: 26px 24px 24px; display: grid; gap: 16px;
}
.gate h3 { font-size: clamp(1.8rem, 4vw, 2.3rem); line-height: 1; margin: 6px 0 0; }
.gate-intro { margin: 10px 0 18px; color: var(--sand-dim); }
form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
label { font-weight: 600; font-size: .95rem; }
input[type="email"] {
  font: inherit; color: var(--sand); background: var(--ink); width: 100%;
  border: 3px solid var(--outline); padding: 13px 14px; box-shadow: inset 3px 3px 0 var(--outline);
  transition: border-color .2s, box-shadow .2s;
}
input[type="email"]:focus {
  outline: none; border-color: var(--terra);
  box-shadow: inset 3px 3px 0 var(--outline), 0 0 0 3px color-mix(in srgb, var(--terra) 30%, transparent);
}
.check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; font-weight: 400; color: var(--sand-dim); cursor: pointer; }
.check input {
  appearance: none; width: 22px; height: 22px; margin: 2px 0 0; cursor: pointer;
  border: 3px solid var(--outline); background: var(--ink); display: grid; place-items: center; transition: background .2s;
}
.check input:checked { background: var(--terra); }
.check input:checked::after {
  content: ""; width: 6px; height: 11px; border: solid var(--sand); border-width: 0 3px 3px 0;
  transform: rotate(45deg) translate(-1px, -1px); animation: pop .3s var(--bounce);
}
@keyframes pop { from { transform: rotate(45deg) scale(0); } }
.error { color: var(--terra-soft); font-size: .9rem; margin: 0; min-height: 1.4em; }
.fine { font-size: .82rem; color: var(--sand-dim); margin: 0; }
form .btn { justify-content: center; width: 100%; font-size: 1.05rem; }
form .btn:disabled { opacity: .7; cursor: wait; transform: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.success { display: grid; gap: 12px; justify-items: start; animation: rise .6s var(--bounce) both; }
.success > svg { width: 64px; height: 64px; }
.success > svg circle { fill: var(--ok); stroke: var(--outline); stroke-width: 4; }
.success > svg path {
  fill: none; stroke: var(--outline); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .5s ease .25s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.success > svg circle { transform-origin: center; animation: check-pop .5s var(--bounce) .05s both; }
@keyframes check-pop { from { transform: scale(0); } }
/* Confettis de l'inscription (gate.js) : partent de la coche, retombent un peu */
.confetti { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 3; }
.confetti i {
  position: absolute; left: -4px; top: -6px; width: 8px; height: 12px; opacity: 0;
  background: var(--c); border: 2px solid var(--outline);
  animation: burst 1.1s cubic-bezier(.15, .75, .35, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
  55% { transform: translate(var(--x), var(--y)) rotate(calc(var(--r) * .6)) scale(1); opacity: 1; }
  100% { transform: translate(calc(var(--x) * 1.15), calc(var(--y) + 70px)) rotate(var(--r)) scale(1); opacity: 0; }
}
/* Badges et « Lire → » qui apparaissent juste après l'inscription */
.badge.unlock-pop { animation: unlock-pop .6s var(--bounce) both; }
.item-go.unlock-pop { display: inline-block; animation: go-pop .6s var(--bounce) both; }
@keyframes unlock-pop { 0% { transform: scale(.5) rotate(-10deg); background: var(--terra); } 60% { transform: scale(1.15) rotate(3deg); } }
@keyframes go-pop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.15); } }
.success h4 { margin: 0; font-size: 1.9rem; line-height: 1; }
.success p { margin: 0; color: var(--sand-dim); }
/* Carte de membre, à la place du formulaire sur la home quand on est déjà Builder */
.member {
  background: var(--ink-deep); border: 3px solid var(--ok); box-shadow: 10px 10px 0 var(--outline);
  padding: 26px 24px 24px; display: grid; gap: 12px; justify-items: start;
}
.member > .lock-ico { width: 40px; height: 40px; color: var(--ok); }
.member h3 { font-size: clamp(1.8rem, 4vw, 2.3rem); line-height: 1; margin: 0; }
.member p { margin: 0; color: var(--sand-dim); }
.member .later { margin-top: 4px; }
/* Proposition des mails (components/OptinPrompt.astro) : discrète, une icône, une phrase, un petit bouton.
   Par défaut sous un trait (écran de succès, bandeau de /bibliotheque/) ; .boxed quand elle est seule dans la page. */
.later {
  justify-self: stretch; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: start;
  margin-top: 8px; padding-top: 16px; border-top: 2px solid var(--line);
}
.later.boxed { margin: 28px 0 0; padding: 18px 20px; border: 3px solid var(--outline); background: var(--ink-deep); }
.later-ico {
  width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: var(--terra-soft);
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.later p { margin: 0; font-size: .92rem; line-height: 1.45; color: var(--sand-dim); }
.later b { display: inline; font-size: inherit; color: var(--sand); }
.later-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.later-btn {
  font: 700 .88rem/1 var(--f-body); color: var(--sand); cursor: pointer;
  background: transparent; padding: 8px 12px; border: 2px solid var(--terra);
  transition: background .2s, color .2s;
}
.later-btn:hover { background: var(--terra); }
.later-no {
  font: 600 .85rem/1 var(--f-body); color: var(--sand-dim); cursor: pointer;
  background: none; border: none; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px;
}
.later-no:hover { color: var(--sand); }
.later button:disabled { opacity: .7; cursor: wait; }
.later .later-done { grid-column: 2; color: var(--ok); font-weight: 600; }
.shake { animation: shake .4s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

@media (max-width: 480px) {
  .item { grid-template-columns: minmax(0, 1fr); }
  .item .badge { justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  .success > svg path { stroke-dashoffset: 0; }
}

/* Page /bibliotheque/ : bandeau d'accès, formulaire en fenêtre */
.unlock {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px 16px; align-items: center;
  padding: 18px 20px; background: var(--ink-deep); border: 3px solid var(--terra); box-shadow: 6px 6px 0 var(--outline);
}
.unlock p { margin: 0; }
.unlock b { display: block; color: var(--sand); font-size: 1.05rem; }
.unlock.ok { grid-template-columns: auto minmax(0, 1fr); border-color: var(--ok); }
.lock-ico { width: 30px; height: 30px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.unlock .lock-ico { color: var(--terra-soft); }
.unlock.ok .lock-ico { color: var(--ok); }
.unlock .later { grid-column: 1 / -1; margin-top: 0; }
.unlock .later b { display: inline; font-size: inherit; }

.badge .lock-ico { width: 13px; height: 13px; stroke-width: 3; }

.gate-dialog {
  padding: 0; border: none; background: transparent; color: var(--sand);
  width: min(30rem, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: visible;
}
.gate-dialog::backdrop { background: color-mix(in srgb, var(--outline) 75%, transparent); backdrop-filter: blur(3px); }
.gate-dialog[open] .gate { animation: rise .45s var(--bounce) both; }
.gate-dialog .gate { position: relative; max-height: calc(100dvh - 32px); overflow-y: auto; }
.gate-close {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 36px; height: 36px; cursor: pointer;
  font: 700 1.3rem/1 var(--f-body); color: var(--sand); background: var(--ink-raise);
  border: 2px solid var(--outline); box-shadow: 3px 3px 0 var(--outline);
}
.gate-close:hover { background: var(--terra); }

@media (max-width: 560px) {
  .unlock { grid-template-columns: auto minmax(0, 1fr); }
  .unlock .btn { grid-column: 1 / -1; justify-content: center; }
}

/* Page /bibliotheque/ en pleine largeur : filtres et grille de cartes */
body.wide .wrap { max-width: 72rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters button {
  font: 700 .9rem/1 var(--f-body); color: var(--sand); cursor: pointer;
  padding: 9px 14px; background: var(--ink-raise); border: 2px solid var(--outline); box-shadow: 3px 3px 0 var(--outline);
  transition: transform .15s ease, box-shadow .15s ease, background .2s;
}
.filters button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--outline); }
.filters button.on { background: var(--terra); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 24px; }
.card {
  display: grid; grid-template-rows: auto 1fr; text-decoration: none; color: var(--sand);
  background: var(--ink-raise); border: 3px solid var(--outline); box-shadow: 6px 6px 0 var(--outline);
  transition: transform .18s ease, box-shadow .18s ease;
}
a.card:hover { color: var(--sand); transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--outline); }
a.card:hover .cover-title { transform: rotate(-2deg) scale(1.04); }
/* Corps en colonne : le lien d'action est poussé en bas, aligné d'une carte à l'autre quelle que soit la longueur du texte */
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .82rem; font-weight: 600; color: var(--sand-dim); }
.card-meta .cat { color: var(--terra-soft); text-transform: uppercase; letter-spacing: .04em; }
.card h3 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.card p { margin: 0; font-size: .95rem; }
.card-go { margin-top: auto; padding-top: 4px; font-weight: 700; font-size: .92rem; color: var(--terra-soft); }
.card-go.free { color: var(--ok); }
.card.soon { background: transparent; box-shadow: none; border-color: var(--line); color: var(--sand-dim); }
.card.soon .cover { filter: grayscale(1); opacity: .35; }
.card.soon .card-go { color: var(--sand-dim); }

/* Couverture générée : couleur de la catégorie (--c), encre (--k), grille, grosse icône en filigrane */
.cover {
  position: relative; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-content: center; padding: 18px;
  background:
    linear-gradient(color-mix(in srgb, var(--outline) 14%, transparent) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, color-mix(in srgb, var(--outline) 14%, transparent) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--c);
  border-bottom: 3px solid var(--outline); color: var(--k);
}
.cover-ico {
  position: absolute; right: -6%; bottom: -14%; width: 52%; height: auto;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .2;
}
.cover-cat {
  position: absolute; top: 12px; left: 12px; font: 700 .72rem/1 var(--f-body); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 8px; background: var(--outline); color: var(--sand);
}
.cover-title {
  position: relative; text-align: center; font-size: clamp(1.7rem, 3.4vw, 2.4rem); line-height: .95; text-wrap: balance;
  transform: rotate(-2deg); transition: transform .2s var(--bounce);
}
.cover-lock { position: absolute; top: 10px; right: 10px; box-shadow: 3px 3px 0 var(--outline); transform: rotate(3deg); }

/* Aperçu d'une ressource réservée : faux texte flouté qui s'efface, puis le formulaire */
.locked-open { display: contents; }
.locked-part { display: grid; padding-block: 10px 30px; scroll-margin-top: 80px; }
.locked-ghost {
  display: grid; gap: 12px; padding-top: 10px; filter: blur(4px); user-select: none;
  -webkit-mask-image: linear-gradient(#000 20%, transparent); mask-image: linear-gradient(#000 20%, transparent);
}
.locked-ghost i { display: block; height: 14px; background: var(--line); border-radius: 3px; }
.locked-ghost i.short { width: 60%; }
.locked-ghost i.g-h { height: 34px; width: 55%; background: var(--terra); margin-bottom: 6px; }
.locked-ghost i.g-box { height: 110px; background: var(--ink-raise); border: 3px solid var(--outline); }
.locked-part .gate { margin-top: -70px; position: relative; }
