/* Sprint 014: date-column containment, sticky month mastheads, drawer navigation, and title hover refinement. */

/*
 * Keep the month masthead attached immediately beneath the sticky site header.
 * Because each masthead is sticky inside its own .calendar-month section, the
 * following month naturally pushes the previous month away in either scroll direction.
 */
.calendar-month {
  position: relative;
}

.calendar-month .calendar-hero {
  position: sticky;
  top: var(--calendar-sticky-top, 104px);
  z-index: 55;
  min-height: 68px;
  margin: 0;
  padding: 12px 34px 10px;
  align-items: center;
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
}

.calendar-month .calendar-hero > div {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 22px;
}

.calendar-month .calendar-hero .eyebrow {
  flex: 0 0 auto;
  margin: 0;
  font-size: .62rem;
}

.calendar-month .calendar-month-title {
  margin: 0;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(2.5rem, 5vw, 4.7rem);
  font-weight: 900;
  line-height: .78;
  letter-spacing: -.045em;
  text-transform: uppercase;
  white-space: nowrap;
}

/*
 * Date marker is a self-contained poster stub. The weekday/month sits below
 * the numeral instead of sharing its horizontal space, so 10-31 cannot bleed
 * into the first event column.
 */
.day-band {
  grid-template-columns: 142px minmax(0, 1fr);
}

.day-band-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  padding: 1px 18px 0 4px;
}

.day-band .day-number {
  display: block;
  width: 100%;
  min-width: 0;
  font-size: clamp(4.7rem, 6.3vw, 6.45rem);
  line-height: .72;
  letter-spacing: -.075em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.day-band .day-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 0 0 0 4px;
  font-size: .62rem;
  line-height: 1;
}

.day-band .day-meta span + span::before {
  content: "·";
  margin-right: 6px;
}

/* Use a true text underline with breathing room instead of a background line. */
.event-title-row-compact h3 {
  line-height: 1.04;
}

.event-title-row-compact h3 a {
  background-image: none;
  text-decoration: none;
  text-decoration-thickness: 2px;
  text-underline-offset: .14em;
  text-decoration-skip-ink: auto;
  transition: color 120ms ease;
}

.event-title-row-compact h3 a:hover,
.event-title-row-compact h3 a:focus-visible {
  background-size: auto;
  text-decoration-line: underline;
}

/* Sticky drawer toolbar: previous and next live on opposing sides, close stays centered. */
.event-drawer-toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(245, 240, 223, .97);
  border-bottom: 2px solid var(--ink);
}

.event-drawer-nav {
  appearance: none;
  width: max-content;
  max-width: 100%;
  border: 0;
  border-bottom: 2px solid currentColor;
  padding: 5px 0 3px;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .05em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
}

.event-drawer-nav-next {
  justify-self: end;
  text-align: right;
}

.event-drawer-nav:disabled {
  visibility: hidden;
  pointer-events: none;
}

.event-drawer-toolbar .event-drawer-close {
  position: static;
  float: none;
  top: auto;
  margin: 0;
  justify-self: center;
  background: var(--paper);
}

.event-drawer-content {
  padding-top: 34px;
}

/* Keep loading feedback compact now that hover/focus prefetch normally wins the race. */
.event-drawer-loading,
.event-drawer-error {
  padding-top: 20px;
}

@media (max-width: 1020px) {
  .calendar-month .calendar-hero {
    top: var(--calendar-sticky-top, 132px);
  }
}

@media (max-width: 720px) {
  .calendar-month .calendar-hero {
    min-height: 54px;
    padding: 9px 18px 8px;
    align-items: center;
  }

  .calendar-month .calendar-hero > div {
    display: block;
  }

  .calendar-month .calendar-hero .eyebrow {
    display: none;
  }

  .calendar-month .calendar-month-title {
    font-size: clamp(2rem, 10.5vw, 3.25rem);
  }

  .day-band {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .day-band-header {
    padding: 1px 8px 0 0;
  }

  .day-band .day-number {
    font-size: 3.7rem;
    letter-spacing: -.09em;
  }

  .day-band .day-meta {
    display: grid;
    gap: 1px;
    padding-left: 2px;
    font-size: .54rem;
  }

  .day-band .day-meta span + span::before {
    content: none;
    margin: 0;
  }

  .event-drawer-toolbar {
    min-height: 58px;
    padding: 8px 12px;
  }

  .event-drawer-nav {
    font-size: .7rem;
  }

  .event-drawer-content {
    padding-top: 26px;
  }
}

@media (max-width: 430px) {
  .day-band {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .day-band .day-number {
    font-size: 3.28rem;
  }

  .event-drawer-toolbar {
    gap: 8px;
  }

  .event-drawer-nav {
    font-size: .64rem;
    letter-spacing: .035em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .event-title-row-compact h3 a { transition: none; }
}
