/* The date range picker with the liquid band you pull by its ends */

:root {
  --bg: #000000;
  --card: #0d0e10;
  --card-2: #121316;
  --line: rgba(255, 255, 255, 0.075);
  --edge: rgba(255, 255, 255, 0.16);
  --ink: #f2f3f5;
  --muted: #8b8f98;
  --faint: #4b4f57;
  --accent: #2fd9b0;      /* the liquid */
  --accent-hi: #8ff5da;   /* the top of the liquid, where the light catches it */
  --on-accent: #03140f;   /* the numbers under the liquid */
  --bar: #26282d;
  /* one day of the grid: measured on the height too, so the card fits the phone box */
  --cell: clamp(30px, min(11.4vw, 9.1vh), 46px);
  --gap: calc(var(--cell) * 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.picker {
  --pad: calc(var(--cell) * 0.42);
  position: relative;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) * 0.8);
  border-radius: calc(var(--cell) * 0.46);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(143, 245, 218, 0.05), transparent 60%),
    linear-gradient(180deg, var(--card-2), var(--card));
  box-shadow:
    inset 0 1px 0 var(--edge),
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 12px 30px -10px rgba(0, 0, 0, 0.8),
    0 40px 80px -30px rgba(47, 217, 176, 0.12);
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* the finest grain on the card */
.picker::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.05;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.picker__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 calc(var(--cell) * 0.08) calc(var(--cell) * 0.3);
}

.picker__title,
.picker__total {
  display: flex;
  flex-direction: column;
  gap: calc(var(--cell) * 0.05);
}

.picker__total { align-items: flex-end; }

.picker__eyebrow,
.picker__unit {
  font-size: calc(var(--cell) * 0.24);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.picker__month {
  font-size: calc(var(--cell) * 0.4);
  font-weight: 620;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.picker__sessions {
  font-size: calc(var(--cell) * 0.4);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- weekdays and days */
.week,
.days {
  display: grid;
  grid-template-columns: repeat(7, var(--cell));
  gap: var(--gap);
}

.week {
  padding-bottom: calc(var(--cell) * 0.1);
}

.week span {
  text-align: center;
  font-size: calc(var(--cell) * 0.24);
  font-weight: 500;
  color: var(--faint);
}

.week .is-we { color: #3a3d44; }

.grid {
  position: relative;
  touch-action: none;
}

.liquid {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.stop-hi { stop-color: var(--accent-hi); }
.stop-lo { stop-color: var(--accent); }

.liquid__glow {
  fill: var(--accent);
  opacity: 0.32;
}

.day {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.day__n {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: calc(var(--cell) * 0.33);
  font-weight: 460;
  font-variant-numeric: tabular-nums;
  font-stretch: 100%;
  transition: color 0.22s ease, font-weight 0.3s ease, font-stretch 0.3s ease;
}

.day.is-we .day__n { color: var(--muted); }

.day.is-in .day__n {
  color: var(--on-accent);
  font-weight: 560;
}

.day.is-end .day__n {
  color: var(--on-accent);
  font-weight: 720;
  font-stretch: 112%;
}

/* the ring of the day under the pointer, and of the focused one */
.day::before {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0);
  transition: box-shadow 0.2s ease;
  pointer-events: none;
}

.day:focus-visible::before { box-shadow: inset 0 0 0 1.5px var(--accent-hi); }

@media (hover: hover) {
  .day:hover::before { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
  .day.is-in:hover::before,
  .day.is-end:hover::before { box-shadow: inset 0 0 0 1px rgba(3, 20, 15, 0.25); }
  .day.is-end { cursor: ew-resize; }
}

.grid.is-dragging .day { cursor: grabbing; }

/* ---------------------------------------------------------------- the bars of the daily sessions */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: calc(var(--cell) * 0.62);
  margin: calc(var(--cell) * 0.28) calc(var(--cell) * 0.06) 0;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}

.bar {
  flex: 1;
  border-radius: 2px 2px 1px 1px;
  background: var(--bar);
  transform-origin: 50% 100%;
}

.bar__lit {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  opacity: 0;
}

/* ---------------------------------------------------------------- the summary */
.picker__foot {
  display: flex;
  align-items: baseline;
  gap: calc(var(--cell) * 0.16);
  padding: calc(var(--cell) * 0.26) calc(var(--cell) * 0.08) 0;
  font-size: calc(var(--cell) * 0.33);
  font-weight: 560;
  letter-spacing: -0.005em;
}

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

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

/* a label whose letters roll one by one */
.roll {
  display: inline-flex;
  white-space: pre;
  line-height: 1.15;
}

.roll .ch {
  position: relative;
  display: inline-block;
  height: 1.15em;
  overflow: hidden;
  vertical-align: top;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
}

.roll .ch__in {
  display: inline-block;
}

.roll .ch__in + .ch__in {
  position: absolute;
  left: 0;
  top: 0;
}

/* ---------------------------------------------------------------- the drawn pointer of the autopilot */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -3px 0 0 -5px;
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .day__n { transition: color 0.3s ease; }
  .hand { display: none; }
}
