/*
 * Travel date range picker (public/js/date-range.js). Uses the site tokens from
 * partials/theme-styles; loaded only where the trip search appears.
 */

[data-date-range] {
  position: relative;
}

.search-field--date .search-date-input {
  caret-color: transparent;
}

.dr-pop {
  position: absolute;
  top: calc(100% + 18px);
  left: -12px;
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 18px 18px 14px;
  background: var(--white, #fff);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px -18px rgba(16, 33, 58, 0.35);
  text-align: left;
}

.dr-backdrop {
  display: none;
}

.dr-head {
  display: none;
}

.dr-body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 4px;
}

.dr-months {
  display: flex;
  justify-content: center;
  gap: 28px;
}

.dr-nav,
.dr-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white, #fff);
  color: var(--blue);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.dr-nav:hover:not(:disabled) {
  border-color: var(--blue);
}

.dr-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.dr-month {
  width: 280px;
}

.dr-month-name {
  margin: 8px 0 12px;
  text-align: center;
  font-weight: 700;
  color: var(--blue);
}

.dr-week,
.dr-grid {
  display: grid;
  grid-template-columns: repeat(7, 40px);
}

.dr-week span {
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.dr-empty {
  height: 40px;
}

.dr-day {
  position: relative;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.dr-day span {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 38px;
  margin: 1px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background-color 0.15s ease;
}

.dr-day:hover:not(:disabled):not(.is-start):not(.is-end) span {
  background: var(--accent-soft, #e8f0fb);
}

.dr-day:focus-visible {
  outline: none;
}

.dr-day:focus-visible span {
  box-shadow: 0 0 0 2px var(--blue);
}

.dr-day:disabled {
  color: var(--muted);
  opacity: 0.4;
  cursor: default;
}

.dr-day.is-today span {
  box-shadow: inset 0 0 0 1.5px var(--blue);
}

/* Range band behind the days, rounded at the ends. */
.dr-day.is-range::before,
.dr-day.is-start.has-end::before,
.dr-day.is-end::before {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 0;
  right: 0;
  background: var(--accent-soft, #e8f0fb);
}

.dr-day.is-start.has-end::before {
  left: 50%;
}

.dr-day.is-end::before {
  right: 50%;
}

.dr-day.is-start span,
.dr-day.is-end span {
  background: var(--blue);
  color: var(--white, #fff);
  font-weight: 700;
}

.dr-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dr-quick button {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white, #fff);
  color: var(--blue);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.dr-quick button:hover {
  border-color: var(--blue);
}

.dr-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.dr-summary {
  flex: 1;
  min-width: 0;
  /* The hint grows once a date is picked; wrap it instead of widening the popup. */
  contain: inline-size;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.dr-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.dr-clear,
.dr-done {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.dr-clear {
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
}

.dr-done {
  border: 0;
  background: var(--blue);
  color: var(--white, #fff);
}

/* Phones: bottom sheet with one month. */
@media (max-width: 640px) {
  .dr-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 59;
    background: rgba(16, 33, 58, 0.45);
  }

  .dr-backdrop[hidden] {
    display: none;
  }

  .dr-pop {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .dr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .dr-title {
    margin: 0;
    font-weight: 700;
    color: var(--blue);
  }

  .dr-close {
    font-size: 1.5rem;
  }

  .dr-month {
    width: 100%;
  }

  .dr-week,
  .dr-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .dr-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .dr-actions {
    justify-content: space-between;
  }

  .dr-done {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dr-day span {
    transition: none;
  }
}
