/* css/catalog-cards.css
  Styles pour l'affichage des cartes du catalogue.
  Utilisé par: `views/catalog.php` (SSR) et `js/catalog.php` (embed client).
*/

:root {
  --catalog-bg: #ffffff;
  --catalog-text: #0f172a;
  --catalog-muted: #64748b;
  --catalog-accent: #207f7f;
  --catalog-border: rgba(15, 23, 42, 0.08);
  --catalog-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.catalog-cards {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
  justify-content: start;
  align-items: stretch;
  width: 100%;
}

/* Explicit columns when configured via class `catalog-cols-N` */
.catalog-cards.catalog-cols-1 { grid-template-columns: repeat(1, 1fr); }
.catalog-cards.catalog-cols-2 { grid-template-columns: repeat(2, 1fr); }
.catalog-cards.catalog-cols-3 { grid-template-columns: repeat(3, 1fr); }
.catalog-cards.catalog-cols-4 { grid-template-columns: repeat(4, 1fr); }
.catalog-cards.catalog-cols-5 { grid-template-columns: repeat(5, 1fr); }
.catalog-cards.catalog-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Make cards stretch to fill column width when explicit columns are used */
.catalog-cards.catalog-cols-1:not(.catalog--row) .catalog-card,
.catalog-cards.catalog-cols-2:not(.catalog--row) .catalog-card,
.catalog-cards.catalog-cols-3:not(.catalog--row) .catalog-card,
.catalog-cards.catalog-cols-4:not(.catalog--row) .catalog-card,
.catalog-cards.catalog-cols-5:not(.catalog--row) .catalog-card,
.catalog-cards.catalog-cols-6:not(.catalog--row) .catalog-card {
  max-width: none;
  width: 100%;
}

/* On small screens, collapse to a single column for readability */
@media (max-width: 720px) {
  .catalog-cards.catalog-cols-1,
  .catalog-cards.catalog-cols-2,
  .catalog-cards.catalog-cols-3,
  .catalog-cards.catalog-cols-4,
  .catalog-cards.catalog-cols-5,
  .catalog-cards.catalog-cols-6 {
    grid-template-columns: repeat(1, 1fr) !important;
  }
}

.catalog-card {
  background: var(--catalog-bg);
  border: 1px solid var(--catalog-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--catalog-shadow);
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-width: 360px;
  text-align: left;
}

.catalog-card__media {
  position: relative;
  height: 170px;
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
}

.catalog-card--no-image .catalog-card__media {
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

.catalog-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.catalog-card__badge--full {
  left: auto;
  right: 12px;
  background: rgba(239, 68, 68, 0.85);
}

.catalog-card__flag,
.catalog-card__region {
  position: absolute;
  bottom: 12px;
  width: 34px;
  height: 24px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.catalog-card__flag { left: 12px; }
.catalog-card__region { left: 54px; }

.catalog-card__body {
  padding: 16px 18px 6px 18px;
  display: grid;
  gap: 6px;
  color: var(--catalog-text);
}

.catalog-card__date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--catalog-accent);
  letter-spacing: 0.06em;
}

.catalog-card__title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.catalog-card__subtitle {
  font-size: 15px;
  font-style: italic;
  color: var(--catalog-muted);
}

.catalog-card__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  
}

/* Icônes catalogue : forme SVG déclarée une fois, couleur via currentColor */
.catalog-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 14px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 14px 14px;
  mask-size: 16px 16px;
  -webkit-mask-position: center;
  mask-position: center;
}

.catalog-icon--date {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

.catalog-icon--location {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 6-9 13-9 13s-9-7-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 6-9 13-9 13s-9-7-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
}

.catalog-icon--duration {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpolyline points='12 7 12 12 16 14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpolyline points='12 7 12 12 16 14'/%3E%3C/svg%3E");
}
.catalog-list-item .catalog-icon{
  margin-right:5px;
  vertical-align: middle;
}
.catalog-card__actions {
  margin-top: auto;
  padding: 12px 18px 18px 18px;
}

.catalog-card__button, .catalog-list-item__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--catalog-accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 6px 12px rgba(32, 127, 127, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.catalog-card__button:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 6px rgba(32, 127, 127, 0.25);
}

.catalog-card__button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 3px rgba(32, 127, 127, 0.2);
}

.catalog-card__button--disabled {
  background: #cbd5e1;
  color: #475569;
  box-shadow: none;
  cursor: not-allowed;
}

.catalog-card__button--disabled:hover,
.catalog-card__button--disabled:active {
  transform: none;
  box-shadow: none;
}

/* List mode styles */
.catalog--list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.catalog-list-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 20px 16px;
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.catalog-card:hover, .catalog-list-item:hover{
  box-shadow: none;
}
.catalog-list-item__thumb {
  width: 120px;
  height: 76px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3), 0 4px 10px rgba(15, 23, 42, 0.2);
}
.catalog-list-item--no-image .catalog-list-item__thumb {
  background-image: linear-gradient(135deg, #0f172a, #1e293b);
}
.catalog-list-item__content {
  display: grid;
  gap: 4px;
}
.catalog-list-item__title {
  font-weight: 700;
  color: var(--catalog-text);
  font-size: 18px;
  line-height: 1.2;
}
.catalog-list-item__meta {
  color: var(--catalog-muted);
  font-size: 16px;
}
.catalog-list-item__subtitle {
  color: var(--catalog-muted);
  font-size: 14px;
  font-style:italic;
}
.catalog-list-item__action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Earlybird badge in list view: small pill above the action button */
.catalog-list-item__badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.catalog-list-item__badge--earlybird {
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: #111827;
  box-shadow: 0 6px 14px rgba(249,115,22,0.18);
}
.catalog-list-item__button {
  font-weight: normal;
  padding:0.3em 1em;
}
.catalog-list-item__button:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 6px rgba(32, 127, 127, 0.25);
}

.catalog-list-item__button--disabled {
  background: #e2e8f0;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

.catalog-list-item__button--disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Mixed mode: after a set of cards, list items should break to a full-width row */
.catalog--mixed .catalog-list-item {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
}

/* Row mode: horizontal scroller */
.catalog--row {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 10px 44px 10px 44px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}
.catalog--row .catalog-card {
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.catalog-row {
  position: relative;
}
.catalog-row__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(15,23,42,0.12);
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(15,23,42,0.15);
  cursor: pointer;
}
.catalog-row__nav--prev { left: 4px; }
.catalog-row__nav--next { right: 4px; }
.catalog-row__nav:focus {
  outline: 3px solid rgba(32,127,127,0.2);
}

/* Accessibility: ensure focus for cards in row */
.catalog--row .catalog-card:focus {
  outline: 3px solid rgba(32,127,127,0.18);
}

@media (max-width: 720px) {
  /* Vue liste → même mise en page carte sur mobile */
  .catalog-list-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    overflow: hidden;
  }
  .catalog-list-item__thumb {
    width: 100%;
    height: 150px;
    border-radius: 0;
    box-shadow: none;
  }
  .catalog-list-item__content {
    padding: 12px 16px 8px;
  }
  .catalog-list-item__action {
    padding: 0 16px 16px;
    align-items: stretch;
  }
  .catalog-list-item__button {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }
}

/* Filter UI styles (search + formation chips) */
.catalog-filter-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.catalog-filter-input {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(16,24,40,0.03);
  font-size: 14px;
}
.catalog-filter-formations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.catalog-filter-formations .catalog-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #e6e7eb;
  background: #ffffff;
  color: var(--catalog-text);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.catalog-filter-formations .catalog-chip span { color: #9ca3af; margin-left: 6px; }
.catalog-filter-formations .catalog-chip.active,
.catalog-filter-formations .catalog-chip[aria-pressed="true"] {
  background: #ecfdf5;
  border-color: #34d399;
}

.catalog-chip-count {
  display: inline-block;
  background: #f3f4f6;
  color: #374151;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}
.catalog-chip-close { color:#9ca3af; margin-left:6px; font-weight:700; }

@media (max-width: 520px) {
  .catalog-filter-input { width: 100%; max-width: none; }
  .catalog-filter-wrapper { flex-direction: column; align-items: stretch; }
}
