/* Reusable React <DatePicker> (components/DatePicker.tsx) — replaces native
   <input type="date"> (see that file for why: iOS Safari's own wheel picker
   renders completely differently from desktop browsers, ignoring most CSS).
   Popover on >=700px, bottom sheet (shared .cp-sheet shell) on <700px — only
   one is ever MOUNTED (gated in JS via useMediaQuery, not a CSS visibility
   swap — see the component's file header for why). Class prefix: dpk-*.
   NOT the same file as datepicker.css (sdp-* prefix) — that one is the
   Django-admin-only datepicker (see CLAUDE.md), untouched by this. */

.dpk-anchor { position: relative; }

/* Font: the mobile calendar portals into document.body via BottomSheet, so pin
   the app font on the calendar root rather than relying on inheritance. */
.dpk-cal { font-family: var(--font); max-width: 300px; margin: 0 auto; }

.dpk-field {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
}
.dpk-field svg { width: 16px; height: 16px; stroke: var(--muted); flex-shrink: 0; }
.dpk-field span { font-variant-numeric: tabular-nums; }
.dpk-field.open { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* Popover — only mounted at >=700px (see DatePicker.tsx). Portaled to
   document.body and positioned via JS-computed top/left (usePopoverPlacement)
   as position:fixed, NOT absolute — an in-flow popover got clipped by any
   scrollable ancestor (e.g. the Add-Entry sheet's overflow-y:auto body), so
   top/left are inline styles, not CSS, and this rule only supplies the
   chrome. */
.dpk-popover {
  position: fixed;
  z-index: 20020; /* above .cp-sheet-nested (20011, ui.css) — can open from inside a nested sheet */
  background: var(--white);
  border-radius: 12px;
  padding: 14px;
  /* natural-shadows Level 4 (popover), verbatim */
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  animation: dpk-pop-in 0.16s ease;
  max-width: calc(100vw - 32px);
  transition: opacity 0.08s ease;
}
@keyframes dpk-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile sheet: nested (see BottomSheet.tsx + ui.css
   .cp-sheet-nested/.cp-backdrop-nested) — DatePicker can open FROM INSIDE
   another already-open .cp-sheet (e.g. Body Stats' Log-entry sheet), so it
   must stack strictly above the base tier. Only mounted at <700px. */

.dpk-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.dpk-cal-month { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--ink); }
.dpk-cal-nav { display: flex; gap: 4px; }
.dpk-cal-nav button {
  width: 28px; height: 28px; border: none; background: none;
  border-radius: 6px; cursor: pointer; font-size: var(--fs-xl); color: var(--slate);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
}
.dpk-cal-nav button:hover { background: var(--bg); }

.dpk-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.dpk-cal-weekdays span {
  text-align: center; font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  color: var(--muted); padding: 4px 0;
}

.dpk-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.dpk-day {
  width: 34px; height: 34px; margin: 0 auto; border: none; background: none; border-radius: 7px;
  font-size: var(--fs-md); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font);
}
.dpk-day:hover:not(:disabled) { background: var(--bg); }
.dpk-day.muted { color: var(--border); cursor: default; }
.dpk-day.today { font-weight: var(--fw-bold); box-shadow: inset 0 0 0 1px var(--blue); }
.dpk-day.selected { background: var(--blue); color: var(--white); font-weight: var(--fw-semibold); }
.dpk-day.selected:hover { background: var(--blue-dark); }

/* ───────── Reusable React <TimePicker> (components/TimePicker.tsx) ─────────
   Same file as the date picker because it's the same picker family and shares
   .dpk-anchor / .dpk-field (the pill trigger button) verbatim; only the
   dropdown body differs, so only that gets its own tpk-* prefix. */

.tpk-grid {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  font-family: var(--font);
}

/* Fixed height + scroll: the columns are long lists, and an unbounded height
   would make the popover taller than the viewport on desktop. */
.tpk-col {
  height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}
.tpk-col::-webkit-scrollbar { display: none; }

.tpk-sep {
  align-self: center;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--muted);
}

.tpk-opt {
  flex-shrink: 0;
  width: 56px;
  height: 34px;
  border: none;
  background: none;
  border-radius: 7px;
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpk-opt:hover:not(.selected) { background: var(--bg); }
.tpk-opt.selected {
  background: var(--blue);
  color: var(--white);
  font-weight: var(--fw-semibold);
}

/* Popover — only mounted at >=700px (see TimePicker.tsx), portaled +
   position:fixed same as .dpk-popover (see its comment above) — mirrors it
   incl. the natural-shadows Level 4 (popover) recipe, verbatim. */
.tpk-popover {
  position: fixed;
  z-index: 20020;
  background: var(--white);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  animation: dpk-pop-in 0.16s ease;
  max-width: calc(100vw - 32px);
  transition: opacity 0.08s ease;
}

/* Mobile sheet — only mounted at <700px (see TimePicker.tsx). */
