/* ============================================================
   Calendario Parrocchia — stile iOS Calendar
   ============================================================ */

.calendario-parrocchia {
  container-type: inline-size;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  color: #1C1C1E;
}

/* ── Wrapper ───────────────────────────────────────────────── */
.cal-wrap {
  background: #FFFFFF;
  border-radius: 16px;
  border: 1px solid #E5E5EA;
  box-shadow: 0 2px 24px rgba(0,0,0,0.07);
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  background: #fff;
  border-bottom: 1px solid #E5E5EA;
}

.cal-title-block {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.cal-month-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1C1C1E;
  letter-spacing: -0.01em;
}

.cal-year-name {
  font-size: 1.125rem;
  font-weight: 400;
  color: #6D6D72;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: #F2F2F7;
  border-radius: 50%;
  cursor: pointer;
  color: #3C3C43;
  transition: background 0.15s;
  flex-shrink: 0;
}

.cal-nav svg {
  width: 8px;
  height: 14px;
}

.cal-nav:hover  { background: #E5E5EA; }
.cal-nav:active { background: #D1D1D6; transform: scale(0.94); }

/* ── Riga giorni settimana ─────────────────────────────────── */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid #E5E5EA;
  background: #F9F9F9;
}

.cal-weekdays span {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8E8E93;
  padding: 6px 0;
}

.cal-weekdays span:nth-child(6),
.cal-weekdays span:nth-child(7) {
  color: #C0392B; /* sab/dom in rosso come iOS */
}

/* ── Grid wrap ─────────────────────────────────────────────── */
.cal-grid-wrap {
  position: relative;
  min-height: 120px;
}

/* ── Griglia giorni ────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid #E5E5EA;
}

/* ── Cella giorno ──────────────────────────────────────────── */
.cal-cell {
  border-right: 1px solid #E5E5EA;
  border-bottom: 1px solid #E5E5EA;
  padding: 4px 4px 4px;
  cursor: pointer;
  transition: background 0.12s;
  min-width: 0;
  background: #fff;
}

/* Su desktop overflow:hidden è gestito dal flex+aspect-ratio */
@media (min-width: 600px) {
  .cal-cell { overflow: hidden; }
}

.cal-cell.cal-empty {
  background: #FAFAFA;
  cursor: default;
  pointer-events: none;
}

.cal-cell.cal-outside {
  background: #FAFAFA;
}

.cal-cell.cal-outside .cal-day-num {
  color: #B0B0B8;
}

.cal-cell:hover:not(.cal-empty) { background: #F2F2F7; }
.cal-cell:active:not(.cal-empty) { background: #E5E5EA; }

/* Weekend */
.cal-grid > .cal-cell:nth-child(7n+6),
.cal-grid > .cal-cell:nth-child(7n)  { background: #FFF9F9; }
.cal-grid > .cal-cell:nth-child(7n+6):hover,
.cal-grid > .cal-cell:nth-child(7n):hover { background: #FFF0F0; }

/* ── Numero del giorno ─────────────────────────────────────── */
.cal-day-head {
  display: flex;
  justify-content: center;
  margin-bottom: 3px;
}

.cal-day-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #1C1C1E;
  flex-shrink: 0;
  line-height: 1;
}

/* Weekend num */
.cal-grid > .cal-cell:nth-child(7n+6) .cal-day-num,
.cal-grid > .cal-cell:nth-child(7n)   .cal-day-num { color: #C0392B; }

/* Oggi */
.cal-cell.is-today .cal-day-num {
  background: #273583;
  color: #fff;
  font-weight: 700;
}

/* Selezionato — !important necessario per battere il selettore nth-child del weekend */
.cal-cell.is-selected .cal-day-num {
  background: #17365d !important;
  color: #fff !important;
  font-weight: 700;
}

.cal-cell.is-selected {
  background: #eef4fb !important;
}

/* ── Pillole evento in griglia ─────────────────────────────── */
.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

.cal-pill {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 0;
  overflow: hidden;
}

.cal-pill-time {
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1.4;
  white-space: nowrap;
}

.cal-pill-title {
  font-size: 0.625rem;
  color: #3C3C43;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  min-width: 0;
}

.cal-cell-more {
  font-size: 0.58rem;
  color: #8E8E93;
  font-weight: 600;
  padding: 0 4px;
  line-height: 1.5;
  flex-shrink: 0;
}

/* ── Responsive: schermi più larghi mostrano più testo ─────── */
/* Desktop: celle quadrate con flex per ancorare "+N altri" in fondo */
@media (min-width: 600px) {
  .cal-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
  }
  .cal-day-events {
    flex: 1;
    min-height: 0;
  }
  .cal-cell-more { margin-top: auto; }
}

@container (min-width: 480px) {
  .cal-pill-time  { font-size: 0.7rem; }
  .cal-pill-title { font-size: 0.7rem; }
  .cal-day-num    { width: 28px; height: 28px; font-size: 0.875rem; }
}

@container (min-width: 640px) {
  .cal-pill       { padding: 2px 5px; gap: 4px; }
  .cal-pill-time  { font-size: 0.75rem; }
  .cal-pill-title { font-size: 0.75rem; }
  .cal-day-num    { width: 30px; height: 30px; font-size: 0.9375rem; }
}

/* ── Loading ───────────────────────────────────────────────── */
.cal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(2px);
}

.cal-loading[hidden] { display: none; }

.cal-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #E5E5EA;
  border-top-color: #273583;
  border-radius: 50%;
  animation: calSpin 0.7s linear infinite;
}

@keyframes calSpin { to { transform: rotate(360deg); } }

.cal-error {
  text-align: center;
  color: #C0392B;
  font-size: 0.875rem;
  padding: 1.5rem 1rem;
}
.cal-error[hidden] { display: none; }

/* ── Pannello dettaglio ────────────────────────────────────── */
.cal-panel {
  border-top: 1px solid #E5E5EA;
  background: #F9F9F9;
  animation: calDown 0.2s cubic-bezier(.25,.46,.45,.94);
}

@keyframes calDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #E5E5EA;
  background: #fff;
}

.cal-panel-date {
  font-size: 0.875rem;
  color: #3C3C43;
  text-transform: capitalize;
}

.cal-panel-date b { color: #1C1C1E; font-weight: 700; }

.cal-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #E5E5EA;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #6D6D72;
  flex-shrink: 0;
  transition: background 0.12s;
}

.cal-panel-close svg { width: 10px; height: 10px; }
.cal-panel-close:hover { background: #D1D1D6; }

.cal-panel-list {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Card evento nel pannello ──────────────────────────────── */
.cal-card {
  background: #fff;
  border-radius: 10px;
  padding: 10px 13px;
  border-left: 4px solid #273583;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.cal-card-time {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.cal-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #1C1C1E;
  line-height: 1.3;
  margin-bottom: 6px;
}

.cal-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Badge risorsa/luogo/gruppo */
.cal-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  outline-offset: -1px;
}

.cal-no-events {
  text-align: center;
  color: #8E8E93;
  font-size: 0.875rem;
  padding: 20px 0;
}

/* ── Call to action ────────────────────────────────────────── */
.cal-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f7f9fc, #eef4fb);
  border-top: 1px solid #d7dfec;
}

.cal-cta-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cal-cta-info strong {
  font-size: 0.875rem;
  font-weight: 700;
  color: #17365d;
}

.cal-cta-info span {
  font-size: 0.75rem;
  color: #273583;
}

.cal-cta-btn {
  display: inline-block;
  background: #273583;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.cal-cta-btn:hover  { background: #17365d; }
.cal-cta-btn:active { transform: scale(0.96); }

@container (max-width: 360px) {
  .cal-cta        { flex-direction: column; align-items: stretch; }
  .cal-cta-btn    { text-align: center; box-sizing: border-box; width: 100%; }
  .cal-month-name,
  .cal-year-name  { font-size: 1rem; }
}
