/* Cycles Calendar Tab — month grid with stacked-lane cycle bars.
 *
 * Each week is its own CSS grid: day cells occupy grid-row 1 and cycle
 * bars stack into lanes (grid-row 2..N). The view supplies a
 * --lane-count custom property per week so the row template grows to
 * fit the bars that span that week.
 */

/* Header — prev / title / next, with optional Today on the right. */
.cycles-calendar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background-color: var(--light-gray);
  border-radius: 0.25rem;
  margin-bottom: var(--spacing-unit);
}

.cycles-calendar-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dark-gray);
}

.cycles-calendar-nav-prev,
.cycles-calendar-nav-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--surface-white);
  color: var(--dark-gray);
  border: 1px solid var(--border-emphasis);
  border-radius: 0.25rem;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cycles-calendar-nav-prev:hover,
.cycles-calendar-nav-next:hover {
  background-color: var(--dark-gray);
  color: white;
}

.cycles-calendar-nav-today {
  padding: 0.25rem 0.75rem;
  background-color: var(--surface-white);
  color: var(--dark-gray);
  border: 1px solid var(--border-emphasis);
  border-radius: 0.25rem;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
}

.cycles-calendar-nav-today:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Outer grid wrapper. */
.cycles-calendar-grid {
  background-color: var(--surface-white);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  overflow: hidden;
}

/* Weekday header row — small bold labels above the grid. */
.cycles-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.cycles-calendar-weekday {
  padding: 0.375rem 0.25rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Week row — 7 day columns and N+1 rows.
 *
 * Row 1 is the day-cell strip; rows 2..N+1 are cycle-bar lanes.
 * The view sets --lane-count on each week so we know how many lane
 * rows to generate.
 */
.cycles-calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 2.5rem repeat(var(--lane-count, 0), 1.5rem);
  gap: 0.15rem;
  padding: 0.15rem;
  border-bottom: 1px solid var(--border);
}

.cycles-calendar-week:last-child {
  border-bottom: none;
}

/* Day cell — minimal frame, day number in top-left. */
.cycles-calendar-day {
  position: relative;
  padding: 0.25rem;
  background-color: var(--surface-white);
  border: 1px solid var(--border);
  border-radius: 0.125rem;
  min-height: 2.25rem;
  font-size: 0.8125rem;
  color: var(--dark-gray);
}

.cycles-calendar-day-out {
  background-color: var(--surface-muted);
  color: var(--text-muted);
}

.cycles-calendar-day-today {
  border: 2px solid var(--primary-color);
  padding: calc(0.25rem - 1px);
}

.cycles-calendar-day-number {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

/* Cycle bar — rounded pill spanning one or more day columns.
 *
 * Inline grid-column / grid-row come from the view. Colors come from
 * the cycle-row-* temporal status classes shared with the cycles
 * table, so the calendar and the index table stay visually aligned.
 */
.cycles-calendar-bar {
  display: flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dark-gray);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.cycles-calendar-bar:hover {
  text-decoration: none;
}

/* Temporal status colors for the bar — soft default washes.
 *
 * cycles.css applies cycle-row-future / cycle-row-past as table-row
 * background washes. Bars need solid pill colors, so we set explicit
 * backgrounds here scoped to .cycles-calendar-bar to avoid disturbing
 * the existing table styling.
 */
.cycles-calendar-bar.cycle-row-current {
  background-color: color-mix(in oklch, var(--primary-color) 25%, white);
}

.cycles-calendar-bar.cycle-row-future {
  background-color: color-mix(in oklch, var(--accent-cycle) 25%, white);
}

.cycles-calendar-bar.cycle-row-past {
  background-color: color-mix(in oklch, var(--medium-gray) 30%, white);
}

/* Highlight every bar that shares a cycle_id with the hovered bar.
 *
 * The cycle-bar-highlight Stimulus controller toggles this class on
 * mouseover so a multi-week cycle's segments visually connect.
 */
.cycles-calendar-bar.cycles-calendar-bar-highlighted {
  color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.cycles-calendar-bar.cycle-row-current.cycles-calendar-bar-highlighted {
  background-color: var(--primary-color);
}

.cycles-calendar-bar.cycle-row-future.cycles-calendar-bar-highlighted {
  background-color: var(--accent-cycle);
}

.cycles-calendar-bar.cycle-row-past.cycles-calendar-bar-highlighted {
  background-color: var(--medium-gray);
}
