/* Flint Hills DSA event cards.
 *
 * Served from GitHub Pages and pulled into WordPress by a Custom HTML block.
 * Colors come from the Neve FSE theme's own CSS custom properties wherever
 * possible, with hard-coded fallbacks for anywhere the theme is not present,
 * so the cards inherit the site's palette instead of fighting it.
 */

.fhdsa-events {
  --fhdsa-fg: var(--wp--preset--color--ti-fg, #1a1a1a);
  --fhdsa-bg: var(--wp--preset--color--ti-bg, #ffffff);
  --fhdsa-bg-alt: var(--wp--preset--color--ti-bg-alt, #f4f4f4);
  --fhdsa-accent: var(--wp--preset--color--ti-accent, #ec1f27);
  --fhdsa-muted: color-mix(in srgb, var(--fhdsa-fg) 65%, transparent);
  --fhdsa-border: color-mix(in srgb, var(--fhdsa-fg) 15%, transparent);
  --fhdsa-radius: 8px;

  color: var(--fhdsa-fg);
  container-type: inline-size;
}

/* --- filters --- */

.fhdsa-events__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.fhdsa-events__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--fhdsa-border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  cursor: pointer;
}

.fhdsa-events__chip:hover {
  border-color: currentColor;
}

.fhdsa-events__chip:focus-visible {
  outline: 2px solid var(--fhdsa-accent);
  outline-offset: 2px;
}

.fhdsa-events__chip[aria-pressed="true"] {
  background: var(--fhdsa-fg);
  color: var(--fhdsa-bg);
  border-color: var(--fhdsa-fg);
}

.fhdsa-events__chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color, currentColor);
  flex: none;
}

/* --- month sections --- */

.fhdsa-events__month {
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--fhdsa-border);
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fhdsa-events__section + .fhdsa-events__section {
  margin-top: 40px;
}

/* --- card grid --- */

/* Three columns everywhere, so `data-limit="6"` on the home page lands as two
   clean rows of three and the calendar page matches it month by month. Cards
   carry only a badge, date and title, so they stay legible when a theme's
   content column is narrow. Collapses only when genuinely cramped -- see the
   container queries at the bottom of this file. */
.fhdsa-events__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fhdsa-events__item {
  display: flex;
}

/* The card is a <button> so it is keyboard reachable and announces itself as
   opening a dialog. These rules undo the browser's button styling. */
.fhdsa-events__card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 20px;
  background: var(--fhdsa-bg-alt);
  border: 0;
  border-radius: var(--fhdsa-radius);
  border-left: 6px solid var(--card-color, var(--fhdsa-accent));
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fhdsa-events__card:focus-visible {
  outline: 2px solid var(--fhdsa-accent);
  outline-offset: 2px;
}

.fhdsa-events__badge {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--card-color, var(--fhdsa-accent));
  /* Set per-event by the script from the committee colour's luminance, so a
     light badge gets dark text instead of failing contrast in white. */
  color: var(--badge-text, #fff);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fhdsa-events__date {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--fhdsa-muted);
}

.fhdsa-events__title {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.3;
}

/* --- modal --- */

.fhdsa-events__dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--fhdsa-radius, 8px);
  border-top: 8px solid var(--card-color, #ec1f27);
  background: var(--wp--preset--color--ti-bg, #fff);
  color: var(--wp--preset--color--ti-fg, #1a1a1a);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}

.fhdsa-events__dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

.fhdsa-events__dialog-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 28px;
}

.fhdsa-events__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.fhdsa-events__close:hover {
  background: color-mix(in srgb, currentColor 12%, transparent);
}

.fhdsa-events__close:focus-visible {
  outline: 2px solid var(--card-color, currentColor);
  outline-offset: 2px;
}

.fhdsa-events__dialog-title {
  margin: 0;
  padding-right: 32px;
  font-size: 1.5rem;
  line-height: 1.25;
}

.fhdsa-events__dialog-date {
  margin: 0;
  font-weight: 700;
}

.fhdsa-events__dialog-location,
.fhdsa-events__dialog-text {
  margin: 0;
  line-height: 1.55;
}

.fhdsa-events__dialog-location {
  color: color-mix(in srgb, currentColor 65%, transparent);
}

.fhdsa-events__rsvp {
  margin-top: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--card-color, #ec1f27);
  color: var(--badge-text, #fff);
  font-weight: 700;
  text-decoration: none;
}

.fhdsa-events__rsvp:hover,
.fhdsa-events__rsvp:focus-visible {
  text-decoration: underline;
  color: var(--badge-text, #fff);
}

/* --- states --- */

.fhdsa-events__status {
  margin: 0;
  padding: 24px 0;
  color: var(--fhdsa-muted);
}


/* Three columns hold until the container is genuinely too narrow for them.
   Measured on the container, not the viewport, so a theme with a narrow content
   column collapses correctly even on a wide screen. */
@container (max-width: 560px) {
  .fhdsa-events__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

@container (max-width: 380px) {
  .fhdsa-events__grid {
    grid-template-columns: 1fr;
  }
}

/* Containment needs a fallback: if a browser lacks container queries the rules
   above never fire, so mirror them on the viewport. */
@supports not (container-type: inline-size) {
  @media (max-width: 600px) {
    .fhdsa-events__grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
  @media (max-width: 420px) {
    .fhdsa-events__grid {
      grid-template-columns: 1fr;
    }
  }
}

@media (prefers-reduced-motion: no-preference) {
  .fhdsa-events__card {
    transition: transform 120ms ease;
  }
  .fhdsa-events__card:hover {
    transform: translateY(-2px);
  }
}
