/* ============================================================
   UCR — "In the Days Ahead"
   Near-term opportunities as expandable cards.

   Namespaced `days-ahead` throughout: /api/events, getEvents(), and
   images/site/events/ already belong to the Google Calendar integration,
   so nothing here is called "events".

   Built on the tokens in styles.css — no new colours or spacing values.
   ============================================================ */

/* ── Toolbar (Expand All / Collapse All) ───────────────────── */

.days-ahead__toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

/* ── List ──────────────────────────────────────────────────── */

.days-ahead__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: 0;
  margin: 0;
}

/* ── Card ──────────────────────────────────────────────────── */

.days-ahead__card {
  background: var(--color-white);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

.days-ahead__card:hover,
.days-ahead__card[open] {
  box-shadow: var(--shadow-md);
}

/* The whole collapsed row is the <summary>, so the entire card face is a
   single keyboard-operable control. Both marker resets are needed: the
   `list-style` one for Firefox, the pseudo-element for Safari. */
.days-ahead__card > summary {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-6);
  padding: var(--space-5);
  cursor: pointer;
  list-style: none;
}

.days-ahead__card > summary::-webkit-details-marker {
  display: none;
}

.days-ahead__card > summary:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: -3px;
}

/* ── Media ─────────────────────────────────────────────────── */

.days-ahead__media {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-cream-dark);
  /* The text column is the taller one once a summary runs to four lines.
     Centre the image against it rather than letting it hang from the top. */
  align-self: center;
}

.days-ahead__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* object-position is set inline per record from the editor's focal choice */
}

/* ── Collapsed body ────────────────────────────────────────── */

.days-ahead__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;              /* lets long words wrap instead of stretching the grid */
}

/* Title and category share one row: title left, pill hard right. */
.days-ahead__titlerow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.days-ahead__title {
  font-size: var(--text-xl);
  line-height: 1.3;
  margin: 0;
  min-width: 0;
}

.days-ahead__tags {
  flex-shrink: 0;          /* the title wraps, the pills never do */
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Featured: a gold rule on the card plus this label, so the signal is never
   carried by colour alone. */
.days-ahead__card--featured {
  border-left: 4px solid var(--color-gold);
}

.days-ahead__featured {
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold-dark);
}

.days-ahead__category {
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--color-indigo);
  color: #f2f2f2;
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}

.days-ahead__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.days-ahead__meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* A repeating event says how often before it says when. Given the weight and
   colour, this is the marker — there is deliberately no "RECURRING" pill,
   because .days-ahead__tags neither wraps nor shrinks and a third pill would
   squeeze the title to one word per line on a phone. */
.days-ahead__repeat {
  color: var(--color-indigo);
  font-weight: 600;
}

/* flex-basis forces the concrete date onto its own line under the pattern,
   rather than letting it wrap alongside like the location does. Two short
   lines read as "how often / when next"; one long line reads as neither. */
.days-ahead__next {
  flex-basis: 100%;
}

.days-ahead__summary {
  color: var(--color-text-muted);
  margin: 0;
  /* Clamping keeps collapsed cards a consistent height regardless of copy. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* A pasted URL is one long unbreakable word — let it wrap rather than
     stretch the card. */
  overflow-wrap: anywhere;
}

.days-ahead__description {
  overflow-wrap: anywhere;
}

.days-ahead__inline-link {
  color: var(--color-indigo);
  font-weight: 600;
  text-decoration: underline;
}

.days-ahead__inline-link:hover,
.days-ahead__inline-link:focus-visible {
  color: var(--color-gold-dark);
}

/* ── Expand cue ────────────────────────────────────────────── */

/* The cue and the reminder actions share one row, so both are reachable
   while the card is collapsed — nobody has to open a card to find them. */
.days-ahead__cuerow {
  margin-top: auto;
  padding-top: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.days-ahead__cue {
  font-weight: 600;
  color: var(--color-indigo);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.days-ahead__card > summary:hover .days-ahead__cue {
  color: var(--color-gold-dark);
}

.days-ahead__cue::after {
  content: '';
  width: 0.5em;
  height: 0.5em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--transition-fast);
}

.days-ahead__card[open] .days-ahead__cue::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

/* Swap the label without touching the DOM. */
.days-ahead__card[open] .days-ahead__cue-closed,
.days-ahead__card:not([open]) .days-ahead__cue-open {
  display: none;
}

/* ── Expanded detail ───────────────────────────────────────── */

/* Deliberately outside the summary grid so long descriptions and link rows
   get the full card width rather than the narrow right-hand column. */
.days-ahead__detail {
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
  background: var(--color-cream);
}

.days-ahead__detail > * + * {
  margin-top: var(--space-4);
}

.days-ahead__description p + p {
  margin-top: var(--space-4);
}

.days-ahead__detail-row {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.days-ahead__detail-row strong {
  color: var(--color-text);
}

.days-ahead__detail-heading {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-4);
}

/* ── Reminders & Add to Calendar ───────────────────────────── */
/* Mirrors the inline-link treatment main.js already uses on the calendar
   widgets, so the two event surfaces behave the same way. Lives inside the
   <summary> so it is available without opening the card. */

.days-ahead__reminders {
  display: flex;
  align-items: center;
}

/* Divider between the cue and the actions, hidden once the row wraps. */
.days-ahead__reminders::before {
  content: '|';
  color: var(--color-border);
  margin-right: var(--space-3);
}

.days-ahead__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.days-ahead__action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--color-indigo);
  text-decoration: underline;
  cursor: pointer;
}

.days-ahead__action:hover,
.days-ahead__action:focus-visible {
  color: var(--color-gold-dark);
}

.days-ahead__sep {
  color: var(--color-text-muted);
}

.days-ahead__remind-form {
  display: none;
  align-items: center;
  gap: var(--space-2);
}

.days-ahead__remind-form.is-open {
  display: flex;
}

.days-ahead__remind-form input {
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 170px;
}

.days-ahead__remind-msg {
  color: var(--color-text-muted);
}

/* ── Loading / empty / error states ────────────────────────── */

.days-ahead__state {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
}

.days-ahead__state p {
  margin-bottom: var(--space-6);
}

/* Reserve height so the section doesn't jump when data arrives. */
.days-ahead__list:empty,
.days-ahead__state {
  min-height: 180px;
}

/* ── Mobile ────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .days-ahead__card > summary {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding: var(--space-4);
  }

  .days-ahead__detail {
    padding: var(--space-5) var(--space-4) var(--space-4);
  }

  .days-ahead__toolbar {
    justify-content: center;
  }

  .days-ahead__actions .btn {
    width: 100%;
    justify-content: center;
  }
}
