/* The date picker dialog: arm B of App\Analytics\DatePickerExperiment. Loaded
 * only with that form, so arm A pays nothing for it. */

html.date-picker-open {
  overflow: hidden;
  padding-right: var(--date-picker-scrollbar, 0);
}

.date-picker {
  width: min(760px, calc(100vw - 48px));
  max-width: none;
  height: min(720px, calc(100vh - 48px));
  height: min(720px, calc(100dvh - 48px));
  max-height: none;
  /* base.css zeroes every margin, and this one is what centres a modal dialog. */
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  overscroll-behavior: contain;
}
.date-picker::backdrop {
  background: rgba(14, 39, 67, 0.62);
}
.date-picker__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* ── Head ─────────────────────────────────────────────────────────────── */
.date-picker__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  padding: 18px 20px 16px;
  background: var(--navy);
  color: #fff;
}
.date-picker__title {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}
.date-picker__summary {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.3;
}
.date-picker__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.date-picker__close:hover { background: rgba(255, 255, 255, 0.14); }
.date-picker__filter {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.date-picker__filter[hidden] { display: none; }
.date-picker__filter-label {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.date-picker__filter-select {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 36px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  /* Safari's native select ignores min-height and stays 27px tall. */
  appearance: none;
  -webkit-appearance: none;
  background: #fff no-repeat right 12px center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9l7 7 7-7' fill='none' stroke='%230E2743' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  color: var(--ink);
  /* 16px: iOS zooms the page into any smaller field. */
  font-family: inherit;
  font-size: 16px;
  text-overflow: ellipsis;
}

/* ── Month bar ────────────────────────────────────────────────────────── */
.date-picker__months {
  position: relative;
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  background: var(--tint);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  touch-action: pan-x;
}
.date-picker__tab {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 48px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  line-height: 1.15;
  cursor: pointer;
}
.date-picker__tab:hover { background: #fff; border-color: var(--line); }
.date-picker__tab-month {
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
}
.date-picker__tab-year {
  font-size: 12px;
  font-weight: 600;
}
.date-picker__tab.is-active,
.date-picker__tab.is-active:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

/* ── List ─────────────────────────────────────────────────────────────── */
.date-picker__list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #fff;
}
.date-picker__list:focus { outline: none; }
/* Wide on purpose: an older audience has to be able to hit it. */
.date-picker__list::-webkit-scrollbar { width: 14px; }
.date-picker__list::-webkit-scrollbar-track { background: var(--tint); }
.date-picker__list::-webkit-scrollbar-thumb {
  border: 3px solid var(--tint);
  border-radius: 999px;
  background: var(--navy-soft);
}
@supports not selector(::-webkit-scrollbar) {
  .date-picker__list { scrollbar-color: var(--navy-soft) var(--tint); }
}
.date-picker__month-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 11px 20px;
  background: var(--tint);
  border-bottom: 1px solid var(--line);
  color: var(--navy);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}
.date-picker__month-title small {
  color: var(--navy-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.date-picker__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}
.date-picker__rows li + li { border-top: 1px solid var(--line); }
.date-picker__row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 9px 20px;
  border: 0;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  /* Clear of the sticky month title when the keyboard walks up the list. */
  scroll-margin-top: 48px;
}
.date-picker__row:hover { background: var(--tint); }
.date-picker__when strong {
  color: var(--navy);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}
.date-picker__name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.date-picker__days {
  color: var(--navy-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.date-picker__check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
}
.date-picker__row.is-selected,
.date-picker__row.is-selected:hover {
  background: var(--tint-warm);
}
.date-picker__row.is-selected .date-picker__check {
  background:
    no-repeat center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%2318120a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    var(--brand);
}

/* ── Foot ─────────────────────────────────────────────────────────────── */
.date-picker__foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: #fff;
}
.date-picker__hint {
  margin: 0;
  color: var(--navy-soft);
  font-size: 14px;
  line-height: 1.3;
}
.date-picker__cancel {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.date-picker__cancel:hover { background: var(--tint); }

.date-picker button:focus { outline: none; }
.date-picker button:focus-visible,
.date-picker__filter-select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}
.date-picker__close:focus-visible,
.date-picker__filter-select:focus-visible {
  outline-color: #fff;
  outline-offset: 2px;
}
.date-picker-pointer .date-picker button:focus-visible { outline: none; }

/* ── Phone: the whole screen, with the tour's length under its name ──────── */
@media (max-width: 560px), (max-height: 560px) {
  .date-picker {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    inset: 0;
  }
}
/* A phone on its side: the list needs every line the head can give up. */
@media (max-height: 560px) and (min-width: 561px) {
  .date-picker__head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 6px 16px;
  }
  .date-picker__title { font-size: 16px; }
  .date-picker__summary { margin-top: 0; font-size: 13px; }
  .date-picker__filter { grid-column: 2; grid-row: 1; }
  .date-picker__filter-label { display: none; }
  .date-picker__close { grid-column: 3; margin: 0 -8px 0 0; }
  .date-picker__months { padding: 4px 10px; }
  .date-picker__tab { min-height: 44px; padding: 2px 8px; }
  .date-picker__hint { display: none; }
  .date-picker__foot { justify-content: flex-end; padding: 4px 16px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
}
/* Safari's own bars can leave 283px (iPhone 17 with a tab bar, measured): one row,
 * until the title the month bar repeats and the foot the close button repeats go. */
@media (max-height: 340px) and (min-width: 561px) {
  .date-picker__month-title,
  .date-picker__foot { display: none; }
}
@media (max-width: 560px) {
  .date-picker__head { padding: 14px 16px 12px; gap: 10px 12px; }
  .date-picker__title { font-size: 18px; }
  .date-picker__months { padding: 8px 10px; }
  .date-picker__tab { min-width: 58px; padding: 4px 8px; }
  .date-picker__month-title { padding: 10px 16px; }
  .date-picker__row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "when check"
      "name check"
      "days check";
    gap: 2px 12px;
    min-height: 64px;
    padding: 10px 16px;
  }
  .date-picker__when { grid-area: when; }
  .date-picker__name { grid-area: name; }
  .date-picker__days { grid-area: days; }
  .date-picker__days:empty { display: none; }
  .date-picker__check { grid-area: check; }
  .date-picker__foot { padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .date-picker__hint { font-size: 13px; }
}
