/*
 * tsp-catalog.css — boutique des produits digitaux (modèle de page « Produits digitaux » et
 * shortcode [tsp_digital_products]) : en-tête, grille, cartes, diaporama, visionneuse, pagination
 * et barres du panier.
 *
 * Design de référence (The_Style.css — TT Radmin v4) : bleu nuit #1a2a5e, bleu #3b5998, vert
 * #2d9c4e, bordures #e4e8f0 / #d0d6e8, gris #6b7a9b, polices Inter (texte) et Cairo (titres),
 * cartes arrondies à 12 px, boutons à 8 px. Toutes les valeurs sont des variables : un thème
 * peut les redéfinir sur .tsp-cat-page ou .tsp-shop.
 * Tailles en px (le thème peut fixer html { font-size } à 10 px), proches du design de référence :
 * texte 13–14 px, nom du livre 16 px, prix 19 px, boutons de 40 px (44 px sur téléphone).
 */
.tsp-cat-page, .tsp-shop, .tsp-lb {
  --tsp-navy: #1a2a5e;
  --tsp-blue: #3b5998;
  --tsp-blue2: #2d4a8a;
  --tsp-blue-soft: #eaeefc;
  --tsp-blue-line: #c8d2ee;
  --tsp-green: #2d9c4e;
  --tsp-green-bg: #e8f6ed;
  --tsp-green-bd: #a8d8b8;
  --tsp-red: #cc0000;
  --tsp-bg: #f5f6fa;
  --tsp-surface: #ffffff;
  --tsp-border: #e4e8f0;
  --tsp-border2: #d0d6e8;
  --tsp-text: #1a2a5e;
  --tsp-muted: #6b7a9b;
  --tsp-subtle: #9eaacc;
  --tsp-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tsp-font-head: 'Cairo', 'Inter', system-ui, sans-serif;
  --tsp-radius: 12px;
  --tsp-radius-btn: 8px;
}

/* ── Page ── */
.tsp-cat-wrap { box-sizing: border-box; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 20px 56px; font-family: var(--tsp-font); color: var(--tsp-text); }
.tsp-shop-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 14px; }
.tsp-cat-title { margin: 0; font-family: var(--tsp-font-head); font-size: 26px; font-weight: 800; line-height: 1.25; color: var(--tsp-navy); }
.tsp-cat-intro { margin: 0 0 22px; font-size: 15px; line-height: 1.6; color: #3d4b70; max-width: 860px; }
.tsp-cat-intro p { margin: 0 0 10px; }
.tsp-cat-intro a { color: var(--tsp-blue); text-decoration: underline; }

/* ── Bouton « Mon panier » (près du titre, en haut de la grille, en bas de page) ── */
.tsp-shop-cartbtn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border: 2px solid var(--tsp-blue); border-radius: var(--tsp-radius-btn); background: var(--tsp-surface); color: var(--tsp-blue);
  font-family: var(--tsp-font); font-size: 14px; font-weight: 700; line-height: 1.2; cursor: pointer;
  transition: background-color .12s, color .12s, box-shadow .12s, transform .08s;
}
.tsp-shop-cartbtn:hover { background: var(--tsp-blue-soft); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .1); }
.tsp-shop-cartbtn.has-items, .tsp-shop-cartbtn--pay { background: var(--tsp-blue); color: #fff; }
.tsp-shop-cartbtn.has-items:hover, .tsp-shop-cartbtn--pay:hover { background: var(--tsp-blue2); color: #fff; }
.tsp-shop-cartbtn-ico { font-size: 16px; line-height: 1; }
.tsp-shop-cartbtn-count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--tsp-blue); color: #fff; font-size: 12px; font-weight: 800;
}
.tsp-shop-cartbtn.has-items .tsp-shop-cartbtn-count, .tsp-shop-cartbtn--pay .tsp-shop-cartbtn-count { background: #fff; color: var(--tsp-blue); }
.tsp-shop-cartbtn:focus-visible { outline: 3px solid var(--tsp-navy); outline-offset: 2px; }

.tsp-shop { font-family: var(--tsp-font); color: var(--tsp-text); }
.tsp-shop-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.tsp-shop-count { font-size: 14px; color: var(--tsp-muted); font-weight: 600; }

/* ── Grille ── */
.tsp-cat-grid {
  display: grid; gap: 22px; align-items: stretch;
  grid-template-columns: repeat(var(--tsp-cat-cols, 3), minmax(0, 1fr));
}
.tsp-cat-item { display: flex; min-width: 0; }
.tsp-cat-item > .tsp-sc-card, .tsp-cat-item > .tsp-sc-slot { width: 100%; max-width: none; margin: 0; }
.tsp-cat-item > .tsp-sc-slot > .tsp-sc-card { max-width: none; margin: 0; height: 100%; }

/* ── Cartes ── */
.tsp-cat-item .tsp-sc-card {
  display: flex; flex-direction: column; font-family: var(--tsp-font); font-size: 14px; color: var(--tsp-text);
  background: var(--tsp-surface); border: 1px solid var(--tsp-border); border-radius: var(--tsp-radius); box-shadow: none; overflow: hidden;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.tsp-cat-item .tsp-sc-card:hover { border-color: var(--tsp-border2); box-shadow: 0 6px 18px rgba(26, 42, 94, .08); transform: translateY(-2px); }
.tsp-cat-item .tsp-sc-body { display: flex; flex-direction: column; flex: 1 1 auto; padding: 14px 16px 16px; }
.tsp-cat-item .tsp-sc-badge {
  align-self: flex-start; margin: 0 0 8px; padding: 3px 10px; border-radius: 20px;
  background: var(--tsp-blue-soft); color: var(--tsp-blue); font-size: 11px; font-weight: 700;
}
.tsp-cat-item .tsp-sc-title { margin: 0 0 4px; font-family: var(--tsp-font-head); font-size: 16px; font-weight: 800; line-height: 1.35; color: var(--tsp-navy); }
.tsp-cat-item .tsp-sc-title:hover { color: var(--tsp-blue); text-decoration: none; }
.tsp-cat-item .tsp-sc-desc {
  margin: 0 0 12px; font-size: 13px; line-height: 1.55; color: var(--tsp-muted);
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tsp-cat-item .tsp-sc-row { margin: 0 0 12px; }
.tsp-cat-item .tsp-sc-price { font-size: 19px; font-weight: 800; color: var(--tsp-navy); }
.tsp-cat-item .tsp-sc-country { font-size: 12px; color: var(--tsp-muted); }

/* ── Boutons des cartes ── */
.tsp-cat-item .tsp-sc .tsp-sc-btn {
  min-height: 40px; padding: 9px 14px; border-radius: var(--tsp-radius-btn); font-family: var(--tsp-font);
  font-size: 14px; font-weight: 700; line-height: 1.25; letter-spacing: 0;
  transition: background-color .12s, color .12s, border-color .12s, box-shadow .12s, transform .08s;
}
.tsp-cat-item .tsp-sc .tsp-sc-btn:hover { opacity: 1; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .1); }
.tsp-cat-item .tsp-sc .tsp-sc-btn:active { transform: none; box-shadow: none; }
.tsp-cat-item .tsp-sc .tsp-sc-btn:focus-visible { outline: 3px solid var(--tsp-navy); outline-offset: 2px; }
/* Sans panier : l'achat direct est le bouton principal (bleu) */
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-sc-btn-digital,
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-sc-btn-order { margin-top: auto; background: var(--tsp-blue); color: #fff; border: 2px solid var(--tsp-blue); }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-sc-btn-digital:hover,
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-sc-btn-order:hover { background: var(--tsp-blue2); border-color: var(--tsp-blue2); color: #fff; }
/* Avec panier : « Ajouter au panier » en principal, achat direct en second (contour) */
.tsp-cat-grid--cart .tsp-sc-body > .tsp-cart-add { order: 1; margin-top: auto; }
.tsp-cat-grid--cart .tsp-cat-item .tsp-sc .tsp-sc-body > .tsp-sc-btn.tsp-sc-btn-digital,
.tsp-cat-grid--cart .tsp-cat-item .tsp-sc .tsp-sc-body > .tsp-sc-btn.tsp-sc-btn-order { order: 2; margin-top: 8px; }
.tsp-cat-grid--cart .tsp-sc .tsp-sc-btn.tsp-sc-btn-digital,
.tsp-cat-grid--cart .tsp-sc .tsp-sc-btn.tsp-sc-btn-order { background: var(--tsp-surface); color: var(--tsp-blue); border: 1.5px solid var(--tsp-border2); }
.tsp-cat-grid--cart .tsp-sc .tsp-sc-btn.tsp-sc-btn-digital:hover,
.tsp-cat-grid--cart .tsp-sc .tsp-sc-btn.tsp-sc-btn-order:hover { background: var(--tsp-blue-soft); color: var(--tsp-blue); border-color: var(--tsp-blue-line); }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-cart-add { margin-top: auto; margin-bottom: 0; background: var(--tsp-blue); color: #fff; border: 2px solid var(--tsp-blue); }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-cart-add:hover { background: var(--tsp-blue2); border-color: var(--tsp-blue2); color: #fff; }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-cart-add.is-in-cart { background: var(--tsp-green-bg); color: var(--tsp-green); border-color: var(--tsp-green-bd); }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-cart-add.is-in-pack,
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-cart-add.is-in-pack:hover { background: var(--tsp-bg); color: var(--tsp-muted); border-color: var(--tsp-border2); transform: none; box-shadow: none; cursor: default; }
.tsp-cat-item .tsp-sc .tsp-sc-btn.tsp-sc-btn-disabled { margin-top: auto; background: var(--tsp-bg); color: var(--tsp-muted); border: 1.5px solid var(--tsp-border); }

/* ── Images : petit diaporama, agrandies au clic ── */
.tsp-cat-item .tsp-sc-card .tsp-sc-media { aspect-ratio: auto; height: 170px; background: var(--tsp-bg); border-bottom: 1px solid var(--tsp-border); }
.tsp-sc-gallery { position: relative; overflow: hidden; }
.tsp-sc-gallery-track {
  display: flex; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior-x: contain;
}
.tsp-sc-gallery-track::-webkit-scrollbar { display: none; }
.tsp-sc-gallery-slide {
  flex: 0 0 100%; height: 100%; margin: 0; padding: 10px; border: 0; background: transparent;
  scroll-snap-align: center; cursor: zoom-in;
}
.tsp-sc-gallery-slide img { display: block; width: 100%; height: 100%; object-fit: contain; margin: 0; border-radius: 0; }
.tsp-sc-gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 30px; height: 30px; padding: 0 0 3px; border: 1px solid var(--tsp-border); border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .95); color: var(--tsp-navy); font-size: 20px; line-height: 1; font-weight: 700;
  box-shadow: 0 2px 8px rgba(26, 42, 94, .15); transition: opacity .15s, background-color .12s, color .12s;
}
.tsp-sc-gallery-nav:hover { background: var(--tsp-blue); border-color: var(--tsp-blue); color: #fff; }
.tsp-sc-gallery-prev { left: 8px; }
.tsp-sc-gallery-next { right: 8px; }
.tsp-sc-gallery-dots {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 2; display: flex; gap: 6px;
  padding: 5px 8px; border-radius: 20px; background: rgba(26, 42, 94, .35); pointer-events: none;
}
.tsp-sc-gallery-dots span { width: 7px; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .65); transition: width .15s, background-color .15s; }
.tsp-sc-gallery-dots span.is-active { width: 18px; background: #fff; }
.tsp-sc-gallery-zoom {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .95); color: var(--tsp-navy);
  font-size: 14px; box-shadow: 0 2px 6px rgba(26, 42, 94, .12); pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .tsp-sc-gallery .tsp-sc-gallery-nav { opacity: 0; }
  .tsp-sc-gallery:hover .tsp-sc-gallery-nav, .tsp-sc-gallery-nav:focus-visible { opacity: 1; }
}
.tsp-sc-gallery-slide:focus-visible, .tsp-sc-gallery-nav:focus-visible { outline: 3px solid var(--tsp-blue); outline-offset: -3px; }

/* ── Visionneuse plein écran (fond des fenêtres du design de référence) ── */
html.tsp-lb-lock { overflow: hidden; }
.tsp-lb {
  position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center;
  padding: 64px 84px 40px; background: rgba(26, 42, 94, .92); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .2s; font-family: var(--tsp-font);
}
.tsp-lb[hidden] { display: none; }
.tsp-lb.is-open { opacity: 1; }
.tsp-lb-figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tsp-lb-img { max-width: 100%; max-height: calc(100% - 48px); object-fit: contain; border-radius: 8px; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.tsp-lb-caption { margin-top: 12px; color: #fff; font-family: var(--tsp-font-head); font-size: 15px; font-weight: 800; text-align: center; }
.tsp-lb-counter { position: absolute; top: 20px; left: 22px; padding: 4px 12px; border-radius: 20px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 13px; font-weight: 700; }
.tsp-lb-close {
  position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; border: 0; padding: 0 0 3px; border-radius: 50%;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; transition: background-color .12s;
}
.tsp-lb-close:hover { background: var(--tsp-red); }
.tsp-lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; padding: 0 0 4px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 34px; line-height: 1; cursor: pointer;
  transition: background-color .12s;
}
.tsp-lb-nav:hover { background: var(--tsp-blue); }
.tsp-lb-prev { left: 16px; }
.tsp-lb-next { right: 16px; }
.tsp-lb-single .tsp-lb-nav { display: none; }
.tsp-lb button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ── Pagination (style des listes du design de référence) ── */
.tsp-shop-pages { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 28px 0 0; padding-top: 18px; border-top: 1px solid var(--tsp-border); }
.tsp-shop-page {
  display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px;
  border: 1px solid var(--tsp-border2); border-radius: var(--tsp-radius-btn); background: var(--tsp-surface); color: var(--tsp-navy);
  font-size: 13px; font-weight: 700; text-decoration: none; transition: background-color .12s, border-color .12s, color .12s;
}
a.tsp-shop-page:hover { border-color: var(--tsp-blue); background: var(--tsp-blue-soft); color: var(--tsp-blue); text-decoration: none; }
.tsp-shop-page.is-active { background: var(--tsp-blue); border-color: var(--tsp-blue); color: #fff; }
.tsp-shop-page.is-disabled { background: var(--tsp-bg); color: var(--tsp-subtle); border-color: var(--tsp-border); }
.tsp-shop-page:focus-visible { outline: 3px solid var(--tsp-navy); outline-offset: 2px; }
.tsp-shop-page-gap { padding: 0 4px; color: var(--tsp-muted); font-weight: 700; }
.tsp-shop-page-info { flex-basis: 100%; text-align: center; margin-top: 6px; font-size: 12px; color: var(--tsp-muted); }

/* ── Barre du panier en bas de page ── */
.tsp-shop-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin: 24px 0 0; padding: 12px 16px; border: 1px solid var(--tsp-blue-line); border-radius: var(--tsp-radius); background: var(--tsp-blue-soft);
}
.tsp-shop-bottom.has-items { background: var(--tsp-surface); border: 2px solid var(--tsp-blue); box-shadow: 0 6px 18px rgba(26, 42, 94, .08); }
.tsp-shop-bottom-txt { margin: 0; font-size: 14px; font-weight: 700; color: var(--tsp-navy); }

/* ── Messages ── */
.tsp-cat-empty { text-align: center; color: var(--tsp-muted); padding: 32px 0; font-size: 15px; }
.tsp-cat-admin {
  border: 1px solid #f5cc80; background: #fff4e0; color: #8a5a06; border-radius: 9px;
  padding: 12px 16px; font-size: 13px; line-height: 1.5;
}

@media (max-width: 1024px) { .tsp-cat-grid { grid-template-columns: repeat(min(var(--tsp-cat-cols, 3), 2), minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .tsp-cat-wrap { padding: 20px 14px 40px; }
  .tsp-cat-title { font-size: 22px; }
  .tsp-shop-head .tsp-shop-cartbtn { width: 100%; justify-content: center; }
  .tsp-cat-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .tsp-cat-item .tsp-sc-card .tsp-sc-media { height: 180px; }
  .tsp-cat-item .tsp-sc .tsp-sc-btn { min-height: 44px; }   /* cible tactile */
  .tsp-shop-bottom { flex-direction: column; align-items: stretch; text-align: center; }
  .tsp-shop-bottom .tsp-shop-cartbtn { justify-content: center; }
  .tsp-lb { padding: 64px 8px 84px; }
  .tsp-lb-nav { top: auto; bottom: 18px; transform: none; width: 48px; height: 48px; }
  .tsp-lb-prev { left: calc(50% - 60px); } .tsp-lb-next { right: calc(50% - 60px); }
}
@media (prefers-reduced-motion: reduce) {
  .tsp-cat-item .tsp-sc-card, .tsp-shop-cartbtn, .tsp-lb { transition: none; }
  .tsp-cat-item .tsp-sc-card:hover { transform: none; }
}
