/*
 * The Matches tab's Calendar view (MatchCalendar.js) — month navigator,
 * weekday header, the 7-column grid, then the Home/Away legend.
 */

.match-calendar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-inline: var(--space-4);
  opacity: 1;
  transition: opacity var(--duration) var(--easing);
}

/* `[hidden]` is a UA rule; the `display: flex` above it wins outright without
   this, the same failure mode every other panel in this app documents. */
.match-calendar[hidden] {
  display: none;
}

.match-calendar[data-open="false"] {
  opacity: 0;
}

/* --- Month navigator ------------------------------------------------------- */

.match-calendar__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.match-calendar__nav-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
}

/* The single "chevron" glyph (arrow-down) rotated to point sideways — the
   same trick the competition filter pill's own chevron uses at rest. */
.match-calendar__nav-icon--prev {
  transform: rotate(90deg);
}

.match-calendar__nav-icon--next {
  transform: rotate(-90deg);
}

.match-calendar__month {
  position: relative;
}

.match-calendar__month-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  color: var(--text);
}

.match-calendar__month-label {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.match-calendar__month-button .icon {
  color: var(--text-muted);
  transition: transform var(--duration) var(--easing);
}

.match-calendar__month-button[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

/* --- Month/year picker -------------------------------------------------- */

.match-calendar__picker {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 232px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-floating);
}

.match-calendar__picker[hidden] {
  display: none;
}

.match-calendar__picker-year-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.match-calendar__picker-year-step {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--text-secondary);
}

.match-calendar__picker-year {
  min-width: 40px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.match-calendar__picker-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-1);
}

.match-calendar__picker-month {
  padding: var(--space-2) 0;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.match-calendar__picker-month:active {
  background: var(--surface-sunken);
}

/* --- Weekday header ------------------------------------------------------- */

.match-calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.match-calendar__weekday {
  text-align: center;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* --- Grid ------------------------------------------------------------------ */

.match-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.match-calendar__cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 60px;
  padding: var(--space-1);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* A leading/trailing cell outside the current month — blank and inert, not
   merely undecorated, so it never reads as a zero-fixture day inside it. */
.match-calendar__cell[data-blank="true"] {
  background: none;
}

.match-calendar__day {
  align-self: flex-start;
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* The current date's own marker — independent of a cell's home/away
   treatment and of whether the day has a fixture at all, which is why it is
   a border layered on top rather than a variant of either. Thicker than the
   grid line every cell already carries, so "today" still reads as its own
   signal rather than a slightly darker gridline. */
.match-calendar__cell[data-today="true"] {
  border-width: 1.5px;
  border-color: var(--accent);
}

.match-calendar__cell--fixture {
  justify-content: space-between;
  text-align: center;
}

.match-calendar__competition {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
}

.match-calendar__opponent {
  margin: auto;
}

.match-calendar__value {
  font-size: 9px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.match-calendar__value .pill {
  padding: 1px var(--space-1);
  font-size: 9px;
}

/*
 * Home / away — the two cell treatments the legend below explains. Driven by
 * `side`, a real field on the fixture (see the note in state/selectors.js),
 * not by which crest the cell happens to show.
 */
.match-calendar__cell--fixture[data-side="home"] {
  background: var(--side-home-soft);
}

.match-calendar__cell--fixture[data-side="away"] {
  background: var(--side-away-soft);
}

/* --- Legend ----------------------------------------------------------------- */

.match-calendar__legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  align-self: center;
}

.match-calendar__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.match-calendar__legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-sm);
}

.match-calendar__legend-swatch[data-side="home"] {
  background: var(--side-home);
}

.match-calendar__legend-swatch[data-side="away"] {
  background: var(--side-away);
}
