/* The Pulse date picker menu (Figma 1399:124704), shared by the timeline and
   the date range menu. Its tokens are scoped to the picker's own elements
   rather than :root, so it carries everything it needs into any page and
   leaves that page's own tokens alone. */

.picker-backdrop,
.picker-popover,
.picker,
.picker__tooltip {
  --fg-brand-primary: #132a7d;
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9fb;
  --bg-active: #d7e6fe;
  --bg-brand-solid: #132a7d;
  --bg-primary-solid: #121217;
  --bg-primary_hover: rgba(0, 0, 0, 0.05);
  --border-primary: #e0e4eb;
  --border-secondary: #e6e9f0;
  --text-primary: #22242f;
  --text-secondary: #424761;
  --text-secondary-hover: #323548;
  --text-tertiary: #51597b;
  --text-brand-secondary: #1644c8;
  --text-white: #ffffff;
  --fg-quaternary: #919db6;
  --utility-neutral-200: #e0e4eb;
  --utility-neutral-500: #667399;
  --tooltip-supporting-text: #c0c8d8;

  --radius-xs: 4px;
  --radius-md: 8px;
  /* Not a token in the frame; the menu's corner reads larger than radius-md. */
  --radius-lg: 12px;
  /* Read off the unit-grid mockup; the frame names no token for it. */
  --radius-xl: 16px;
  --radius-full: 9999px;

  --spacing-xxs: 2px;
  --spacing-xs: 4px;
  --spacing-sm: 6px;
  --spacing-md: 8px;
  --spacing-lg: 12px;
  --spacing-xl: 16px;
  --spacing-2xl: 20px;
  --spacing-3xl: 24px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 1px 2px 0 rgba(0, 0, 0, 0.04),
    0 2px 4px 0 rgba(0, 0, 0, 0.02),
    0 4px 8px 0 rgba(0, 0, 0, 0.02),
    0 8px 12px 0 rgba(0, 0, 0, 0.02),
    0 0 0 0.5px #e0e0e0;

  --text-xs: 12px;
  --line-height-text-xs: 16px;
  --text-sm: 14px;
  --line-height-text-sm: 20px;
  --text-md: 16px;
  --line-height-text-md: 24px;

  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ---------- Date picker menu ---------- */

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  background: rgba(18, 18, 23, 0.32);
  animation: scrim-in 0.15s ease;
}
/* A class selector beats the UA's [hidden] rule, so say it explicitly --
   without this the dialog is displayed even while hidden is set. */
.picker-backdrop[hidden] { display: none; }

/* Popover mode: no scrim, the menu hangs under its anchor. Placed in page
   coordinates by the script, so it scrolls with the page it belongs to. */
.picker-popover {
  position: absolute;
  z-index: 10;
}
.picker-popover[hidden] { display: none; }

@keyframes scrim-in { from { opacity: 0; } }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
}

.picker {
  display: flex;
  /* 812px, plus a 40px week column in each of the two panels. */
  width: 892px;
  max-width: 100%;
  max-height: 100%;
  animation: dialog-in 0.18s var(--ease-out);
  overflow: auto;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.picker__rail {
  flex: none;
  width: 156px;
  padding: 0 var(--spacing-lg) var(--spacing-lg);
  border-right: 1px solid var(--border-secondary);
}

/* Comparison sits under Period, divided by a rule that runs the full width
   of the rail. */
.picker__group--compare {
  margin: var(--spacing-lg) calc(-1 * var(--spacing-lg)) 0;
  padding: 0 var(--spacing-lg);
  border-top: 1px solid var(--border-secondary);
}

.picker__heading {
  margin: 0;
  padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-xs);
  font-size: var(--text-xs);
  line-height: var(--line-height-text-xs);
  font-weight: 700;
  color: var(--text-primary);
}

.picker__list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.picker__option {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-xl);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.picker__option:hover { background: var(--bg-primary_hover); }
.picker__option:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: -2px;
}
.picker__option[aria-selected="true"] {
  background: var(--bg-active);
  color: var(--text-secondary-hover);
}
/* Grey, like the comparison band it switches on -- blue stays the selection's. */
.picker__group--compare .picker__option[aria-selected="true"] {
  background: var(--utility-neutral-200);
  color: var(--text-primary);
}

.picker__main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top panel ---------- */

.picker__top {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg) var(--spacing-3xl);
  border-bottom: 1px solid var(--border-secondary);
}

.picker__shortcuts {
  display: flex;
  align-items: center;
  gap: var(--spacing-3xl);
}

.picker__shortcut {
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 600;
  color: var(--text-brand-secondary);
  white-space: nowrap;
  cursor: pointer;
}
.picker__shortcut:hover { text-decoration: underline; }
.picker__shortcut:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.picker__dates {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--spacing-xs);
  margin-left: auto;
}

.picker__range {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

/* The compared period, read-only: it follows from the range and the mode. */
.picker__vs {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin: 0;
  padding: 0 var(--spacing-xl);
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.picker__vs[hidden] { display: none; }
.picker__vs-sep { color: var(--fg-quaternary); }
.picker__vs-dash {
  font-size: var(--text-md);
  line-height: var(--line-height-text-md);
  color: var(--fg-quaternary);
}

/* Wide enough for the longest form, "Week 53, 2026", with room to type. */
.picker__input {
  width: 136px;
  height: 36px;
  padding: 0 var(--spacing-md);
  background: var(--bg-primary);
  border: 0.5px solid var(--border-primary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.picker__input:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: 1px;
}
.picker__input.is-invalid { color: #b42318; }

.picker__dash {
  font-size: var(--text-md);
  line-height: var(--line-height-text-md);
  color: var(--text-tertiary);
}

/* ---------- Calendars ---------- */

.picker__months {
  flex: 1 1 auto;
  display: flex;
  /* Hold the day grid's height so the dialog doesn't jump between scopes. */
  min-height: 384px;
}

.cal {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-2xl) var(--spacing-3xl);
}
.cal + .cal { border-left: 1px solid var(--border-secondary); }

.cal__head {
  display: flex;
  align-items: center;
  height: 32px;
  margin-bottom: var(--spacing-md);
}

.cal__nav {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.cal__nav:hover { background: var(--bg-primary_hover); }
.cal__nav:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: -2px;
}
.cal__nav.is-spacer { visibility: hidden; }
.cal__nav svg { display: block; }

.cal__title {
  flex: 1 1 0;
  text-align: center;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.cal__grid {
  display: grid;
  row-gap: var(--spacing-xs);
}

/* Fixed 40px columns, so the cells touch and a band or a disc never has a
   gap beside it, however wide the panel gets. The first is the week number. */
.cal__grid--days {
  grid-template-columns: repeat(8, 40px);
  justify-content: center;
}

/* Month / Quarter / Year pick whole units, so a cell is a block rather than a
   40px disc: the grid stretches to the day grid's height and every row takes
   an equal share, so a month is a big target and the panels line up. The
   rounded rectangle replaces the pill -- at this height a full radius would
   read as a lozenge. */
.cal__grid--units {
  flex: 1 1 auto;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  row-gap: var(--spacing-xs);
}
/* Month grids lead each row with its quarter, in a 40px column like the
   day grid's week numbers. */
.cal__grid--units.has-labels { grid-template-columns: 40px repeat(3, 1fr); }
.cal__cell.cal__cell--wide { height: auto; }
.cal__cell--wide .cal__disc {
  left: 0;
  width: 100%;
  height: 100%;
  margin-left: 0;
  border-radius: var(--radius-xl);
}
.cal__cell--wide .cal__band.cap-left { border-radius: var(--radius-xl) 0 0 var(--radius-xl); }
.cal__cell--wide .cal__band.cap-right { border-radius: 0 var(--radius-xl) var(--radius-xl) 0; }
.cal__cell--wide .cal__band.cap-left.cap-right { border-radius: var(--radius-xl); }
.cal__cell.cal__cell--wide:focus-visible { border-radius: var(--radius-xl); }

.cal__dow {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 500;
  color: var(--utility-neutral-500);
}

/* A cell is a 40px circle; .cal__band paints the run between the two
   endpoints, capped where the run breaks, so a rounded cap always meets the
   navy endpoint circle -- which is the notch the Figma connectors produce. */
.cal__cell {
  position: relative;
  /* Contain the z-index the number and dot use to sit over the band, so it
     cannot outrank the sticky footer in the picker's stacking context. */
  isolation: isolate;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
}
.cal__cell.is-outside { color: var(--fg-quaternary); }

/* Row labels -- W12 beside a week, Q3 beside a quarter -- are a margin note
   (Text 2xs/Medium at half strength, as in the frame) and stay one when their
   row is banded: the band starts at the row's first cell, not at the label.
   Where the row is the period's unit they are buttons that pick it. */
.cal__label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 10px;
  line-height: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.5;
}
button.cal__label {
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: opacity 0.12s ease;
}
button.cal__label:hover { opacity: 1; }
button.cal__label:focus-visible {
  opacity: 1;
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: -3px;
}

.cal__cell:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: -3px;
  border-radius: var(--radius-full);
}

.cal__band {
  position: absolute;
  inset: 0;
  background: var(--bg-active);
}
.cal__band.cap-left { border-radius: var(--radius-full) 0 0 var(--radius-full); }
.cal__band.cap-right { border-radius: 0 var(--radius-full) var(--radius-full) 0; }
.cal__band.cap-left.cap-right { border-radius: var(--radius-full); }
.cal__band--compare { background: var(--utility-neutral-200); }

.cal__disc {
  position: absolute;
  top: 0;
  left: 50%;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border-radius: var(--radius-full);
}
.cal__cell.is-today .cal__disc { background: var(--bg-brand-solid); }

.cal__num {
  position: relative;
  z-index: 1;
}
.cal__cell.is-today .cal__num {
  color: var(--text-white);
  font-weight: 500;
}
.cal__cell.in-band .cal__num { font-weight: 500; }

.cal__cell:not(.is-today):not(.in-band):hover .cal__disc {
  background: var(--bg-primary_hover);
}

.cal__dot {
  position: absolute;
  z-index: 1;
  bottom: 4px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: var(--radius-full);
  background: var(--text-secondary);
}
.cal__cell.is-today .cal__dot { background: var(--text-white); }

/* A filled navy block the size of a month would outshout the selection, so
   on the unit grids today is a navy outline instead -- same colour, same
   meaning, a fraction of the weight. */
.cal__cell--wide.is-today .cal__disc {
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--bg-brand-solid);
}
.cal__cell--wide.is-today .cal__num { color: var(--fg-brand-primary); }
.cal__cell--wide.is-today:not(.in-band):hover .cal__disc { background: var(--bg-primary_hover); }

/* ---------- Bottom panel ---------- */

.picker__bottom {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--bg-secondary);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-lg);
  padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-xl) var(--spacing-3xl);
  border-top: 1px solid var(--border-secondary);
}

.btn {
  height: 36px;
  padding: 0 var(--spacing-xl);
  border-radius: var(--radius-full);
  border: 0.5px solid transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: var(--line-height-text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.btn:focus-visible {
  outline: 2px solid var(--fg-brand-primary);
  outline-offset: 2px;
}
.btn--ghost {
  background: var(--bg-primary);
  border-color: var(--border-primary);
  box-shadow: var(--shadow-xs);
  color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-secondary); }
.btn--primary {
  background: var(--bg-brand-solid);
  color: var(--text-white);
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: #0f2166; }

/* ---------- Holiday tooltip ---------- */

.picker__tooltip {
  position: fixed;
  z-index: 12;
  width: 200px;
  padding: var(--spacing-lg);
  background: var(--bg-primary-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.picker__tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: var(--bg-primary-solid);
  border-bottom-width: 0;
}
.picker__tooltip h4 {
  margin: 0 0 var(--spacing-xxs);
  font-size: var(--text-xs);
  line-height: var(--line-height-text-xs);
  font-weight: 700;
  color: var(--text-white);
}
.picker__tooltip ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.picker__tooltip li {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  font-size: var(--text-xs);
  line-height: var(--line-height-text-xs);
  color: var(--tooltip-supporting-text);
}
.picker__tooltip li::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--tooltip-supporting-text);
}

/* ---------- Picker responsive ---------- */

@media (max-width: 880px) {
  .picker { flex-direction: column; width: 460px; }
  .picker__rail {
    width: auto;
    padding: var(--spacing-lg);
    border-right: none;
    border-bottom: 1px solid var(--border-secondary);
  }
  .picker__heading { display: none; }
  .picker__list { flex-direction: row; gap: var(--spacing-xs); }
  .picker__option { padding: var(--spacing-sm) var(--spacing-lg); text-align: center; }
  .picker__top { flex-wrap: wrap; row-gap: var(--spacing-md); }
  .picker__dates { margin-left: 0; align-items: flex-start; }
  .picker__vs { padding: 0; }
  /* Two rows of chips need telling apart, so Comparison keeps a label. */
  .picker__group--compare {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0 0;
    padding: var(--spacing-md) 0 0;
  }
  .picker__group--compare .picker__heading { display: block; padding: 0; }
}

@media (max-width: 520px) {
  .picker { width: calc(100vw - 24px); }
  .picker__shortcuts { gap: var(--spacing-lg); }
  .cal { padding: var(--spacing-lg); }
}
