/*! wheel.css 1.0.0 | DJ2000-UK/app-workbench */
/* The date wheel (wheel/wheel.js), as on an iPhone: three rolling wheels behind
   one rounded band, and the field that holds it: a row with its name and the day
   on a pill, the wheel opening under it. Every colour is one of the app's own
   tokens (--ink, --muted-bright, --muted, --accent or --accent-rgb), so it follows
   the palette in Kaizen, Shinpo, Hokyu and djcns.css alike.

   An app may set, on .wheel or on anything round it:
     --wheel-row      the height of a row (34 px)
     --wheel-height   the wheel's height (204 px: the band and two and a half rows each side)
     --wheel-font     the rows' size (20 px)
     --wheel-accent   the pill's colour while its wheel is open (the palette's accent)
     --wheel-band     the band's fill
     --wheel-radius   the band's and the pill's corners (10 px) */

.wheel {
  position: relative;
  display: grid;
  box-sizing: border-box;
  height: var(--wheel-height, 204px);
  min-width: 0;
  padding-inline: 6px;
  grid-template-columns: var(--wheel-columns, minmax(0, 2fr) minmax(0, 4.4fr) minmax(0, 2.8fr));
  gap: 2px;
  color: var(--ink);
  font-size: var(--wheel-font, 20px);
  font-variant-numeric: tabular-nums;
  line-height: var(--wheel-row, 34px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* The band the chosen day rests in, behind every wheel at once. */
.wheel__band {
  position: absolute;
  top: calc(50% - var(--wheel-row, 34px) / 2);
  right: 0;
  left: 0;
  height: var(--wheel-row, 34px);
  border-radius: var(--wheel-radius, 10px);
  background: var(--wheel-band, color-mix(in srgb, var(--ink) 10%, transparent));
  pointer-events: none;
}

/* One wheel: the browser's own scrolling, stopping on a row. */
.wheel__col {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  touch-action: pan-y;
  border-radius: var(--wheel-radius, 10px);
  outline: none;
}
.wheel__col::-webkit-scrollbar { display: none; }
.wheel__col:focus-visible { box-shadow: inset 0 0 0 2px var(--wheel-accent, var(--accent, rgb(var(--accent-rgb)))); }

/* Room above the first row and below the last, so each can rest in the band. */
.wheel__list { padding-block: calc((var(--wheel-height, 204px) - var(--wheel-row, 34px)) / 2); }

.wheel__item {
  height: var(--wheel-row, 34px);
  overflow: hidden;
  color: var(--muted-bright);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  scroll-snap-align: center;
  cursor: default;
}
.wheel__item.is-centre { color: var(--ink); }
/* A day the month does not have, or one outside the range: still there, greyed out. */
.wheel__item.is-off { color: color-mix(in srgb, var(--muted) 55%, transparent); }

/* The field: its name, and the day on a pill that opens the wheel. */
.wheel-field { display: grid; min-width: 0; }
.wheel-field__row {
  display: flex;
  min-width: 0;
  min-height: var(--target, 44px);
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.wheel-field__label {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-bright);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wheel-field__value {
  flex: 0 0 auto;
  min-height: var(--target, 44px);
  max-width: 70%;
  padding: 0 14px;
  overflow: hidden;
  border: 0;
  border-radius: var(--wheel-radius, 10px);
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.wheel-field.is-open .wheel-field__value {
  background: color-mix(in srgb, var(--wheel-accent, var(--accent, rgb(var(--accent-rgb)))) 16%, transparent);
  color: var(--wheel-accent, var(--accent, rgb(var(--accent-rgb))));
}

/* The wheel under the row: shut until the pill opens it. */
.wheel-field__drawer {
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.32s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.2s ease;
}
.wheel-field.is-open .wheel-field__drawer {
  height: calc(var(--wheel-height, 204px) + 8px);
  opacity: 1;
}
.wheel-field__drawer > .wheel { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .wheel-field__drawer, .wheel-field__value { transition: none; }
}
