/* Events — Awards and recognition canvas, "Events page · EDS light" and "Event card rules" (29 Oct).
   Upcoming: cards that size to their content; date, title, details and link line up per row through
   CSS subgrid (no height script). Past: a compact list grouped by month.
   No root background: the section supplies the band (Rob, 16 Oct). */

.eds-events {
  --eds-events-cols: 3;
  --eds-events-rows: 4; /* date, title, details, link */
  padding-block: var(--eds-section-space);
}

.eds-events--images { --eds-events-rows: 5; }

.eds-events--cols-1 { --eds-events-cols: 1; }
.eds-events--cols-2 { --eds-events-cols: 2; }
.eds-events--cols-3 { --eds-events-cols: 3; }
.eds-events--cols-4 { --eds-events-cols: 4; }
.eds-events--cols-5 { --eds-events-cols: 5; }
.eds-events--cols-6 { --eds-events-cols: 6; }

.eds-events__inner {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-64);
}

.eds-events__section {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-24);
}

/* ---- Section header: heading, count, hairline ------------------------------ */

.eds-events__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--eds-space-12);
  padding-bottom: var(--eds-space-12);
  border-bottom: var(--eds-stroke-hairline) solid var(--eds-border-subtle);
  color: var(--eds-text-primary);
  font-family: var(--eds-font-display);
  font-size: var(--eds-display-32);
  font-weight: var(--eds-weight-regular);
  line-height: 1.25;
}

.eds-events__count {
  color: var(--eds-text-muted);
  font-family: var(--eds-font-body);
  font-size: var(--eds-text-sm);
  font-variant-numeric: tabular-nums;
  line-height: 20px;
}

.eds-events__empty {
  color: var(--eds-text-muted);
  font-size: var(--eds-text-md);
  line-height: 28px;
}

.eds-events [hidden] {
  display: none;
}

/* ---- Upcoming: card grid --------------------------------------------------- */

.eds-events__grid {
  display: grid;
  grid-template-columns: repeat(var(--eds-events-cols), minmax(0, 1fr));
  gap: var(--eds-space-24);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each card spans the same rows as its neighbours, so a row is as tall as its tallest card
   and titles, details and links line up across it. */
.eds-events__card {
  position: relative;
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span var(--eds-events-rows);
  row-gap: var(--eds-space-12);
  min-width: 0;
  padding: var(--eds-space-24);
  border: var(--eds-stroke-hairline) solid var(--eds-border-subtle);
  border-radius: var(--eds-radius-md);
  background-color: var(--eds-surface-card);
  color: var(--eds-text-primary);
  transition: border-color var(--eds-duration) var(--eds-ease);
}

/* Browsers without subgrid: each card is a column with its link pinned to the bottom. */
@supports not (grid-template-rows: subgrid) {
  .eds-events__card {
    display: flex;
    flex-direction: column;
  }

  .eds-events__cta {
    margin-top: auto;
  }
}

.eds-events__card--linked:hover {
  border-color: var(--eds-border-strong);
}

.eds-events__media {
  height: 180px;
  margin: calc(-1 * var(--eds-space-24)) calc(-1 * var(--eds-space-24)) 0;
  overflow: hidden;
  border-radius: var(--eds-radius-md) var(--eds-radius-md) 0 0;
  background-color: var(--eds-surface-raised); /* holds the box while the image loads */
}

.eds-events__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eds-events__date time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--eds-space-8) var(--eds-space-12);
  color: var(--eds-accent-primary);
}

.eds-events__day {
  font-family: var(--eds-font-display);
  font-size: var(--eds-display-40);
  font-variant-numeric: tabular-nums;
  line-height: 44px;
}

.eds-events__month {
  font-size: var(--eds-text-sm);
  font-weight: var(--eds-weight-bold);
  line-height: 20px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.eds-events__title {
  color: var(--eds-text-primary);
  font-family: var(--eds-font-display);
  font-size: var(--eds-display-24);
  font-weight: var(--eds-weight-regular);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* The title link is the card's one link; its ::after covers the whole card. */
.eds-events__link,
.eds-events__link:visited,
.eds-events__link:hover {
  color: inherit;
  text-decoration: none;
}

.eds-events__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--eds-radius-md);
}

.eds-events__meta {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-12);
}

.eds-events__location {
  display: flex;
  align-items: center;
  gap: var(--eds-space-8);
  color: var(--eds-text-secondary);
  font-size: var(--eds-text-sm);
  line-height: 20px;
}

.eds-events .eds-events__pin {
  flex: none;
  width: 16px;
  height: 16px;
}

/* Speakers and sessions: collapsed, and above the stretched link so it opens instead of following it. */
.eds-events__details {
  position: relative;
  z-index: 1;
  color: var(--eds-text-secondary);
  font-size: var(--eds-text-sm);
  line-height: 22px;
}

.eds-events__summary {
  display: list-item;
  min-height: 32px;
  color: var(--eds-text-link);
  font-weight: var(--eds-weight-bold);
  cursor: pointer;
}

.eds-events__summary:hover {
  color: var(--eds-text-link-hover);
}

.eds-events__summary:focus-visible {
  outline: var(--eds-stroke-thick) solid var(--eds-border-focus);
  outline-offset: var(--eds-stroke-thick);
  border-radius: var(--eds-radius-sm);
}

.eds-events__text {
  padding-top: var(--eds-space-4);
}

.eds-events__text > * + * {
  margin-top: var(--eds-space-8);
}

.eds-events__text ul,
.eds-events__text ol {
  padding-left: 1.25em;
}

.eds-events__text a {
  color: var(--eds-text-link);
}

.eds-events__cta {
  display: inline-flex;
  align-self: end;
  align-items: center;
  gap: var(--eds-space-8);
  color: var(--eds-text-link);
  font-size: var(--eds-text-sm);
  font-weight: var(--eds-weight-bold);
  line-height: 20px;
}

.eds-events__card--linked:hover .eds-events__cta {
  color: var(--eds-text-link-hover);
}

/* The shared arrow, turned to point up and out: the link leaves the site. */
.eds-events .eds-events__out {
  transform: rotate(-45deg);
}

/* Focus ring goes round the whole card, which is the hit area. */
.eds-events__link:focus-visible {
  outline: var(--eds-stroke-thick) solid var(--eds-border-focus);
  outline-offset: var(--eds-stroke-thick);
}

@supports selector(:has(*)) {
  .eds-events__link:focus-visible {
    outline: none;
  }

  .eds-events__card--linked:has(.eds-events__link:focus-visible) {
    outline: var(--eds-stroke-thick) solid var(--eds-border-focus);
    outline-offset: var(--eds-stroke-thick);
  }
}

/* ---- Past: compact list by month ------------------------------------------- */

.eds-events__months {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-32);
}

.eds-events__month-label {
  padding-bottom: var(--eds-space-8);
  border-bottom: var(--eds-stroke-hairline) solid var(--eds-border-subtle);
  color: var(--eds-text-secondary);
  font-family: var(--eds-font-body);
  font-size: var(--eds-text-sm);
  font-weight: var(--eds-weight-bold);
  line-height: 20px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.eds-events__month-label:focus {
  outline: none;
}

.eds-events__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.eds-events__row {
  display: grid;
  grid-template-columns: 88px minmax(0, 2fr) minmax(0, 1fr) minmax(140px, auto);
  align-items: baseline; /* date, location and link stay level with the title when Speakers and sessions opens */
  column-gap: var(--eds-space-24);
  min-height: 56px;
  padding: var(--eds-space-8) var(--eds-space-12);
  border-bottom: var(--eds-stroke-hairline) solid var(--eds-border-subtle);
  transition: background-color var(--eds-duration-fast) var(--eds-ease);
}

.eds-events__row:hover {
  background-color: var(--eds-surface-card);
}

.eds-events__row-date {
  color: var(--eds-text-secondary);
  font-size: var(--eds-text-sm);
  font-weight: var(--eds-weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 20px;
}

.eds-events__row-title {
  color: var(--eds-text-primary);
  font-size: var(--eds-text-md);
  font-weight: var(--eds-weight-semibold);
  line-height: 24px;
  overflow-wrap: anywhere;
}

.eds-events__row-main {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-4);
  min-width: 0;
}

/* In the list the toggle sits under the title; rows have no stretched link, so no z-index needed. */
.eds-events__details--row {
  position: static;
}

.eds-events__details--row .eds-events__summary {
  min-height: 0;
  padding-block: var(--eds-space-4);
  font-size: var(--eds-text-sm);
}

.eds-events__row-where {
  color: var(--eds-text-secondary);
  font-size: var(--eds-text-sm);
  line-height: 20px;
}

.eds-events__row-action {
  justify-self: end;
}

.eds-events__more-wrap {
  display: flex;
  justify-content: center;
  padding-top: var(--eds-space-8);
}

/* ---- Laptop: 4 / 5 / 6 per row fall to 3 below 1280 (decision 30 Sep) ---- */

@media (max-width: 1279px) {
  .eds-events--cols-4,
  .eds-events--cols-5,
  .eds-events--cols-6 { --eds-events-cols: 3; }
}

/* ---- Tablet: 3+ per row fall to 2; list rows stack date beside the text ---- */

@media (max-width: 1023px) {
  .eds-events--cols-3,
  .eds-events--cols-4,
  .eds-events--cols-5,
  .eds-events--cols-6 { --eds-events-cols: 2; }
}

@media (max-width: 767px) {
  .eds-events__inner {
    gap: var(--eds-space-48);
  }

  .eds-events__heading {
    font-size: var(--eds-display-24);
  }

  .eds-events__row {
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-areas:
      "date title"
      "date where"
      "date action";
    align-items: start;
    row-gap: var(--eds-space-4);
    padding-block: var(--eds-space-12);
  }

  .eds-events__row-date { grid-area: date; padding-top: 2px; }
  .eds-events__row-main { grid-area: title; }
  .eds-events__row-title { font-size: var(--eds-text-sm); line-height: 22px; }
  .eds-events__row-where { grid-area: where; }
  .eds-events__row-action { grid-area: action; justify-self: start; }
}

/* ---- Phone: one column ----------------------------------------------------- */

@media (max-width: 479px) {
  .eds-events { --eds-events-cols: 1; } /* later in the file, so it beats every --cols-N */
}
