/* ==========================================================================
   Desktop calendar (#/calendar). Loaded always, used only at ≥ 900px.
   ========================================================================== */

.cal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--gap);
  align-items: start;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 10px;
}
.cal-title { margin: 0; font-size: 20px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-weekday {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 2px 0 4px;
}

.cal-day {
  min-height: 150px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: box-shadow .12s ease, background .12s ease;
}
.cal-day-num { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.cal-day--past { background: var(--bg-tint); }
.cal-day--past .chip { opacity: .7; }
.cal-day--today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day--today .cal-day-num { color: var(--accent); }
/* Beyond the horizon: visible for context, refuses every drop. */
.cal-day--locked {
  background: repeating-linear-gradient(45deg, transparent 0 8px, var(--bg-tint) 8px 16px);
  color: var(--muted);
}

/* Drop feedback — set by dnd.js while a valid payload hovers. */
.cal-day.drop-ok { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-soft); }
.cal-day.drop-no { box-shadow: inset 0 0 0 2px var(--danger); }

.chip {
  font-size: 12.5px;
  line-height: 1.25;
  padding: 3px 7px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  user-select: none;
}
.chip:active { cursor: grabbing; }
.chip--cook { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.chip--fresh { background: var(--accent-soft); color: var(--accent); }
.chip--freezer { background: var(--frost-soft); color: var(--frost); }
.chip--log { background: var(--ok-soft); color: var(--ok); cursor: pointer; }
/* Advisory only — a fresh lunch drawing on an old batch, never refused. */
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--done { opacity: .65; }
.chip.dragging { opacity: .35; }
/* Overrides the generic .cal-day--past .chip dimming: a log chip already
   reads as muted-but-confirmed, so it needs less of it. */
.cal-day--past .chip--log { opacity: .85; }

.cal-palette {
  position: sticky;
  top: calc(var(--appbar-h) + var(--gap));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: calc(100vh - var(--appbar-h) - var(--tabbar-h) - 2 * var(--gap));
  overflow: auto;
}
.cal-palette-title { margin: 0 0 8px; font-size: 15px; }

.cal-search { width: 100%; margin-bottom: 8px; }
.cal-section { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 4px;
  cursor: grab;
  user-select: none;
  font-size: 14px;
}
.pal-item--freezer { background: var(--frost-soft); border-color: transparent; color: var(--frost); }
.pal-item--spent { opacity: .5; cursor: not-allowed; }
.pal-item.dragging { opacity: .35; }
.pal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cal-pop {
  position: fixed;
  z-index: 40;
  min-width: 240px;
  max-width: 320px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pop-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.pop-action { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; }

.pop-form { display: grid; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pop-form-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* The popover caps out at 320px; app.css's 74px stepper input does not
   leave room for the +/- buttons and a label in that width. */
.pop-form .stepper input { width: 3ch; }

/* calendar-gap-finder: a day inside the plannable window with no lunch yet. */
.cal-gap {
  margin-top: auto;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* repeat-week popover: the two week <select>s reuse .input, but should not
   stretch to the app-wide 100% inside the popover's own 320px cap. */
.pop-form-row select.input { width: auto; max-width: 190px; }
