/**
 * Chadenac Annual Calendar Styles
 * Milestone 3: Responsive 12-Column Grid & Category Styling
 *
 * Requirements:
 * - Desktop & tablet (>= 768px): 12-column horizontal scrolling grid
 * - Mobile (< 768px): Chronological monthly list view
 * - Grid Geometry: ROW_H: 22px, DAY_COL_W: 42px, LANE_W: 110px
 * - Weekend background: #e2e8f0
 * - Sticky month headers (top: 0, bg: #475569, text: #ffffff)
 * - Official brand category palette & duration threshold styling
 */

/* ==========================================================================
   1. Root Container & Controls
   ========================================================================== */

.chadenac-annual-calendar {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #1e293b;
  margin: 1.5rem 0;
}

.chadenac-annual-calendar *,
.chadenac-annual-calendar *::before,
.chadenac-annual-calendar *::after {
  box-sizing: border-box;
}

/* Barre de contrôles supérieure (Sélecteur d'année + Filtres) */
.chadenac-calendar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Sélecteur d'année ‹ [Année] › */
.chadenac-calendar-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.chadenac-calendar-nav-prev,
.chadenac-calendar-nav-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  border-radius: 6px;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.chadenac-calendar-nav-prev:hover,
.chadenac-calendar-nav-next:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.chadenac-calendar-nav-prev:focus-visible,
.chadenac-calendar-nav-next:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 1px;
}

.chadenac-calendar-nav-year {
  min-width: 64px;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.02em;
}

/* Pastilles de filtres de catégories */
.chadenac-calendar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.chadenac-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.chadenac-filter-pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.chadenac-filter-pill.is-active,
.chadenac-filter-pill[aria-pressed="true"] {
  background: #325e68;
  border-color: #325e68;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(50, 94, 104, 0.25);
}

.chadenac-filter-pill.is-active .chadenac-filter-count,
.chadenac-filter-pill[aria-pressed="true"] .chadenac-filter-count {
  color: rgba(255, 255, 255, 0.85);
}

.chadenac-filter-color {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chadenac-filter-label {
  white-space: nowrap;
}

.chadenac-filter-count {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 400;
}

/* ==========================================================================
   2. Desktop 12-Column Annual Grid (>= 768px)
   ========================================================================== */

.chadenac-annual-calendar-grid-wrapper,
.chadenac-annual-scroll-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  -webkit-overflow-scrolling: touch;
}

.chadenac-annual-calendar-grid {
  display: flex;
  min-width: max-content;
  border-collapse: collapse;
}

/* Colonne d'un mois */
.chadenac-calendar-month-col {
  flex-shrink: 0;
  border-right: 1px solid #cbd5e1;
  background: #ffffff;
  min-width: 152px; /* 42px day column + 110px min 1 lane */
  transition: width 0.15s ease;
}

.chadenac-calendar-month-col:last-child {
  border-right: none;
}

/* En-tête de mois sticky */
.chadenac-calendar-month-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #475569;
  color: #ffffff;
  padding: 6px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chadenac-calendar-month-col.is-current-month .chadenac-calendar-month-header {
  background: #325e68;
  border-bottom-color: #1f3d44;
}

.chadenac-month-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Corps du mois contenant 31 rangées de 22px */
.chadenac-calendar-month-body {
  position: relative;
  height: calc(31 * 22px); /* 682px */
  background: #ffffff;
}

/* Piste de fond des 31 jours */
.chadenac-calendar-days-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Ligne de jour (hauteur constante 22px) */
.chadenac-calendar-day-row {
  position: relative;
  height: 22px;
  line-height: 22px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  background-color: #ffffff;
  box-sizing: border-box;
  font-size: 11px;
}

/* Visualisation distinguée des week-ends (Samedi et Dimanche) */
.chadenac-calendar-day-row.is-weekend {
  background-color: #e2e8f0;
  font-weight: 600;
}

/* Mise en avant de la date du jour */
.chadenac-calendar-day-row.is-today {
  background-color: #e0f2fe;
  box-shadow: inset 0 1px 0 #0284c7, inset 0 -1px 0 #0284c7;
  font-weight: 700;
}

.chadenac-calendar-day-row.is-today .chadenac-day-letter {
  color: #0369a1;
  font-weight: 700;
}

.chadenac-calendar-day-row.is-today .chadenac-day-num {
  color: #0c4a6e;
  font-weight: 800;
  border-right-color: #7dd3fc;
}

/* Jours invalides pour les mois de moins de 31 jours */
.chadenac-calendar-day-row.is-invalid-day {
  background: repeating-linear-gradient(
    45deg,
    #f8fafc,
    #f8fafc 4px,
    #f1f5f9 4px,
    #f1f5f9 8px
  );
  pointer-events: none;
  opacity: 0.65;
}

/* Lettre du jour (16px) et Numéro du jour (22px) + bordure droite = 42px */
.chadenac-day-letter {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  user-select: none;
  padding-left: 2px;
}

.is-weekend .chadenac-day-letter {
  color: #64748b;
  font-weight: 700;
}

.chadenac-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 26px;
  padding-right: 4px;
  font-size: 11px;
  color: #334155;
  user-select: none;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid #e2e8f0;
  height: 100%;
}

.is-weekend .chadenac-day-num {
  color: #1e293b;
  border-right-color: #cbd5e1;
}

/* Calque supérieur des événements dynamiques */
.chadenac-calendar-events-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

/* ==========================================================================
   3. Event Block Anatomy & Typography Scaling
   ========================================================================== */

.chadenac-event-block {
  position: absolute;
  z-index: 2;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 10px;
  line-height: 1.15;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease, box-shadow 0.1s ease;
  box-sizing: border-box;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  color: #0f172a;
}

.chadenac-event-block:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.chadenac-event-block:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 1px;
}

/* Événements fermés ou complets */
.chadenac-event-block.opacity-65,
.chadenac-event-block.is-closed {
  opacity: 0.65;
}

/* Titre du séjour (spanDays >= 1) */
.chadenac-event-title {
  font-weight: 600;
  font-size: 10px;
  line-height: 1.15;
  word-break: break-word;
  white-space: normal;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Méta : Places disponibles + Étoile si featured (spanDays >= 2) */
.chadenac-event-meta {
  opacity: 0.85;
  font-size: 9px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  line-height: 1;
}

.chadenac-event-spots-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chadenac-icon-users {
  display: inline-block;
  vertical-align: middle;
}

.chadenac-icon-star {
  color: #d97706;
  font-size: 10px;
  line-height: 1;
}

/* Dates formatées dd/MM -> dd/MM (spanDays >= 3) */
.chadenac-event-dates {
  opacity: 0.75;
  font-size: 9px;
  margin-top: 1px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Badge Fermé (spanDays >= 4 && !isOpen) */
.chadenac-event-badge-closed {
  display: inline-block;
  margin-top: 2px;
  padding: 0 4px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid currentColor;
  border-radius: 3px;
  width: fit-content;
  line-height: 1.3;
}

/* Message d'état vide sur l'année */
.chadenac-calendar-empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  margin: 1rem 0;
}

/* ==========================================================================
   4. Official Brand Category Palette (3-tone styling)
   ========================================================================== */

.chadenac-cat-spiritual_session {
  border-left: 4px solid #9333ea;
  background-color: rgba(147, 51, 234, 0.18);
  color: #581c87;
}

.chadenac-cat-spiritual_weekend {
  border-left: 4px solid #ec4899;
  background-color: rgba(236, 72, 153, 0.18);
  color: #831843;
}

.chadenac-cat-autonomous_stage {
  border-left: 4px solid #3b82f6;
  background-color: rgba(59, 130, 246, 0.18);
  color: #1e3a8a;
}

.chadenac-cat-residential_stage {
  border-left: 4px solid #059669;
  background-color: rgba(5, 150, 105, 0.18);
  color: #064e3b;
}

.chadenac-cat-children_teens {
  border-left: 4px solid #f59e0b;
  background-color: rgba(245, 158, 11, 0.18);
  color: #78350f;
}

.chadenac-cat-family_stay {
  border-left: 4px solid #e91e63;
  background-color: rgba(233, 30, 99, 0.18);
  color: #880e4f;
}

.chadenac-cat-solo_stay {
  border-left: 4px solid #8b5cf6;
  background-color: rgba(139, 92, 246, 0.18);
  color: #4c1d95;
}

.chadenac-cat-pilgrimage {
  border-left: 4px solid #6366f1;
  background-color: rgba(99, 102, 241, 0.18);
  color: #312e81;
}

.chadenac-cat-retreat {
  border-left: 4px solid #a855f7;
  background-color: rgba(168, 85, 247, 0.18);
  color: #581c87;
}

.chadenac-cat-formation {
  border-left: 4px solid #14b8a6;
  background-color: rgba(20, 184, 166, 0.18);
  color: #134e4a;
}

.chadenac-cat-alsh_period,
.chadenac-cat-alsh {
  border-left: 4px solid #06b6d4;
  background-color: rgba(6, 182, 212, 0.18);
  color: #164e63;
}

/* ==========================================================================
   5. Mobile Chronological List Layout (< 768px)
   ========================================================================== */

.chadenac-calendar-mobile-list {
  display: none;
  width: 100%;
}

.chadenac-mobile-month-group {
  margin-bottom: 2rem;
}

.chadenac-mobile-month-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 0.875rem 0;
  padding-bottom: 0.375rem;
  border-bottom: 2px solid #e2e8f0;
}

.chadenac-mobile-month-events {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.chadenac-mobile-event-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chadenac-mobile-event-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.chadenac-mobile-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.chadenac-mobile-event-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
}

.chadenac-mobile-event-featured {
  color: #d97706;
  font-size: 1.125rem;
  line-height: 1;
}

.chadenac-mobile-event-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.5rem 0;
}

.chadenac-mobile-event-title a {
  color: #1e293b;
  text-decoration: none;
}

.chadenac-mobile-event-title a:hover {
  color: #0284c7;
  text-decoration: underline;
}

.chadenac-mobile-event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
  font-size: 0.8125rem;
  color: #64748b;
  margin-bottom: 0.875rem;
}

.chadenac-mobile-event-dates,
.chadenac-mobile-event-spots {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.chadenac-mobile-event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chadenac-empty-list {
  padding: 2.5rem 1rem;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

/* ==========================================================================
   6. Responsive Breakpoint Switch (768px Strict Contract)
   ========================================================================== */

/* Écrans mobiles (< 768px) */
@media (max-width: 767.98px) {
  .chadenac-annual-calendar-grid-wrapper,
  .chadenac-annual-scroll-container {
    display: none !important;
  }

  .chadenac-calendar-mobile-list {
    display: block !important;
  }

  .chadenac-calendar-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .chadenac-calendar-nav {
    justify-content: center;
  }

  .chadenac-calendar-filters {
    justify-content: center;
  }
}

/* Écrans tablettes et ordinateurs (>= 768px) */
@media (min-width: 768px) {
  .chadenac-annual-calendar-grid-wrapper,
  .chadenac-annual-scroll-container {
    display: block !important;
  }

  .chadenac-calendar-mobile-list {
    display: none !important;
  }
}
