/* Calendar: month grid (#/month) and week columns (#/week). Phone layout is at the bottom. */

/* ---------- toolbar + legend ---------- */
.cal-title { margin-left: 6px; }
.cal-today { padding: 0 18px; }
.cal-toggle { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.cal-seg { position: relative; height: 36px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 500; cursor: pointer; }
.cal-seg:hover { background: var(--off); }
.cal-seg[aria-pressed="true"] { background: var(--soft); color: var(--accent-ink); font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- month grid ---------- */
.cal-month, .cal-wk { overflow-x: auto; }
.cal-grid, .cal-cols { min-width: 760px; }
.cal-weekdays, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays { border-bottom: 1px solid var(--line); }
.cal-weekdays span { padding: 10px 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cal-cell { position: relative; min-width: 0; min-height: 138px; padding: 8px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.cal-cell:last-child { border-right: 0; }
.cal-week:last-child .cal-cell { border-bottom: 0; }
.cal-cell.is-off { background: var(--off); }
.cal-cell.is-today { background: var(--soft); }

/* The day link covers its whole cell, so anywhere that is not a chip opens the day. */
.cal-day { align-self: flex-start; border-radius: 13px; color: inherit; }
.cal-day:hover { text-decoration: none; }
.cal-day::after { content: ""; position: absolute; inset: 0; }
.cal-day:hover::after { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-day:focus-visible { outline: none; }
.cal-day:focus-visible::after { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -3px; }
.cal-num { min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
.is-off .cal-num { color: var(--muted); }
.is-today .cal-num { background: var(--accent); color: var(--on-accent); }

.cal-chip { position: relative; z-index: 1; display: block; padding: 3px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip:hover { text-decoration: none; filter: brightness(0.96); }
.cal-more { padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--accent-ink); }

/* Dots replace chip titles on a phone. */
.cal-dots { display: none; }
.cal-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.cal-dot-wait { background: var(--wait-bar); }
.cal-dot-change { background: var(--change-bar); }
.cal-dot-prog { background: var(--prog-bar); }
.cal-dot-done { background: var(--done-bar); }
.cal-dot-rej { background: var(--rej-bar); }
.cal-dots-more { font-size: 10px; font-weight: 600; line-height: 1; color: var(--muted); }

/* ---------- week columns ---------- */
.cal-cols { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 520px; }
.cal-col { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.cal-col:last-child { border-right: 0; }
.cal-col.is-today { background: var(--soft); }
.cal-colhead { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: inherit; }
.cal-colhead:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-colhead:focus-visible { outline-offset: -3px; }
.cal-wd { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cal-colhead .cal-num { min-width: 30px; height: 30px; border-radius: 15px; margin-left: -7px; font-size: 15px; }
.cal-colcount { display: none; }
.cal-col-items { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cal-chip-lg { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; white-space: normal; }
.cal-chip-title { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.cal-chip-by { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  /* Title on its own line, controls under it. */
  .cal-bar { gap: 8px; }
  .cal-title { order: -1; flex: 1 0 100%; margin-left: 0; }
  .cal-gap { display: none; }
  .cal-toggle { margin-left: auto; }
  .cal-seg { padding: 0 14px; }
  .cal-seg::before { content: ""; position: absolute; inset: -4px -2px; } /* 44px tap height */

  /* A dot for each colour, so the legend explains the dots in the grid. */
  .cal-legend { gap: 6px; }
  .cal-legend .pill { gap: 6px; }
  .cal-legend .pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
  .cal-legend .tone-wait::before { background: var(--wait-bar); }
  .cal-legend .tone-change::before { background: var(--change-bar); }
  .cal-legend .tone-prog::before { background: var(--prog-bar); }
  .cal-legend .tone-done::before { background: var(--done-bar); }
  .cal-legend .tone-rej::before { background: var(--rej-bar); }

  /* Month: the grid fits the screen; each cell is one tap target with dots. */
  .cal-month, .cal-wk { overflow: hidden; }
  .cal-grid, .cal-cols { min-width: 0; }
  .cal-weekdays span { padding: 8px 0; text-align: center; font-size: 11px; letter-spacing: 0.02em; }
  .cal-cell { min-height: 64px; padding: 6px 2px 8px; align-items: center; gap: 6px; }
  .cal-day { align-self: center; }
  .cal-mon, .cal-cell .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; align-items: center; justify-content: center; gap: 3px; }

  /* Week: seven days stacked as a list. */
  .cal-cols { display: block; min-height: 0; }
  .cal-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .cal-col:last-child { border-bottom: 0; }
  .cal-colhead { flex-direction: row; align-items: center; gap: 8px; min-height: 48px; padding: 6px 14px; border-bottom: 0; }
  .cal-wd { width: 34px; }
  .cal-colhead .cal-num { margin-left: 0; }
  .cal-colcount { display: block; margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
  .cal-col-items { padding: 0 12px 12px; }
  .cal-col-items:empty { display: none; }
  .cal-chip-lg { min-height: 44px; justify-content: center; padding: 6px 10px; }
}
