/* Galerie — disposition agnostique du thème (cartes, badges, boutons, recherche).
   Les tokens de thème (--g-*) ne vivent PLUS ici : depuis v1.3.22 ils sont
   compilés dans les bundles bootstrap par-mode depuis custom.scss, que Quarto
   charge deux fois (flatly = clair, darkly = sombre). Le vrai mécanisme de
   bascule de Quarto (échange de bundles + body.quarto-dark/.quarto-light)
   sélectionne alors les tokens via les règles :root de chaque bundle.
   NE PAS réintroduire ici de [data-bs-theme="…"] ni de @media (prefers-color-
   scheme: …) pour ces tokens : Quarto 1.10.18 n'émet jamais l'attribut
   data-bs-theme et un media query brut découplerait les cartes (toujours
   sombres en OS sombre, même sur page claire) — régression corrigée en v1.3.22. */

/* Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem 0;
  list-style: none;
  margin: 0;
}

/* Card */
.g-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--g-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  color: var(--g-text);
}

.g-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--g-shadow-hover);
  background: var(--g-surface-hover);
}

/* Type badge (left border accent) */
.g-card--cours {
  border-left: 4px solid var(--g-badge-cours-text);
}

.g-card--tp {
  border-left: 4px solid var(--g-badge-tp-text);
}

.g-card__badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.25em 0.6em;
  border-radius: 4px;
}

.g-card--cours .g-card__badge {
  background: var(--g-badge-cours-bg);
  color: var(--g-badge-cours-text);
}

.g-card--tp .g-card__badge {
  background: var(--g-badge-tp-bg);
  color: var(--g-badge-tp-text);
}

/* Title */
.g-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  color: var(--g-text);
}

.g-card__title a {
  color: inherit;
  text-decoration: none;
}

.g-card__title a:hover {
  color: var(--g-next-hover);
}

/* Subtitle */
.g-card__subtitle {
  font-size: 0.9rem;
  color: var(--g-text-secondary);
  margin: 0 0 0.75rem 0;
  font-weight: 400;
}

/* Description */
.g-card__desc {
  font-size: 0.9rem;
  color: var(--g-text-secondary);
  margin: 0 0 1rem 0;
  line-height: 1.5;
  flex-grow: 1;
}

/* Meta (date) */
.g-card__meta {
  font-size: 0.8rem;
  color: var(--g-text-secondary);
  margin-bottom: 1rem;
  opacity: 0.8;
}

/* Action buttons */
.g-card__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.g-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 1em;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.g-btn--notes {
  background: var(--g-btn-notes-bg);
  color: var(--g-btn-notes-text);
  border: 1px solid transparent;
}

.g-btn--notes:hover {
  background: var(--g-btn-notes-hover);
  color: var(--g-btn-notes-text);
}

.g-btn--slides {
  background: var(--g-btn-slides-bg);
  color: var(--g-btn-slides-text);
  border: 1px solid var(--g-btn-slides-border);
}

.g-btn--slides:hover {
  background: var(--g-btn-slides-hover-bg);
  color: var(--g-btn-slides-text);
}

/* Next indicator */
.g-card__next {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  font-size: 1.2rem;
  color: var(--g-next-color);
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
  padding: 0.25em;
}

.g-card__next:hover {
  color: var(--g-next-hover);
  transform: translateX(3px);
}

/* Search header */
.gallery-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  margin-bottom: 0.5rem;
}

.gallery-search {
  flex: 1;
  max-width: 400px;
  padding: 0.6em 1em;
  font-size: 0.9rem;
  border: 1px solid var(--g-search-border);
  border-radius: 8px;
  background: var(--g-search-bg);
  color: var(--g-text);
  outline: none;
  transition: border-color 0.15s ease;
}

.gallery-search:focus {
  border-color: var(--g-next-hover);
}

.gallery-search::placeholder {
  color: var(--g-text-secondary);
  opacity: 0.7;
}

.gallery-count {
  font-size: 0.8rem;
  color: var(--g-text-secondary);
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem 0;
  }

  .g-card {
    padding: 1.25rem;
  }

  .gallery-header {
    flex-direction: column;
    align-items: stretch;
  }

  .gallery-search {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .g-card__actions {
    flex-direction: column;
  }

  .g-btn {
    justify-content: center;
    width: 100%;
  }
}
