/* ─── Gallery — modern minimal course index ─── */

:root {
  --g-bg: #f9fafb;
  --g-surface: #ffffff;
  --g-text: #111827;
  --g-text-muted: #6b7280;
  --g-border: #e5e7eb;
  --g-primary: #2563eb;
  --g-primary-hover: #1d4ed8;
  --g-green: #059669;
  --g-green-bg: #ecfdf5;
  --g-blue-bg: #eff6ff;
  --g-radius: 10px;
  --g-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --g-shadow-hover: 0 10px 25px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --g-bg: #0f172a;
    --g-surface: #1e293b;
    --g-text: #f1f5f9;
    --g-text-muted: #94a3b8;
    --g-border: #334155;
    --g-primary: #3b82f6;
    --g-primary-hover: #60a5fa;
    --g-green: #34d399;
    --g-green-bg: #064e3b;
    --g-blue-bg: #1e3a5f;
    --g-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --g-shadow-hover: 0 10px 25px rgba(0,0,0,0.4);
  }
}

/* Override Quarto's listing wrapper */
#listing-gallery-listing,
#listing-sec-01, #listing-sec-02, #listing-sec-03,
#listing-sec-04, #listing-sec-05, #listing-sec-06,
#listing-sec-07, #listing-sec-08, #listing-sec-09,
#listing-sec-10, #listing-sec-11, #listing-sec-12 {
  width: 100%;
  max-width: 100%;
}

/* ─── Header / Search ─── */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.gallery-search {
  flex: 1;
  max-width: 360px;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  font-size: 0.9375rem;
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  background: var(--g-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  color: var(--g-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gallery-search:focus {
  outline: none;
  border-color: var(--g-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

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

/* ─── Grid ─── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 0 0.5rem;
  max-width: 1200px;
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .gallery-header {
    flex-direction: column;
    align-items: stretch;
  }
  .gallery-search {
    max-width: none;
  }
}

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

.g-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--g-shadow-hover);
  border-color: var(--g-primary);
}

.g-card--cours {
  border-left: 3px solid var(--g-primary);
}

.g-card--tp {
  border-left: 3px solid var(--g-green);
}

/* ─── Badge ─── */
.g-card__badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

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

/* ─── Typography ─── */
.g-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--g-text);
  margin: 0 0 0.25rem;
  padding-right: 5rem; /* room for badge */
}

.g-card__subtitle {
  font-size: 0.875rem;
  color: var(--g-text-muted);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.g-card__desc {
  font-size: 0.9375rem;
  color: var(--g-text);
  line-height: 1.6;
  margin: 0;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Meta ─── */
.g-card__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--g-text-muted);
}

.g-card__time {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* ─── Action buttons ─── */
.g-card__actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--g-border);
}

.g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s, transform 0.1s;
  min-height: 36px;
}

.g-btn:active {
  transform: scale(0.97);
}

.g-btn--notes {
  background: var(--g-primary);
  color: #fff;
}

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

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

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

/* ─── Next indicator ─── */
.g-card__next {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--g-text-muted);
  text-decoration: none;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.g-card__next:hover {
  background: var(--g-blue-bg);
  color: var(--g-primary);
}

/* ─── Empty state ─── */
.gallery-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--g-text-muted);
  font-size: 1rem;
}
