/* ============================================================================
   SEGMENTED CONTROL
   Two kinds: view switch (navigation, plain links) and choice (a real
   radio group). Built so both work with no JS; toggle_radio_controller.js
   is only used to add arrow-key movement between choice options.
   ============================================================================ */

.segmented {
  display: inline-flex;
  gap: 3px;
  margin: 0;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--sf2);
  border: var(--bw) solid var(--line);
}

.segmented-legend {
  margin: 0 0 6px;
}

.segmented--block {
  display: flex;
  width: 100%;
}

.segmented--block .segmented-option {
  flex: 1;
}

.segmented-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  font: var(--fw-semibold) 14px/1 var(--font);
  color: var(--tx2);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 80ms ease-out, color 80ms ease-out, box-shadow 80ms ease-out;
}

@media (max-width: 46.1875rem) {
  .segmented-option {
    height: 36px;
  }
}

/* View switch: selected is a raised --sf thumb */
.segmented-option--view.is-selected,
.segmented-option--view[aria-current="true"] {
  background: var(--sf);
  color: var(--tx);
  box-shadow: var(--sh-1);
}

/* Choice: a real radio group */
.segmented-choice {
  position: relative;
}

.segmented-choice input[type="radio"] {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented-choice .segmented-option {
  width: 100%;
}

.segmented-choice:has(input:checked) .segmented-option {
  background: var(--ac-bg);
  color: var(--ac-text);
  box-shadow: var(--selected-ring);
}

.segmented-choice:has(input:focus-visible) .segmented-option {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* A block control shares its width evenly between the choices */
.segmented--block .segmented-choice {
  flex: 1;
  min-width: 0;
}

.segmented-option .icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
}

.field > .segmented-legend {
  margin: 0;
}

.segmented-hint {
  margin: -4px 0 0;
  color: var(--tx2);
}

/* Trend: three large tiles instead of a track, so the second judgment of a
   session carries the same weight as effort. The picked tile takes its trend
   color, as the trend circle does (better mint, same neutral, worse peach),
   and its arrow springs the way the trend went. */
.segmented--trend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  /* A sideways swipe picks a tile (trend_swipe_controller.js); up and down
     still scroll the sheet */
  touch-action: pan-y;
  user-select: none;
}

.segmented--trend .segmented-option {
  --trend-edge: inset 0 0 0 var(--bw) var(--line);
  flex-direction: column;
  gap: var(--sp-2);
  height: auto;
  min-block-size: 76px;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-tile);
  background: var(--sf);
  box-shadow: var(--trend-edge);
  font: var(--fw-semibold) var(--t-body-s) var(--font);
  transition: background-color 80ms ease-out, color 80ms ease-out, box-shadow 80ms ease-out, scale var(--spring-dur) var(--spring);
}

.segmented--trend .segmented-option .icon {
  width: 24px;
  height: 24px;
  margin: 0;
  color: var(--tx3);
}

/* Mid-swipe the finger has left the tile it went down on, so that tile
   doesn't stay pressed */
.segmented--trend:not(.is-swiping) .segmented-choice:active .segmented-option {
  scale: 0.96;
}

.segmented--trend .segmented-choice:has(input:checked) .segmented-option {
  box-shadow: var(--trend-edge);
}

.segmented--trend .segmented-choice:has(input:checked) .icon {
  color: currentColor;
}

.segmented--trend .segmented-choice--better:has(input:checked) .segmented-option {
  --trend-edge: inset 0 0 0 var(--bw) var(--mint-edge);
  background: var(--mint);
  color: var(--mint-tx);
}

/* Same has no color of its own, so its picked tile takes the neutral trend
   fill and a heavy edge in the strong text color, to read as picked beside
   the plain tiles */
.segmented--trend .segmented-choice--same:has(input:checked) .segmented-option {
  --trend-edge: inset 0 0 0 calc(var(--bw) * 2) var(--tx2);
  background: var(--sf2);
  color: var(--tx);
}

.segmented--trend .segmented-choice--worse:has(input:checked) .segmented-option {
  --trend-edge: inset 0 0 0 var(--bw) var(--peach-edge);
  background: var(--peach);
  color: var(--peach-tx);
}

.segmented--trend .segmented-choice:has(input:focus-visible) .segmented-option {
  box-shadow: var(--focus-ring), var(--trend-edge);
}

/* The pick springs only once the coach has picked here (.has-picked, set by
   trend_swipe_controller.js), not when a sheet opens with a trend already
   chosen */
.segmented--trend.has-picked .segmented-choice:has(input:checked) .segmented-option {
  animation: trend-tile-pick var(--spring-bounce-dur) var(--spring-bounce);
}

.segmented--trend.has-picked .segmented-choice--better:has(input:checked) .icon {
  animation: trend-arrow-up var(--spring-bounce-dur) var(--spring-bounce);
}

.segmented--trend.has-picked .segmented-choice--same:has(input:checked) .icon {
  animation: trend-arrow-across var(--spring-bounce-dur) var(--spring-bounce);
}

.segmented--trend.has-picked .segmented-choice--worse:has(input:checked) .icon {
  animation: trend-arrow-down var(--spring-bounce-dur) var(--spring-bounce);
}

@keyframes trend-tile-pick {
  from { scale: 0.94; }
}

@keyframes trend-arrow-up {
  from { translate: 0 10px; }
}

@keyframes trend-arrow-down {
  from { translate: 0 -10px; }
}

@keyframes trend-arrow-across {
  from { translate: -10px 0; }
}

/* Filter pills (Roster: Everyone 9 · Worth a check-in 3 · Taking a break 1).
   Separate pills rather than a track, each a plain link with a count. The
   picked one takes the choice styling. On phone the row scrolls sideways. */
.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--sf);
  color: var(--tx2);
  font: var(--fw-semibold) 15px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 80ms ease-out, color 80ms ease-out;
}

.filter-pill:hover {
  background: var(--sf2);
  color: var(--tx);
}

.filter-pill.is-selected {
  border-color: transparent;
  background: var(--ac-bg);
  color: var(--ac-text);
  box-shadow: var(--selected-ring);
}

.filter-pill:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.filter-pill .count-badge {
  height: 22px;
  min-width: 22px;
  padding: 0 6px;
  color: inherit;
  font-size: 12px;
}

.filter-pill.is-selected .count-badge {
  background: var(--sf);
}

@media (max-width: 1099px), (hover: none) and (pointer: coarse) {
  .filter-pills {
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    /* Scroll to the screen edge, past the page padding, with room above
       and below for the pills' tap areas, which the scroller would clip */
    margin: -3px -16px -3px 0;
    padding: 3px 16px 3px 0;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    position: relative;
    height: 38px;
    padding: 0 13px;
    font-size: 14px;
  }

  /* 38px pills with a 44px tap area */
  .filter-pill::after {
    content: "";
    position: absolute;
    inset: -3px 0;
  }
}
