/* The workspace date picker. Built entirely from the tokens app.css defines, so
   the dark theme and the future layout come for free rather than being repeated
   here. app/static/js/datepicker.js is what puts these elements on the page.

   The field keeps the shape of every other input in the app — the same border,
   radius and focus ring — because it is still a field you type into. Only the
   calendar that opens is ours, and it is one of the few things in this app that
   legitimately floats: it is a popover, so it carries --shadow-pop. */

.date-field { position: relative; display: block; }
.date-field .date-field-input { padding-right: 40px; }

/* Addressed through .date-field, which is one class more than a page's own
   "every button in this form" rule: the picker drops this button into whatever
   form a page has written, and the department plan's 220px submit-button rule
   caught it and stretched the calendar icon across half the field. */
.date-field > .date-field-open {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 29px;
  min-width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  background: transparent;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.date-field-open:hover { color: var(--accent); background: var(--sheet-2); }
.date-field-open svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The popup is placed on <body> and positioned in script: a field can sit
   inside a panel that clips its overflow, and this must never be the thing
   that gets cut off. */
.date-picker {
  position: fixed;
  z-index: 9000;
  width: 292px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow-pop);
}

.date-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.date-picker-head .icon-button { width: 29px; height: 29px; min-height: 29px; font-size: .8125rem; }
.date-picker-month { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.date-picker-weekdays,
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
/* Sentence case, the same as the month grid's own headings. Tracked-out
   capitals on a three-letter day name are the loudest thing in a popover that
   has nothing urgent to say. */
.date-picker-weekdays span {
  color: var(--ink-2);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
}

/* Day cells read as the month grid does: tabular figures at .8125rem/600,
   today an accent chip, the chosen day filled. */
.date-picker-day {
  height: 33px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: transparent;
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.date-picker-day.blank { cursor: default; }
.date-picker-day.weekend { color: var(--ink-2); background: var(--sheet-2); }
.date-picker-day:hover:not(.blank):not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.date-picker-day:focus-visible { outline: none; box-shadow: var(--focus); }
/* Today is the outlined chip and the chosen day is the filled one, so a picker
   opened on a date that is not today still says which of the two is which. */
.date-picker-day.today { border-color: var(--accent); color: var(--accent); }
.date-picker-day.selected,
.date-picker-day.selected.weekend {
  border-color: transparent;
  color: var(--accent-ink);
  background: var(--accent);
}
.date-picker-day:disabled { color: var(--ink-3); opacity: .45; cursor: not-allowed; }

/* A time field opens two scrolling columns instead of a month. Same shell, same
   tokens, same slot shape as a day cell, so the panel off the clock icon and
   the panel off the calendar icon read as one control. */
.date-picker.time-picker { width: 168px; }
.time-picker-head > span { color: var(--ink-2); font-size: .6875rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.time-picker-head .time-picker-readout { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.time-picker-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.time-picker-column {
  max-height: 226px;
  display: grid;
  align-content: start;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.time-picker-slot {
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: transparent;
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.time-picker-slot:hover { color: var(--accent); background: var(--accent-soft); }
.time-picker-slot:focus-visible { outline: none; box-shadow: var(--focus); }
.time-picker-slot.selected { border-color: transparent; color: var(--accent-ink); background: var(--accent); font-weight: 600; }

.date-picker-time {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.date-picker-time > span:first-child { flex: 1 1 auto; color: var(--ink-2); font-weight: 600; }
.date-picker-time select { width: auto; min-height: 36px; padding: 4px 8px; }

html[data-layout="future"] .date-picker {
  border-color: var(--future-line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow-pop);
}

/* Redundant now that the chosen day and slot are drawn from --accent and
   --accent-ink, which the dark token block already flips. Kept only so no
   selector disappears from the file; there is nothing here to keep in step. */
html[data-theme="dark"] .date-picker-day.selected,
html[data-theme="dark"] .date-picker-day.selected.weekend {
  color: var(--accent-ink);
  background: var(--accent);
}
html[data-theme="dark"] .time-picker-slot.selected {
  color: var(--accent);
  background: var(--accent-soft);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .date-picker-day.selected,
  html:not([data-theme="light"]) .date-picker-day.selected.weekend {
    color: var(--accent-ink);
    background: var(--accent);
  }
  html:not([data-theme="light"]) .time-picker-slot.selected {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

@media (max-width: 480px) {
  .date-picker { width: min(292px, calc(100vw - 24px)); }
}
