/* Ledger A - the reusable controls from js/ui/shared/: drop-downs, the day chooser, the priority
   slider and the Auto | Manual pill. Loaded straight after forms.css (the text-box rule there also
   styles .picker-button and must come first) and BEFORE the feature files, whose own rows
   narrow these controls and must come later to win. */

/* ---------- the box a drop-down or day chooser opens from ---------- */
.picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  width: 100%;
  text-align: left;
}
.picker-button:hover,
.picker-button[aria-expanded="true"] {
  border-color: var(--colour-accent);
}
.picker-button__text {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-button__arrow {
  flex: none;
  color: var(--colour-text-muted);
  font-size: var(--font-size-sm);
}
/* The arrow is drawn here, not typed into the page, so it isn't part of the button's words. */
.picker-button__arrow::before {
  content: "▾";
}

/* ---------- drop-down menus in the app's own look (ui/shared/dropdown.js) ---------- */
.dropdown {
  position: relative;
  min-width: 0;
}
.dropdown__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--layer-menu);
  min-width: 100%;
  max-height: var(--size-220);
  overflow-y: auto;
  padding: var(--space-4);
  border: var(--border-thin) solid var(--colour-line-strong);
  border-radius: var(--radius-8);
  background: var(--colour-surface-stage);
  box-shadow: var(--shadow-menu);
}
.dropdown__list[hidden] {
  display: none;
}
.dropdown__list--up {
  top: auto;
  bottom: calc(100% + 4px);
}
.dropdown__option {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-10);
  border-radius: var(--radius-6);
  white-space: nowrap;
  cursor: pointer;
}
/* The lilac highlight follows the mouse (and the arrow keys). It starts on the chosen item. */
.dropdown__option--highlighted {
  background: var(--colour-accent-soft); /* soft lilac, the app's accent */
}
.dropdown__option--selected {
  font-weight: var(--font-weight-medium); /* the chosen item is shown in bold */
}

/* ---------- day chooser (ui/shared/date-picker.js) ---------- */
/* Its month grid reuses the small month calendar's own look (.month-grid, in base.css). */
.date-picker {
  position: relative;
  min-width: 0;
}
.date-picker__popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--layer-menu);
  width: var(--size-250);
  padding: var(--space-10) var(--space-12) var(--space-12);
  border: var(--border-thin) solid var(--colour-line-strong);
  border-radius: var(--radius-8);
  background: var(--colour-surface-stage);
  box-shadow: var(--shadow-menu);
}
.date-picker__popup[hidden] {
  display: none;
}
.date-picker__popup--up {
  top: auto;
  bottom: calc(100% + 4px);
}
.date-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.date-picker__title {
  margin: 0;
}
.date-picker__arrow {
  font-size: var(--font-size-2xl);
}
/* In the day chooser, today is only marked by its text; the chosen day is filled. */
.month-grid__day--today-text {
  font-weight: var(--font-weight-bold);
  color: var(--colour-accent-hover);
}
.month-grid__day--picked,
.month-grid__day--picked:hover {
  background: var(--colour-accent);
  color: var(--colour-text-on-accent);
  font-weight: var(--font-weight-bold);
}

/* ---------- priority slider (task form): snaps to 1-5, green to red ---------- */
.priority-slider {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  width: 100%;
  height: var(--size-30);
  touch-action: none; /* dragging must not scroll the page */
  user-select: none;
}
.priority-slider:focus-visible {
  outline: var(--border-medium) solid var(--colour-accent);
  outline-offset: var(--space-2);
  border-radius: var(--radius-8);
}
.priority-slider__rail {
  position: relative;
  flex: 1;
  height: var(--size-24);
  margin: 0 var(--space-9); /* room for half the handle at each end */
}
.priority-slider__line {
  position: absolute;
  top: 9px;
  right: -3px; /* the line ends flush with the outer edge of the end nodes (3px radius) */
  left: -3px;
  height: var(--size-6);
  border-radius: var(--radius-3);
  background: linear-gradient(
    to right,
    var(--colour-scale-1),
    var(--colour-scale-2),
    var(--colour-scale-3),
    var(--colour-scale-4),
    var(--colour-scale-5)
  );
}
.priority-slider__node {
  position: absolute;
  top: 9px;
  width: var(--size-6);
  height: var(--size-6);
  margin-left: calc(var(--space-3) * -1);
  border-radius: var(--radius-round);
  background: var(--colour-slider-node);
}
.priority-slider__handle {
  position: absolute;
  top: 3px;
  width: var(--size-18);
  height: var(--size-18);
  margin-left: calc(var(--space-9) * -1);
  border: var(--border-thick) solid var(--colour-surface-stage);
  border-radius: var(--radius-round);
  box-shadow: var(--shadow-thumb);
  cursor: grab; /* only the bulb moves the slider */
  transition:
    left var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}
.priority-slider__handle::before {
  position: absolute;
  inset: -6px; /* a larger area to grab, so the bulb is easy to catch */
  content: "";
}
.priority-slider--dragging .priority-slider__handle {
  transition: none; /* follow the mouse closely while dragging */
}
.priority-slider__value {
  min-width: 1ch;
  font-weight: var(--font-weight-bold);
}
@media (prefers-reduced-motion: reduce) {
  .priority-slider__handle {
    transition: none;
  }
}

/* ---------- time box with a menu of readings (js/ui/shared/length-picker.js) ---------- */
/* Used by the task form's "Time to do" and the event form's travel times. */
.length-picker__box {
  width: 100%;
}
.length-picker__list {
  max-height: none; /* the quick choices all show without scrolling */
}

/* ---------- pill toggle with word options (task form: Auto | Manual) ---------- */
/* The same look as the S | M switch, but the highlight resizes to fit each word as it slides
   (js/ui/shared/pill-toggle.js measures the chosen option and sets the thumb's width and position). */
.pill-toggle {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
  height: var(--size-30);
  padding: 0 var(--space-3); /* with the 3px above and below the highlight, an even edge all round */
  border-radius: var(--radius-15);
  background: var(--colour-surface-control);
  cursor: pointer;
}
.pill-toggle[hidden] {
  display: none;
}
.pill-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 0;
  height: var(--size-24);
  border-radius: var(--radius-12);
  background: var(--colour-accent);
  transition:
    transform var(--duration-base) var(--ease),
    width var(--duration-base) var(--ease);
}
.pill-toggle__option {
  position: relative; /* above the sliding highlight */
  padding: 0 var(--space-14);
  border: 0;
  background: none;
  color: var(--colour-text); /* the muted brown was too faint on the pill (accessibility check) */
  font: inherit;
  font-weight: var(--font-weight-bold);
  line-height: var(--size-30);
  cursor: pointer;
}
.pill-toggle__option--chosen {
  color: var(--colour-text-on-accent);
}
@media (prefers-reduced-motion: reduce) {
  .pill-toggle__thumb {
    transition: none;
  }
}
