/* Upcoming Events module (mod_eventmanager_upcoming).
   Self-contained: no Bootstrap/UIkit/icon font needed, and every colour is set explicitly so the
   cards stay readable inside dark or light template sections. Accent colours come from the
   module's Appearance settings. */

.em-upcoming {
  --em-cols: 3;
  --em-per-row: var(--em-cols);
  --em-gap: 30px;
  --em-accent: #044678;
  --em-hover: #4c6406;
  --em-card-bg: #ffffff;
  --em-text: #333333;
  --em-heading: #1a1a1a;
  --em-muted: #5f6368;
  --em-border: rgba(0, 0, 0, .12);
}

/* Centred flex layout: 1 or 2 events sit in the middle instead of the first columns. */
.em-upcoming .em-upcoming-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--em-gap);
}

.em-upcoming .em-upcoming-card {
  display: flex;
  flex: 0 1 calc((100% - (var(--em-per-row) - 1) * var(--em-gap)) / var(--em-per-row));
  flex-direction: column;
  /* Wraps to fewer per row in narrow positions (e.g. a sidebar) instead of squashing. */
  min-width: min(100%, 240px);
  border: 1px solid var(--em-border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--em-card-bg);
  color: var(--em-text);
  text-align: left;
  transition: box-shadow .3s ease, transform .3s ease;
}

.em-upcoming .em-upcoming-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, .25);
  transform: translateY(-3px);
}

/* Date block in place of a photo */
.em-upcoming .em-upcoming-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 10px 16px;
  background: var(--em-accent);
  color: #fff;
  line-height: 1.1;
  text-decoration: none;
  transition: background .3s ease;
}

.em-upcoming .em-upcoming-card:hover .em-upcoming-date {
  background: var(--em-hover);
}

.em-upcoming .em-upcoming-date:hover,
.em-upcoming .em-upcoming-date:focus {
  color: #fff;
  text-decoration: none;
}

.em-upcoming .em-upcoming-month {
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.em-upcoming .em-upcoming-day {
  color: #fff;
  font-size: 2.8rem;
  font-weight: 700;
}

.em-upcoming .em-upcoming-weekday {
  color: #fff;
  font-size: .85rem;
  opacity: .9;
}

.em-upcoming .em-upcoming-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px 20px 20px;
}

.em-upcoming .em-upcoming-title {
  margin: 0 0 8px;
  color: var(--em-heading);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
  text-transform: none;
}

.em-upcoming .em-upcoming-title a {
  color: var(--em-heading);
  text-decoration: none;
}

.em-upcoming .em-upcoming-title a:hover,
.em-upcoming .em-upcoming-title a:focus {
  color: var(--em-accent);
}

.em-upcoming .em-upcoming-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 12px;
  color: var(--em-muted);
  font-size: .9rem;
  line-height: 1.4;
}

.em-upcoming .em-upcoming-meta > span {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.em-upcoming .em-icon {
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  margin-top: .2em;
  fill: var(--em-accent);
}

.em-upcoming .em-upcoming-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.em-upcoming .em-upcoming-badges:empty {
  display: none;
}

.em-upcoming .em-badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid #d5dbe1;
  border-radius: 3px;
  background: #f5f7f9;
  color: #2b2f33;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.4;
}

.em-upcoming .em-badge-free {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #1b5e20;
}

.em-upcoming .em-badge-members {
  border-color: var(--em-accent);
  background: var(--em-accent);
  color: #fff;
}

.em-upcoming .em-badge-full,
.em-upcoming .em-badge-few {
  border-color: #f0ad4e;
  background: #fff4e0;
  color: #7a4b00;
}

.em-upcoming .em-upcoming-text {
  margin: 0 0 16px;
  color: var(--em-text);
  line-height: 1.6;
}

.em-upcoming .em-upcoming-more,
.em-upcoming .em-upcoming-all a {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 3px;
  background: var(--em-accent);
  color: #fff;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background .3s ease;
}

.em-upcoming .em-upcoming-more {
  align-self: flex-start;
  margin-top: auto;
}

.em-upcoming .em-upcoming-more:hover,
.em-upcoming .em-upcoming-more:focus,
.em-upcoming .em-upcoming-all a:hover,
.em-upcoming .em-upcoming-all a:focus {
  background: var(--em-hover);
  color: #fff;
  text-decoration: none;
}

.em-upcoming .em-upcoming-all {
  margin: 30px 0 0;
  text-align: center;
}

/* Keeps the message readable whatever the section background is. */
.em-upcoming-empty p {
  display: inline-block;
  margin: 0;
  padding: 14px 20px;
  border-radius: 4px;
  background: #fff;
  color: #333;
}

.em-upcoming-empty {
  text-align: center;
}

.em-upcoming .visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 959px) {
  .em-upcoming:not(.em-upcoming-cols-1) {
    --em-per-row: 2;
  }
}

@media (max-width: 639px) {
  /* Same specificity as the tablet rule above so this one wins on phones. */
  .em-upcoming,
  .em-upcoming:not(.em-upcoming-cols-1) {
    --em-per-row: 1;
  }
}
