/* === Date and time picker — assets/js/date-picker.js =========================
   One control for every date on the site. It speaks tokens.css only: every
   colour is a --dp-* variable defaulting to a token (the reminders page remaps
   them to its own palette — reminders.css, .rm-page and .rm-page .dp-panel), and
   every gap, padding and radius is on the --s-* / --r-* scale. Both pages that
   load it load tokens.css first. */

/* The native input stays in the form — it posts, it validates, it fires
   change — visually hidden but still where the browser anchors its message.
   display:none would make `required` unfocusable, the trap combo.js met. */
.dp { position: relative; display: block; min-width: 0; }
.dp > .dp-native {
  position: absolute; bottom: var(--s-2); left: var(--s-3);
  width: 1px; height: 1px; padding: 0; margin: 0; border: 0;
  opacity: 0; pointer-events: none;
}

/* The control carries the input's own classes (.input, .rm-input, .error), so
   its height, border and focus ring ARE the form's rule. These only lay it out. */
.dp-trigger {
  display: flex; align-items: center; gap: var(--s-2);
  text-align: left; cursor: pointer;
  min-width: 10.5em;
}
.dp-trigger-time { min-width: 14.5em; }
.dp-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dp-trigger.is-placeholder .dp-text { color: var(--dp-placeholder, var(--char-500)); }
/* The calendar glyph is a mask, so its colour is a variable like every other. */
.dp-trigger::after {
  content: ''; flex: none; width: 16px; height: 16px;
  background: var(--dp-icon, var(--char-500));
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E") no-repeat center / 16px 16px;
          mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E") no-repeat center / 16px 16px;
}

.dp-panel {
  --dp-surface: var(--pearl);
  --dp-line:    var(--line-200);
  --dp-ink:     var(--char-900);
  --dp-muted:   var(--char-500);
  --dp-on:      var(--ink-800);
  --dp-on-ink:  var(--pearl);
  --dp-hover:   var(--gold-100);
  --dp-mark:    var(--gold-700);
  --dp-font:    var(--font-ui);
  /* Mounted on <body>, so its layer must clear the full-screen overlays a field
     can sit in — the modal and the filter sheet, both 9000 in components.css —
     and stay under the toasts (9999). At 1000 it opened behind the finance
     "record a transaction" modal (owner, 2026-09-12). */
  position: fixed; z-index: 9500; top: 0; left: 0;
  display: grid; grid-template-columns: auto;
  max-width: calc(100vw - 16px);
  background: var(--dp-surface); color: var(--dp-ink);
  border: 1px solid var(--dp-line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lifted);
  font: 400 14px/1.2 var(--dp-font);
}
.dp-panel.dp-with-time { grid-template-columns: auto auto; }
.dp-panel[hidden] { display: none; }

.dp-cal { padding: var(--s-3); }
.dp-head { display: flex; align-items: center; gap: var(--s-1); margin: 0 0 var(--s-2); }
.dp-month { flex: 1; text-align: center; font-weight: 600; font-size: 15px; }
.dp-nav {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-md); background: none; color: var(--dp-ink); cursor: pointer;
}
.dp-nav:hover:not(:disabled) { background: var(--dp-hover); }
.dp-nav:disabled { opacity: .3; cursor: default; }

.dp-grid { border-collapse: separate; border-spacing: var(--s-1); margin: calc(-1 * var(--s-1)); }
.dp-grid th {
  height: 26px; padding: 0;
  font: 600 11px var(--dp-font); letter-spacing: .06em; text-transform: uppercase; color: var(--dp-muted);
}
.dp-grid td { padding: 0; }
.dp-day {
  position: relative; display: block; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--r-md); background: none; cursor: pointer;
  font: 500 14px var(--dp-font); color: var(--dp-ink); font-variant-numeric: tabular-nums;
}
.dp-day:hover:not([aria-disabled]):not(.is-on) { background: var(--dp-hover); }
.dp-day.is-out { color: var(--dp-muted); }
.dp-day.is-today::after {
  content: ''; position: absolute; left: 50%; bottom: var(--s-1);
  width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--dp-mark);
}
.dp-day.is-on { background: var(--dp-on); color: var(--dp-on-ink); font-weight: 600; }
.dp-day.is-on::after { background: var(--dp-on-ink); }

/* Out of reach: faded AND struck through — colour is never the only signal. */
.dp-day[aria-disabled], .dp-time[aria-disabled] {
  color: var(--dp-muted); opacity: .45; text-decoration: line-through; cursor: default;
}

/* The times sit beside the calendar and exactly as tall as it (--dp-cal-h is
   measured when it opens), so the panel is one clean block. */
.dp-times {
  position: relative; box-sizing: border-box; width: 120px; height: var(--dp-cal-h, auto);
  overflow-y: auto; padding: var(--s-2) var(--s-1); border-left: 1px solid var(--dp-line);
}
.dp-times:focus { outline: none; }
.dp-time {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md); cursor: pointer; white-space: nowrap;
  font: 500 14px var(--dp-font); font-variant-numeric: tabular-nums;
}
.dp-time:hover:not([aria-disabled]):not(.is-on), .dp-time.is-active:not(.is-on) { background: var(--dp-hover); }
.dp-time.is-on { background: var(--dp-on); color: var(--dp-on-ink); font-weight: 600; }
.dp-times:focus-visible .dp-time.is-active { outline: 2px solid var(--dp-mark); outline-offset: -2px; }

.dp-day:focus-visible, .dp-nav:focus-visible, .dp-clear:focus-visible { outline: 2px solid var(--dp-mark); outline-offset: 1px; }

/* Spans the panel without widening it: a zero width that grows to fill means
   a long note wraps inside the calendar's width instead of stretching it. */
.dp-foot {
  grid-column: 1 / -1; width: 0; min-width: 100%; box-sizing: border-box;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4); border-top: 1px solid var(--dp-line);
  font-size: 13px; line-height: 1.35; color: var(--dp-muted);
}
.dp-foot[hidden], .dp-clear[hidden] { display: none; }
.dp-note { flex: 1; min-width: 0; }
.dp-clear {
  margin-left: auto; padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: 600 13px var(--dp-font); color: var(--dp-mark);
}
.dp-clear:hover { background: var(--dp-hover); }

/* A phone: the times go under the calendar, four to a row, big enough to tap. */
@media (max-width: 520px) {
  .dp-panel.dp-with-time { grid-template-columns: auto; }
  .dp-day { width: 40px; height: 40px; }
  .dp-times {
    width: auto; height: 176px; border-left: 0; border-top: 1px solid var(--dp-line);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-1); align-content: start;
  }
  .dp-time { padding: var(--s-3) var(--s-1); text-align: center; font-size: 13px; }
}
