/* dates (AGENDA.leo): the free-days calendar. Also holds the styles of ui/calendar.js (.cal), which only this
   screen uses. Every selector is prefixed .scr-dates. */

/* ---------- window layout: padded head + full-bleed calendar + padded foot ---------- */
/* Room below the window, so the last controls can scroll clear of Henk AND a three-line speech bubble
   (he sits just above the nav, and his bubble takes taps: a control under it is dead while he talks).
   At full scroll Henk then stands in the free space under the window. */
.scr-dates .dates-win { margin-bottom: 84px; }
.scr-dates .dates-win .win__body > * + * { margin-top: 0; }

.scr-dates .dates-head {
  padding: 14px 14px 12px;
}

.scr-dates .dates-head .q-sub { margin-top: 4px; }

.scr-dates .dates-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px 16px;
  font-size: var(--fs-m); /* the em in the chips breakpoint below (follows LEESBRIL) */
  container-type: inline-size;
}

/* ---------- calendar ---------- */
.scr-dates .cal {
  background: var(--ink);
  border-top: var(--bw) solid var(--ink);
  border-bottom: var(--bw) solid var(--ink);
}

.scr-dates .cal__tabs {
  display: grid;
  grid-auto-flow: column; /* one equal tab per month in CONFIG.TRIP_WINDOW */
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--bw);
}

.scr-dates .cal__tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: var(--tap);
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: var(--fs-s);
  line-height: 1;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--shade);
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.scr-dates .cal__tab svg { flex: none; }
.scr-dates .cal__tab:active { background: var(--lav-l); }

.scr-dates .cal__tab.is-active {
  background: var(--lav);
  /* a 3px inner line along the bottom keeps the tab "pressed in" like the title bars */
  box-shadow: inset 0 -3px 0 0 var(--lav-d);
}

.scr-dates .cal__tab-label { white-space: nowrap; }
.scr-dates .cal__tab:not(.is-active) .cal__tab-label { color: var(--ink); opacity: 0.75; }

/* Days picked in that month: a notification badge on the tab's corner (like the bell's). It sits outside the
   tab's flow, so the label never wraps and the calendar never moves when the first day of a month is picked. */
.scr-dates .cal__badge {
  position: absolute;
  top: -11px;
  right: 3px;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 3px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1;
  background: var(--pink);
  border: 2px solid var(--ink);
}

.scr-dates .cal__head,
.scr-dates .cal__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(40px, 1fr));
  gap: var(--bw);
  margin-top: var(--bw);
}

.scr-dates .cal__wd {
  display: grid;
  place-items: center;
  height: 26px;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  line-height: 1;
  text-transform: uppercase;
  background: var(--paper);
}

.scr-dates .cal__wd.is-weekend { background: var(--lav-l); }

.scr-dates .cal__grid {
  grid-auto-rows: 44px;
  /* an up/down swipe scrolls the page (the browser cancels the pointer); a sideways drag paints days */
  touch-action: pan-y;
}

.scr-dates .cal__day,
.scr-dates .cal__pad {
  position: relative;
  min-width: 0;
}

.scr-dates .cal__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-s);
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  touch-action: pan-y;
}

.scr-dates .cal__day > * { pointer-events: none; }
.scr-dates .cal__day.is-weekend { background: var(--lav-l); }

.scr-dates .cal__pad {
  background: var(--wall);
}

/* chosen: a filled pink cell with a white pixel heart */
.scr-dates .cal__heart { display: none; }
.scr-dates .cal__day.is-on { background: var(--pink); }
.scr-dates .cal__day.is-on .cal__heart { display: block; }

/* holidays (25/26 dec, 1 jan): a small star in the corner */
.scr-dates .cal__icon {
  position: absolute;
  top: 2px;
  right: 2px;
}

/* today: dashed selection box */
.scr-dates .cal__day.is-today::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px dashed var(--ink);
  pointer-events: none;
}

/* past days (or outside the trip window): a 50% dither, the way old OS's greyed things out */
.scr-dates .cal__day.is-disabled {
  color: var(--lav-d);
  background: conic-gradient(var(--shade) 25%, var(--paper) 0 50%, var(--shade) 0 75%, var(--paper) 0) 0 0 / 6px 6px;
  cursor: not-allowed;
}

.scr-dates .cal__day.is-disabled.is-on { background: var(--pink-l); }
.scr-dates .cal__day.is-disabled .cal__icon { opacity: 0.5; }

.scr-dates .cal__day:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: -6px;
}

/* choppy motion: the heart pops in, a month switch flickers in */
.scr-dates .cal__day.cal-pop .cal__heart { animation: dates-pop calc(250ms / var(--speed)) steps(3) both; }
.scr-dates .cal__grid.cal-flip { animation: dates-flip calc(250ms / var(--speed)) steps(3) both; }

@keyframes dates-pop {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes dates-flip {
  0% { opacity: 0.25; transform: translateX(6px); }
  100% { opacity: 1; transform: none; }
}

/* ---------- live summary: an OS status line ----------
   Always two lines tall (longer lists are clipped with "…"; screen readers still get all of it): the chips right
   below never jump when it changes, e.g. "Alle weekenden" would otherwise push them down three lines at once. */
.scr-dates .dates-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(2 * 1.3em + 16px + 2 * var(--bw));
  margin: 0;
  padding: 8px 10px;
  font-size: var(--fs-m);
  line-height: 1.3;
  background: var(--pink-l);
  border: var(--bw) solid var(--ink);
}

.scr-dates .dates-summary__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  min-width: 0;
}
.scr-dates .dates-summary__count { font-weight: 700; }
.scr-dates .dates-summary__range { white-space: nowrap; }
.scr-dates .dates-summary.is-empty { background: var(--shade); }
.scr-dates .dates-summary.is-empty .dates-summary__heart { opacity: 0.35; }

/* ---------- quick-pick chips ---------- */
.scr-dates .dates-chips {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "holiday holiday"
    "weekends clear"
    "all all";
  gap: 10px 8px;
}

.scr-dates .dates-chip {
  min-height: var(--tap);
  min-width: 0;
  padding: 6px 10px;
  text-align: left;
}

.scr-dates .dates-chip svg,
.scr-dates .dates-chip__icon { flex: none; }
.scr-dates .dates-chip__icon { display: flex; }
.scr-dates .dates-chip__label { min-width: 0; }
.scr-dates .dates-chip__nowrap { white-space: nowrap; } /* "(19 dec–3 jan)" stays on one line */

/* "Wissen" / "Toch niet" stacked in one cell: the chip is always as wide as the longer one */
.scr-dates .dates-steady {
  display: inline-grid;
  place-items: center start;
}

.scr-dates .dates-steady > * {
  grid-area: 1 / 1;
  visibility: hidden;
}

.scr-dates .dates-steady > .is-shown { visibility: visible; }
.scr-dates .dates-chip__icon.dates-steady { place-items: center; }
.scr-dates .dates-chip--holiday { grid-area: holiday; }
.scr-dates .dates-chip--weekends { grid-area: weekends; }
.scr-dates .dates-chip--clear { grid-area: clear; }
.scr-dates .dates-chip--all { grid-area: all; }

/* Too narrow for "Alle weekenden" next to "Toch niet" (320 px with LEESBRIL): Wissen gets its own row.
   Measured: the pair needs 114 px + 9.75 chip-em, which is 8.67em of the foot's --fs-m. */
@container (max-width: calc(114px + 8.67em)) {
  .scr-dates .dates-chips {
    grid-template-areas:
      "holiday holiday"
      "weekends weekends"
      "all all"
      ". clear";
  }
}
.scr-dates .dates-chip[disabled] svg { opacity: 0.4; }
/* a pressed chip is pink: its pink icon turns white so it doesn't disappear */
.scr-dates .dates-chip[aria-pressed="true"] svg path[fill="#F8A6D4"] { fill: var(--paper); }

/* ---------- mode switch ---------- */
.scr-dates .dates-divider { margin: 2px 0; }
.scr-dates .dates-mode__label { margin: 0; }

.scr-dates .dates-mode .seg__opt {
  min-width: 0;
  min-height: var(--tap);
  padding: 4px 6px;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

/* Narrow phones (under 360 px, e.g. the first iPhone SE at 320 px): slimmer side gutters keep the cells at
   40 px; anything narrower still lets them shrink instead of scrolling sideways. */
@media (max-width: 359px) {
  .scr-dates.screen {
    padding-left: 6px;
    padding-right: 6px;
  }

  .scr-dates .cal__head,
  .scr-dates .cal__grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }

  .scr-dates .cal__tab {
    gap: 6px;
    padding: 4px 6px;
    font-size: var(--fs-xs);
  }
}
