/* =========================================================================
   Task time pickers (TaskTimeField and its three styles: day strip, hour
   grid, wheels). The fourth style is MudTimePicker and keeps its own look.
   Linked from both host documents (App.razor and the MAUI index.html) and
   pinned by StaticAssetModuleTests. Tokens come from timeline.css.

   Vocabulary is the dialogs' own: the uppercase eyebrow of .add-task-label,
   the pill chips of .heads-up-chip, the lit surface of the dialog, stone-500
   for "chosen". Amber is not used: it belongs to live signals only.
   ========================================================================= */

.tp {
  --tp-lit: var(--hf-dialog-lit, var(--surface-raised));
  --tp-track: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.tp-pending { min-height: 1.6rem; }

.tp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 0.75rem;
  min-height: 1.6rem;
}

.tp-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tp-status {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--stone-700);
  font-variant-numeric: tabular-nums;
}

.tp-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-muted);
}

.tp-error {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--rust-500, var(--rust-500));
}

.tp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 1.25rem;
}

.tp-link {
  background: none;
  border: 0;
  padding: 0.15rem 0;
  font: inherit;
  font-size: 0.8rem;
  color: var(--stone-600);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.tp-link:hover { color: var(--stone-700); }

.tp :is(button, [tabindex]):focus-visible {
  outline: 2px solid var(--stone-500);
  outline-offset: 2px;
}

/* ---- "Set a time" switch (wheels, day strip) --------------------------- */

.tp-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 0;
  padding: 0.2rem 0;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-primary);
  cursor: pointer;
}

.tp-switch-track {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--stone-300);
  transition: background 0.14s ease;
}

.tp-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tp-lit);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  transition: transform 0.14s ease;
}

.tp-switch.is-on .tp-switch-track { background: var(--stone-500); }
.tp-switch.is-on .tp-switch-knob { transform: translateX(14px); }

/* ---- Hour grid ---------------------------------------------------------- */

.tp-grid-box {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  background: var(--tp-track);
}

.tp-grid-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tp-grid-label {
  padding-left: 0.15rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tp-grid-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.25rem;
}

.tp-grid-mins {
  border-top: 1px solid var(--stone-200);
  padding-top: 0.6rem;
}

.tp-grid-passed {
  margin: 0;
  padding-left: 0.15rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.tp-cell {
  height: 2.4rem;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(var(--surface-raised-rgb), 0.62);
  color: var(--ink-primary);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.tp-cell-min { height: 2.15rem; font-size: 0.84rem; }

.tp-cell:hover:not(:disabled):not(.is-on) {
  background: var(--tp-lit);
  border-color: var(--stone-300);
}

.tp-cell.is-on {
  background: var(--fill-primary);
  border-color: var(--fill-primary);
  color: var(--surface-base);
}

/* Passed hours stay in place so the grid never reflows; they just stop answering. */
.tp-cell:disabled {
  background: transparent;
  color: var(--stone-300);
  font-weight: 400;
  cursor: default;
}

/* ---- Wheels ------------------------------------------------------------- */

.tp-wheels {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 0.85fr;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  background: var(--tp-track);
}

/* The selection band the three columns' middle rows line up in. */
.tp-wheels::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  right: 0.25rem;
  top: 50%;
  height: 38px;
  transform: translateY(-50%);
  border: 1px solid var(--stone-500);
  border-radius: 10px;
  background: var(--surface-base);
  box-shadow: 0 1px 2px rgba(74, 62, 46, 0.12);
  pointer-events: none;
}

/* 5 rows of 36px: two pads of 72px let the first and last rows reach the band.
   The 36px is ItemHeight in WheelTimePicker.razor. */
.tp-wheel {
  position: relative;
  height: 180px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border-radius: 10px;
  outline-offset: -2px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
}

.tp-wheel::-webkit-scrollbar { display: none; }

.tp-wheel-pad { height: 72px; }

.tp-wheel-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 1.05rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
}

.tp-wheel-item.is-on {
  color: var(--stone-700);
  font-weight: 700;
}

.tp-readout {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.tp-readout strong { color: var(--stone-700); }

/* ---- Day strip ---------------------------------------------------------- */

.tp-strip-read {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.25rem 0.55rem;
  text-align: center;
}

.tp-strip-time {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--stone-700);
  font-variant-numeric: tabular-nums;
}

.tp-strip-note {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.tp-strip-note.is-warn {
  color: var(--stone-700);
  font-weight: 600;
}

.tp-strip-wrap {
  position: relative;
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  background: var(--tp-lit);
  overflow: hidden;
}

.tp-strip {
  height: 108px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x;
  cursor: grab;
  outline-offset: -3px;
}

.tp-strip::-webkit-scrollbar { display: none; }
.tp-strip.is-drag { cursor: grabbing; }

.tp-strip-inner {
  display: flex;
  width: max-content;
  height: 100%;
}

/* Width set by time-picker.js to half the strip, so 12 am and 11:55 pm can sit under the needle. */
.tp-strip-pad {
  flex: none;
  width: 150px;
  height: 100%;
}

.tp-strip-track {
  position: relative;
  flex: none;
  height: 100%;
  user-select: none;
}

.tp-tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 8px;
  background: var(--stone-300);
}

.tp-tick.is-half { height: 13px; }

.tp-tick.is-hour {
  height: 22px;
  background: var(--stone-400);
}

.tp-tick-label {
  position: absolute;
  bottom: 26px;
  transform: translateX(-50%);
  font-size: 0.68rem;
  color: var(--ink-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tp-strip-marker {
  position: absolute;
  top: 12px;
  max-width: 11rem;
  height: 24px;
  padding: 0 7px;
  overflow: hidden;
  border: 1px solid var(--stone-300);
  border-radius: 7px;
  background: var(--stone-100);
  color: var(--stone-700);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 22px;
  white-space: nowrap;
  text-overflow: clip;
}

/* A hairline from the marker down to its minute on the ruler. */
.tp-strip-marker::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 22px;
  width: 1px;
  height: 52px;
  background: var(--stone-300);
}

.tp-strip-quiet {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(135deg, rgba(var(--stone-500-rgb), 0.13) 0 6px, transparent 6px 12px);
}

.tp-strip-quiet-label {
  position: absolute;
  top: 42px;
  left: 6px;
  font-size: 0.66rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.tp-strip-now {
  position: absolute;
  top: 44px;
  left: 3px;
  font-size: 0.66rem;
  color: var(--ink-muted);
}

.tp-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--stone-700);
  pointer-events: none;
}

.tp-needle::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -5px;
  border: 6px solid transparent;
  border-top-color: var(--stone-700);
}

.tp-nudges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

/* Same pill as .heads-up-chip, so the nudges and the heads-up row under them read as one set. */
.tp-chip {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--stone-200);
  border-radius: 999px;
  background: var(--surface-base);
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tp-chip:hover {
  border-color: var(--stone-300);
  background: var(--stone-50);
}

@media (prefers-reduced-motion: reduce) {
  .tp-switch-track,
  .tp-switch-knob,
  .tp-cell,
  .tp-chip { transition: none; }
}

/* ---- Profile: choosing a style ------------------------------------------ */

.tp-styles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .tp-styles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.tp-style {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0.55rem 0.55rem 0.6rem;
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  background: var(--surface-base);
  color: var(--ink-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tp-style:hover:not(.is-active) {
  border-color: var(--stone-300);
  background: var(--stone-50);
}

.tp-style.is-active {
  border-color: var(--stone-500);
  background: var(--surface-raised);
  box-shadow: 0 0 0 1px var(--stone-500);
}

.tp-style:focus-visible {
  outline: 2px solid var(--stone-500);
  outline-offset: 2px;
}

.tp-style-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 120 / 64;
  border-radius: 9px;
  background: var(--tp-track, var(--surface-soft));
}

.tp-style-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.tp-style-tag {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tp-style-desc {
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--ink-muted);
}

.tp-preview {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--stone-200);
  border-radius: 16px;
  background: var(--surface-raised);
}

.tp-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.tp-preview-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tp-preview-hint {
  font-size: 0.76rem;
  color: var(--ink-muted);
}
