/* The dashboard date range picker with presets and comparison: the period button of Halcyon Analytics, on white.
   A white panel with a 1px edge that catches the light, layered soft shadows and a very fine grain; one accent, iris,
   for the band of the range; green and coral only for the change against the period before. */
:root {
  --page: #ffffff;              /* the page */
  --surface: #ffffff;           /* the panel and the button */
  --rail: #f6f6fa;              /* the column of the presets */
  --ink: #16172a;               /* the words */
  --muted: #8b8da3;             /* the small words */
  --faint: #c9cad8;             /* the days still to come */
  --line: rgba(22, 24, 52, 0.08); /* the 1px edges */
  --accent: #5b4ff5;            /* the one accent: iris, the ends of the range */
  --accent-deep: #3a2fc4;       /* the numbers inside the band */
  --band: rgba(91, 79, 245, 0.11); /* the band of the range */
  --up: #138a52;                /* the period grew */
  --down: #d24b3c;              /* the period shrank */
  --prev: #d9dae6;              /* the bar of the period before */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 10px 2vw;
  overflow: hidden;
}

/* the picker is the container: the panel changes layout with its width */
.picker {
  position: relative;
  width: min(744px, 96vw);
  container-type: inline-size;
  opacity: 0;
}

/* ---------------------------------------------------------------- the button */
.trigger {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 13px;
  -webkit-tap-highlight-color: transparent;
}

.trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* the body is GSAP's (press), the button is the hit area */
.trigger__body {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 12px 0 13px;
  border-radius: 13px;
  background: linear-gradient(180deg, #ffffff, #fafafd);
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 0 #fff,
    0 1px 1px rgba(22, 24, 52, 0.05),
    0 3px 8px -3px rgba(22, 24, 52, 0.1),
    0 0 0 0 rgba(91, 79, 245, 0);
  font-size: 13.5px;
  font-weight: 560;
  letter-spacing: -0.005em;
  transition: box-shadow 0.35s ease;
}

.trigger[aria-expanded='true'] .trigger__body {
  box-shadow:
    inset 0 0 0 1px rgba(91, 79, 245, 0.42),
    inset 0 1px 0 #fff,
    0 1px 1px rgba(22, 24, 52, 0.05),
    0 3px 8px -3px rgba(22, 24, 52, 0.1),
    0 0 0 4px rgba(91, 79, 245, 0.12);
}

@media (hover: hover) {
  .trigger:hover .trigger__body {
    box-shadow:
      inset 0 0 0 1px rgba(22, 24, 52, 0.13),
      inset 0 1px 0 #fff,
      0 1px 1px rgba(22, 24, 52, 0.05),
      0 6px 14px -5px rgba(22, 24, 52, 0.16),
      0 0 0 0 rgba(91, 79, 245, 0);
  }

  .trigger[aria-expanded='true']:hover .trigger__body {
    box-shadow:
      inset 0 0 0 1px rgba(91, 79, 245, 0.5),
      inset 0 1px 0 #fff,
      0 1px 1px rgba(22, 24, 52, 0.05),
      0 6px 14px -5px rgba(22, 24, 52, 0.16),
      0 0 0 4px rgba(91, 79, 245, 0.14);
  }
}

.trigger__cal {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.trigger__cal-fill {
  fill: var(--accent);
  stroke: none;
}

.trigger__sep {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.trigger__range {
  color: var(--muted);
  font-weight: 480;
}

.trigger__chev {
  width: 16px;
  height: 16px;
  margin-left: 1px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- rolling words */
.roll {
  position: relative;
  display: inline-flex;
  overflow: hidden;
  white-space: pre;
  vertical-align: top;
  line-height: 1.25;
  /* a little room above and below, so the letters can roll in without being cut while still */
  padding: 0.06em 0;
  margin: -0.06em 0;
}

.roll__line {
  display: inline-flex;
  white-space: pre;
}

.roll__line--out {
  position: absolute;
  left: 0;
  top: 0.06em;
}

.roll__ch {
  display: inline-block;
  white-space: pre;
}

/* ---------------------------------------------------------------- the panel */
.panel {
  --cell: min(34px, 5vh, calc((100cqw - 230px) / 14.6));
  position: relative;
  display: grid;
  grid-template-columns: 150px 1fr;
  grid-template-areas:
    'presets months'
    'foot foot';
  margin-top: 10px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 0 #fff,
    0 1px 2px rgba(22, 24, 52, 0.05),
    0 10px 22px -10px rgba(22, 24, 52, 0.14),
    0 34px 70px -22px rgba(48, 40, 150, 0.26);
  opacity: 0;
  visibility: hidden;
  transform-origin: 22px -8px;
  font-size: 13px;
}

.panel.is-open {
  visibility: visible;
}

/* a very fine grain on the white, so it reads as a surface and not as an empty box */
.panel__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.45 0 0 0 0 0.55 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- the presets */
.presets {
  grid-area: presets;
  position: relative;
  margin: 0;
  padding: 12px 8px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 18px 0 0 0;
  background: linear-gradient(180deg, var(--rail), rgba(246, 246, 250, 0.4));
  box-shadow: inset -1px 0 0 var(--line);
}

.presets__item {
  position: relative;
  z-index: 1;
}

.presets__item--custom {
  margin-top: auto;
  padding-top: 6px;
}

.preset {
  display: flex;
  align-items: center;
  width: 100%;
  height: 31px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: #4a4c63;
  font-size: 13px;
  font-weight: 470;
  text-align: left;
  cursor: pointer;
  transition: color 0.25s ease, font-weight 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.preset--custom {
  cursor: default;
  color: var(--faint);
}

.preset.is-on {
  color: var(--ink);
  font-weight: 620;
}

.preset--custom.is-on {
  color: var(--accent-deep);
}

@media (hover: hover) {
  button.preset:hover {
    color: var(--ink);
  }
}

.preset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.preset__short {
  display: none;
}

/* the raised pill under the chosen preset: it slides on a spring */
.presets__pill {
  position: absolute;
  left: 8px;
  top: 0;
  width: calc(100% - 16px);
  height: 31px;
  border-radius: 9px;
  background: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(22, 24, 52, 0.07),
    inset 0 1px 0 #fff,
    0 1px 2px rgba(22, 24, 52, 0.06),
    0 4px 10px -4px rgba(48, 40, 150, 0.18);
  z-index: 0;
  pointer-events: none;
}

.presets__pill::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---------------------------------------------------------------- the months */
.months {
  grid-area: months;
  display: flex;
  justify-content: center;
  gap: calc(var(--cell) * 0.7);
  padding: 12px 16px 10px;
}

.month__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--cell) * 0.9);
}

.month__name {
  font-weight: 620;
  font-size: 13px;
  letter-spacing: -0.005em;
}

.month__nav {
  position: absolute;
  left: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.month__nav--next {
  left: auto;
  right: 0;
}

.month__nav svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #4a4c63;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.month__nav:disabled {
  opacity: 0.3;
  cursor: default;
}

@media (hover: hover) {
  .month__nav:not(:disabled):hover {
    background: var(--rail);
  }
}

.month__nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.month__week {
  display: grid;
  grid-template-columns: repeat(7, var(--cell));
  height: calc(var(--cell) * 0.66);
  align-items: center;
  color: var(--muted);
  font-size: calc(var(--cell) * 0.31);
  font-weight: 520;
  text-align: center;
}

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, var(--cell));
  grid-template-rows: repeat(6, var(--cell));
}

/* the band: one strip per week, under the numbers */
.band {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.band__strip {
  position: absolute;
  left: 0;
  top: 0;
  height: calc(var(--cell) - 4px);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 45%),
    var(--band);
  box-shadow: inset 0 0 0 1px rgba(91, 79, 245, 0.06);
  visibility: hidden;
}

/* the wet head of the brush: a soft light right where the band is growing */
.band__head {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--cell) * 1.4);
  height: calc(var(--cell) - 4px);
  margin-left: calc(var(--cell) * -1.4);
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, rgba(91, 79, 245, 0), rgba(91, 79, 245, 0.2) 70%, rgba(130, 120, 255, 0.42));
  opacity: 0;
  visibility: hidden;
}

/* the two ends of the range: solid iris tiles */
.band__cap {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--cell) - 4px);
  height: calc(var(--cell) - 4px);
  margin: 2px;
  border-radius: 9px;
  background: linear-gradient(180deg, #6d62ff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 0 0 1px rgba(40, 30, 160, 0.25),
    0 2px 6px -2px rgba(70, 58, 230, 0.55);
  visibility: hidden;
}

.day {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font-size: calc(var(--cell) * 0.38);
  font-weight: 450;
  font-variation-settings: 'wdth' 100;
  cursor: pointer;
  transition: color 0.22s ease, font-weight 0.22s ease, font-variation-settings 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

/* today: a thin ring, nothing filled */
.day--today::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(91, 79, 245, 0.45);
  pointer-events: none;
}

.day:disabled {
  color: var(--faint);
  cursor: default;
}

.day.is-in {
  color: var(--accent-deep);
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
}

.day.is-end {
  color: #fff;
  font-weight: 640;
}

@media (hover: hover) {
  .day:not(:disabled):not(.is-in):hover {
    background: var(--rail);
  }
}

.day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------------------------------------------------------------- the foot */
.foot {
  grid-area: foot;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 12px 14px 12px 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(246, 246, 250, 0.7), rgba(255, 255, 255, 0));
  border-radius: 0 0 18px 18px;
}

.sum p,
.cmp p {
  margin: 0;
}

.sum__main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.sum__dot {
  color: var(--faint);
}

.sum__vs {
  margin-top: 2px !important;
  color: var(--muted);
  font-size: 12px;
}

.cmp__top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.cmp__label {
  color: var(--muted);
}

.cmp__value {
  font-weight: 640;
  font-size: 13.5px;
  letter-spacing: -0.005em;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px 0 5px;
  border-radius: 6px;
  background: rgba(19, 138, 82, 0.1);
  color: var(--up);
  font-size: 11.5px;
  font-weight: 620;
  transition: background 0.35s ease, color 0.35s ease;
}

.delta.is-down {
  background: rgba(210, 75, 60, 0.1);
  color: var(--down);
}

.delta__arrow {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bars {
  display: grid;
  gap: 4px;
  margin-top: 7px;
}

.bars__track {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(22, 24, 52, 0.04);
  overflow: hidden;
}

.bars__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  border-radius: 3px;
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.bars__fill--now {
  background: linear-gradient(90deg, #8f86ff, var(--accent));
  box-shadow: inset -2px 0 0 rgba(255, 255, 255, 0.55);
}

.bars__fill--prev {
  background: var(--prev);
}

.acts {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn__face {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
}

.btn--ghost .btn__face {
  color: #4a4c63;
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 1px rgba(22, 24, 52, 0.04);
  background: #fff;
}

.btn--main .btn__face {
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(180deg, #2a2b45, #16172a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(22, 24, 52, 0.2),
    0 6px 14px -6px rgba(22, 24, 52, 0.45);
}

/* a light that crosses the Apply button when the range changes */
.btn__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  transform: translateX(-100%);
  pointer-events: none;
}

@media (hover: hover) {
  .btn--ghost:hover .btn__face {
    color: var(--ink);
  }

  .btn--main:hover .btn__face {
    background: linear-gradient(180deg, #34355a, #1c1d35);
  }
}

/* ---------------------------------------------------------------- narrow: chips on top, compact months */
@container (max-width: 560px) {
  .trigger__body {
    height: 38px;
    gap: 7px;
    font-size: 12.5px;
  }

  .panel {
    --cell: min(32px, 5.4vh, calc((100cqw - 26px) / 14.5));
    grid-template-columns: 1fr;
    grid-template-areas:
      'presets'
      'months'
      'foot';
    margin-top: 8px;
    border-radius: 16px;
  }

  .presets {
    flex-direction: row;
    gap: 2px;
    margin: 10px 10px 0;
    padding: 3px;
    border-radius: 10px;
    background: var(--rail);
    box-shadow: inset 0 0 0 1px rgba(22, 24, 52, 0.05);
  }

  .presets__item {
    flex: 1;
  }

  .presets__item--wide,
  .presets__item--custom {
    display: none;
  }

  .preset {
    justify-content: center;
    height: 26px;
    padding: 0 4px;
    font-size: 11.5px;
    border-radius: 7px;
  }

  .preset__long {
    display: none;
  }

  .preset__short {
    display: inline;
  }

  .presets__pill {
    left: 0;
    top: 3px;
    height: 26px;
    border-radius: 7px;
  }

  .presets__pill::before {
    display: none;
  }

  .months {
    gap: calc(var(--cell) * 0.5);
    padding: 8px 8px 6px;
  }

  .month__name {
    font-size: 11.5px;
  }

  .month__nav {
    width: 22px;
    height: 22px;
    margin-top: -11px;
  }

  .day--today::after,
  .band__cap,
  .day {
    border-radius: 6px;
  }

  .foot {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'sum acts'
      'cmp cmp';
    gap: 8px 10px;
    padding: 9px 10px 10px 12px;
    border-radius: 0 0 16px 16px;
  }

  .sum {
    grid-area: sum;
  }

  .cmp {
    grid-area: cmp;
  }

  .acts {
    grid-area: acts;
    gap: 6px;
  }

  .sum__main {
    font-size: 12.5px;
    gap: 4px;
  }

  .sum__vs {
    font-size: 10.5px;
  }

  .cmp__top {
    font-size: 11px;
  }

  .cmp__value {
    font-size: 12px;
  }

  .bars {
    margin-top: 5px;
  }

  .btn__face {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  .btn--main .btn__face {
    padding: 0 12px;
  }
}

@container (max-width: 400px) {
  .trigger__sep,
  .trigger__range {
    display: none;
  }
}

/* ---------------------------------------------------------------- the drawn pointer */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(22, 24, 52, 0.32));
}

.hand path {
  fill: #16172a;
  stroke: #fff;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .day,
  .preset,
  .delta,
  .trigger__body {
    transition: color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  }
}
