/* ══ Rolling counter ═════════════════════════════════════
   Bencho's slab, fitted to Borhe. Tokens are mapped on the
   component root so they do not leak into the page.
   --card / --fill-slab  surface the keys sit on
   --fill-on / --ink     text and icon ink
   --font-ui             the UI face already in use
   --pane-edge           the field's hairline
   --signal              focus, the theme's primary / ring

   The repeat row's other control is a 54px pill. The counter
   fills that pill and centers a 32px key in it. The key corner
   is 16px, a circle. Admin fields keep the 10px field radius;
   their keys step down to 6px. Neither size uses 8 or 12. */

.rct {
  --card: var(--color-surface, var(--surface, #ffffff));
  --fill-slab: var(--color-input-bg, var(--surface, #ffffff));
  --fill-on: var(--color-text, var(--text, #17181a));
  --ink: var(--fill-on);
  --pane-edge: var(--color-border, var(--border, rgba(23, 24, 26, 0.16)));
  --signal: var(--color-primary, var(--ring, #1b787a));
  --font-ui: var(--app-font-family, inherit);
  --rct-r: 10px;
  --rct-in: 6px;
  --rct-cell: 32px;
  font-family: var(--font-ui);
  /* `* { direction: rtl }` sets direction on every element, so
     ltr on this root does not reach the digits. Each descendant
     has to be ltr or ۱۲ paints as ۲۱. */
  direction: ltr;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  box-sizing: border-box;
  /* 4px round each key, and the corner is the box's less that
     same 4, so the keys sit concentric in it */
  padding: 4px;
  border-radius: var(--rct-r);
  background: var(--fill-slab, var(--card));
  color: var(--fill-on, var(--ink));
  user-select: none;
}

.rct * { direction: ltr; }

[data-stroke="on"] .rct { box-shadow: 0 0 0 1px var(--pane-edge); }

.rct-host {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.rct--field {
  width: 100%;
  height: 42px;
  border: 1px solid var(--pane-edge);
}

.rct--field:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--color-primary-soft, color-mix(in srgb, var(--signal) 18%, transparent));
}

.rct--field.is-invalid {
  border-color: var(--color-danger, #dc2626);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger, #dc2626) 15%, transparent);
}

/* The field box is the 54px pill. This fills its content box
   and centers the keys, so they share the unit label's midline. */
.task-repeat-field .rct-host { height: 100%; }

.rct--modal {
  --rct-r: var(--radius-2xl, 24px);
  --rct-in: var(--radius-md, 16px);
  --rct-cell: 32px;
  --fill-slab: transparent;
  --card: transparent;
  width: 100%;
  height: 100%;
  padding: 0 10px;
  background: transparent;
  box-shadow: none;
}

.rct.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.rct-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: var(--rct-cell);
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--rct-in);
  background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));
  color: inherit;
  cursor: pointer;
  transition: scale 200ms cubic-bezier(0.3, 0.9, 0.4, 1), background-color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.rct--modal .rct-btn {
  width: 32px;
  /* the slab is transparent, so mix against the page surface
     rather than the slab or the key disappears into the card */
  background: color-mix(in srgb, var(--fill-on, #17181a) 7%, var(--surface, #ffffff));
}

.rct--modal .rct-btn:hover {
  background: color-mix(in srgb, var(--fill-on, #17181a) 12%, var(--surface, #ffffff));
}

.rct-btn:hover { background: color-mix(in srgb, var(--fill-on, #17181a) 10%, var(--fill-slab, #ffffff)); }

.rct-btn:active { scale: 0.9; transition-duration: 110ms; }

.rct-btn:focus-visible,
.rct-num:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--signal, #1b787a);
}

.rct-btn svg { display: block; }

/* The number sits between the keys. In a full-width field the
   digits stay centered, and the 8–10px padding is the smallest
   gap between a digit and a key. A column arriving or leaving
   animates its own width. */
.rct-num {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 8px;
  height: var(--rct-cell);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: var(--rct-cell);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  border-radius: var(--rct-in);
  /* rolling digits fade at the window's top and bottom edge */
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}

.rct--modal .rct-num {
  padding: 0 8px;
  font-size: 20px;
}

.rct-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-muted, var(--text-subtle, #6b7280));
  pointer-events: none;
}

.rct-digits { display: flex; min-width: 0.72em; justify-content: center; }

.rct-sign,
.rct-pair { display: flex; }

.rct-sign,
.rct-col,
.rct-sep {
  width: 0;
  opacity: 0;
  overflow: hidden;
  height: var(--rct-cell);
  transition: width 320ms cubic-bezier(0.3, 1.2, 0.4, 1), opacity 220ms ease;
}

.rct-sign { line-height: var(--rct-cell); }

.rct-sign[data-on] { width: 0.55em; opacity: 1; }

.rct-col[data-on] { width: 0.72em; opacity: 1; }

.rct-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

.rct-strip > span {
  display: grid;
  place-items: center;
  width: 0.72em;
  height: var(--rct-cell);
}

.rct-sep[data-on] { width: 0.32em; opacity: 1; }

input.rct-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  opacity: 0 !important;
  pointer-events: none !important;
  appearance: none !important;
}

input.rct-native::-webkit-outer-spin-button,
input.rct-native::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* The old number box beside a slider was ~90px. Two keys plus a
   short count need the wider track; the slider keeps the rest. */
.badge-placement-control__inputs,
.tool-background-control__inputs,
.day-decor-range,
.icon-adjust-scale {
  grid-template-columns: minmax(0, 1fr) 168px;
}

.extension-notices__width-row .rct-host,
.extension-notices__placement-row .rct-host {
  width: 168px;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .rct-sign,
  .rct-col,
  .rct-sep,
  .rct-btn { transition: none; }
}
