/**
 * ATPEP Events Calendar — styles pixel-perfect d'après maquette Figma.
 */

.atpep-ec {
  --ec-navy:        #1B2559;
  --ec-navy-dark:   #141B45;
  --ec-red:         #C21B2A;
  --ec-red-light:   #D83340;
  --ec-red-hover:   #A3111F;
  --ec-text:        #1B2559;
  --ec-muted:       #6B7280;
  --ec-border:      #E5E7EB;
  --ec-bg:          #FFFFFF;
  --ec-radius:      4px;
  --ec-radius-pill: 6px;
  --ec-cell-min-h:  100px;

  color: var(--ec-text);
  padding: 48px 16px;
  max-width: 1280px;
  margin: 0 auto;
  box-sizing: border-box;
  font-family: inherit;
}

.atpep-ec *,
.atpep-ec *::before,
.atpep-ec *::after {
  box-sizing: border-box;
}

/* ============= Titre ============= */
.atpep-ec__title {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: var(--ec-navy);
  margin: 0 0 40px 0;
  padding-bottom: 8px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.atpep-ec__title-underline {
  display: block;
  width: 72px;
  height: 3px;
  background: var(--ec-red);
  margin: 14px auto 0;
  border-radius: 2px;
}

/* ============= Grille ============= */
.atpep-ec__grid-wrapper {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.atpep-ec__grid {
  display: grid;
  grid-template-columns: repeat(var(--ec-cols, 6), minmax(0, 1fr));
  border: 1px solid var(--ec-navy);
  background: var(--ec-bg);
  overflow: hidden;
}

.atpep-ec__cell {
  border-right: 1px solid var(--ec-navy);
  min-height: var(--ec-cell-min-h);
  display: flex;
  flex-direction: column;
  background: var(--ec-bg);
}

.atpep-ec__cell:last-child {
  border-right: none;
}

/* ============= Entête de mois (bandeau navy) ============= */
.atpep-ec__month-head {
  background: var(--ec-navy);
  color: #fff;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 1.2;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.atpep-ec__month-label {
  text-transform: none;
}

/* ============= Conteneur événements ============= */
.atpep-ec__events {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* ============= Pastilles rouges (pills) ============= */
.atpep-ec__pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ec-red);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--ec-radius-pill);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  width: 100%;
  line-height: 1.25;
  min-height: 28px;
  font-family: inherit;
  transition: background-color .15s ease, transform .15s ease, box-shadow .15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.atpep-ec__pill:hover {
  background: var(--ec-red-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(194, 27, 42, 0.25);
}

.atpep-ec__pill:focus {
  outline: none;
}

.atpep-ec__pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(194, 27, 42, 0.35);
}

.atpep-ec__pill-day {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.atpep-ec__pill-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  font-size: 12px;
}

/* ============= État vide ============= */
.atpep-ec__empty {
  text-align: center;
  color: var(--ec-muted);
  padding: 32px 16px;
  font-style: italic;
}

/* ============= Responsive ============= */
@media (max-width: 1024px) {
  .atpep-ec__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .atpep-ec__cell {
    border-right: 1px solid var(--ec-navy);
    border-bottom: 1px solid var(--ec-navy);
  }
  .atpep-ec__cell:nth-child(3n) { border-right: none; }
  .atpep-ec__cell:nth-last-child(-n+3) { border-bottom: none; }
}

@media (max-width: 640px) {
  .atpep-ec { padding: 32px 12px; }
  .atpep-ec__title { font-size: 24px; margin-bottom: 28px; }
  .atpep-ec__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .atpep-ec__cell:nth-child(3n) { border-right: 1px solid var(--ec-navy); }
  .atpep-ec__cell:nth-child(2n) { border-right: none; }
  .atpep-ec__cell:nth-last-child(-n+2) { border-bottom: none; }
  .atpep-ec__month-head { font-size: 13px; padding: 9px 12px; min-height: 36px; }
}

/* ============================================================ */
/* ========== Popup / Bulle de détails ========================= */
/* ============================================================ */

.atpep-ec-popup[hidden] { display: none !important; }

.atpep-ec-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: atpep-ec-fade .2s ease;
}

@keyframes atpep-ec-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.atpep-ec-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 27, 69, 0.65);
  cursor: pointer;
}

.atpep-ec-popup__card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: atpep-ec-slide .25s cubic-bezier(.2, .8, .2, 1);
}@keyframes atpep-ec-slide {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.atpep-ec-popup__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
  padding: 0;
}

.atpep-ec-popup__close:hover {
  background: rgba(0, 0, 0, 0.78);
  transform: rotate(90deg);
}

.atpep-ec-popup__image-wrap {
  width: 100%;
  max-height: 260px;
  background: #F3F4F6;
  overflow: hidden;
  flex-shrink: 0;
}

.atpep-ec-popup__image-wrap[data-empty="true"] {
  display: none;
}

.atpep-ec-popup__image {
  width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

.atpep-ec-popup__body {
  padding: 24px 28px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.atpep-ec-popup__date {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ec-red);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
}

.atpep-ec-popup__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ec-navy);
  margin: 0 0 10px 0;
  line-height: 1.25;
}

.atpep-ec-popup__address {
  font-size: 13px;
  color: var(--ec-muted);
  margin: 0 0 14px 0;
  display: none;
}

.atpep-ec-popup__address[data-has-value="true"] {
  display: block;
}

.atpep-ec-popup__description {
  font-size: 14px;
  color: #4B5563;
  line-height: 1.6;
  margin: 0 0 20px 0;
  flex: 1;
}

.atpep-ec-popup__cta {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  background: #1b2559 !important;
  background-color: #1b2559 !important;
  color: #fff !important;
  padding: 10px 22px !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  transition: background .15s, transform .15s !important;
  letter-spacing: 0.2px !important;
  align-self: flex-start;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  border: none !important;
  cursor: pointer !important;
  margin-top: auto;
  white-space: nowrap;
  min-height: 40px;
}

.atpep-ec-popup__cta:hover {
  background: #c21b2a !important;
  transform: translateX(2px);
  color: #fff !important;
}

@media (max-width: 480px) {
  .atpep-ec-popup__card { border-radius: 10px; }
  .atpep-ec-popup__body { padding: 20px 20px 22px; }
  .atpep-ec-popup__title { font-size: 19px; }
}
