/* =========================================================================
   calendar.css — month and week view, drag & drop, day markers.
   ========================================================================= */

.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); margin-bottom: var(--sp-3);
}
.cal-toolbar__label { font-size: 1.06rem; font-weight: 750; }

/* ---------- Month grid ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.cal-grid__dow {
  text-align: center;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 4px;
}
.cal-cell {
  position: relative;
  min-height: 60px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
/* Days of the neighbouring months: quieter, but the day number stays readable (opacity 0.4 left it at
   1.8:1) – the cell fades, the number keeps the faint text colour. */
.cal-cell--out > :not(.cal-cell__head), .cal-cell--out .cal-cell__head > :not(.cal-cell__num) { opacity: 0.45; }
.cal-cell--out .cal-cell__num { color: var(--text-3); font-weight: 500; }
.cal-cell--today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell--race { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.cal-cell__num { font-size: 0.74rem; font-weight: 700; color: var(--text-2); }
/* Narrow cells (iPhone): weather below the date instead of beyond the cell edge. */
.cal-cell__head { flex-wrap: wrap; row-gap: 2px; }
.cal-weather { font-size: 0.56rem; font-weight: 600; color: var(--text-2); white-space: nowrap; line-height: 1; }
.cal-day__weather { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }

/* Cycle */
.cal-cycle-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface); }
.cycle-tag { font-size: 0.62rem; font-weight: 700; padding: 2px 7px; border-radius: var(--r-pill); white-space: nowrap; }
.cycle-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cycle-strip__day {
  min-height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cycle-strip__day.is-today { box-shadow: inset 0 0 0 2px var(--text); }
/* Forecast: dashed inner border instead of transparency (the number stays legible). */
.cycle-strip__day.is-predicted { outline: 1.5px dashed color-mix(in srgb, currentColor 75%, transparent); outline-offset: -4px; }
.cycle-strip__head { margin-bottom: 4px; }
.cycle-strip__head span { text-align: center; font-size: 0.7rem; font-weight: 700; color: var(--text-2); }
.cal-cell--today .cal-cell__num { color: var(--accent-text); }
.cal-cell__dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; }
.cal-cell.drag-over { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Week view (list per day) ---------- */
.cal-week { display: flex; flex-direction: column; gap: var(--sp-3); }
.cal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cal-day.drag-over { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day__head {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap; row-gap: 4px;   /* narrow screens: count and "+" on the second line */
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
}
.cal-day__head.is-today { background: var(--accent-soft); }
.cal-day__dow { font-weight: 750; }
.cal-day__date { color: var(--text-2); font-size: 0.84rem; }
.cal-day__count { margin-left: auto; color: var(--text-3); font-size: 0.78rem; white-space: nowrap; }
.cal-day__units { padding: var(--sp-2) var(--sp-4) var(--sp-3); display: flex; flex-direction: column; }
.cal-unit {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.cal-unit:last-child { border-bottom: none; }
.cal-unit__body { flex: 1; min-width: 0; }
.cal-unit__title { font-weight: 650; font-size: 0.9rem; }
.cal-unit__meta { font-size: 0.76rem; color: var(--text-2); }
.cal-unit--done .cal-unit__title { color: var(--text-2); }
.cal-unit--done .cal-unit__title::before { content: "✓ "; color: var(--good-text); font-weight: 800; }
.cal-unit--missed .cal-unit__title { color: var(--bad-text); }
.cal-unit--overdue { box-shadow: inset 3px 0 0 #f5a623; padding-left: 6px; }
.cal-unit--overdue .cal-unit__title { color: color-mix(in srgb, #f5a623 85%, var(--text)); }
/* Handle ≥ 44 px (previously 26 px) – also as a button for keyboard and tapping (UI-23) */
.cal-unit__handle {
  color: var(--text-3); cursor: grab; touch-action: none;
  display: grid; place-items: center; flex: 0 0 auto;
  width: 36px; min-height: 44px; margin: -6px 0 -6px -8px;
  background: none; border: 0; border-radius: var(--r-xs);
}
.cal-unit__handle svg { width: 18px; height: 18px; }
.cal-day__rest { padding: var(--sp-3) var(--sp-4); color: var(--text-3); font-size: 0.84rem; }

/* Appointments (dated checklist items) in the calendar */
.cal-dot--task { border-radius: 2px; }   /* square -> clearly distinguished from round training dots */
/* Free workouts (without a plan): dot with a light ring */
.cal-dot--free { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px currentColor; color: var(--text-3); }
/* "+ Log training" in the day header */
.cal-day__add { width: 32px; height: 32px; flex: 0 0 auto; margin-left: -4px; }
.cal-day__add svg { width: 16px; height: 16px; }
.cal-unit--task { padding-left: 2px; }
.cal-task__icon { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 26px; }
.cal-task__icon svg { width: 18px; height: 18px; }

/* floating drag image during touch reschedule */
.drag-ghost {
  position: fixed; z-index: 80; pointer-events: none;
  padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-contrast);
  font-size: 0.8rem; font-weight: 650;
  box-shadow: var(--shadow-3);
  opacity: 0.95;
}
