/*
  Wortic macOS UI Kit — Segmented Control
  wm-segmented — poço côncavo (inset) com indicador branco elevado tipo
  pílula do macOS, deslizando com curva enfatizada.
*/

@layer components {
  .wm-segmented {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    /* fallback para engines sem light-dark() */
    background: var(--wm-fill-secondary);
    background: light-dark(rgba(0, 0, 0, 0.055), rgba(255, 255, 255, 0.07));
    box-shadow: inset 0 0 0 0.5px light-dark(rgba(0, 0, 0, 0.045), rgba(255, 255, 255, 0.05)),
      inset 0 1px 1.5px light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.3));
    border-radius: var(--wm-radius-md);
    padding: 2px;
    gap: 1px;
    isolation: isolate;
  }

  .wm-segmented__indicator {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: var(--wm-seg-width, 0px);
    transform: translateX(var(--wm-seg-offset, 0px));
    /* Superfície de controle (mesmo par de tokens do botão/select). */
    background: var(--wm-control-face-top);
    background: linear-gradient(180deg, var(--wm-control-face-top), var(--wm-control-face-bottom));
    border-radius: var(--wm-radius-sm);
    box-shadow: 0 0 0 0.5px light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.35)),
      inset 0 1px 0 light-dark(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.12)),
      0 1px 2px light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.4)),
      0 3px 8px -2px light-dark(rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.38));
    transition: transform var(--wm-duration-normal) var(--wm-ease-emphasized),
      width var(--wm-duration-normal) var(--wm-ease-emphasized);
    z-index: 0;
  }

  .wm-segmented__item {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wm-space-2);
    min-width: 64px;
    height: var(--wm-control-height-sm);
    padding-inline: var(--wm-space-6);
    border-radius: var(--wm-radius-sm);
    font-size: var(--wm-font-size-subheadline);
    font-weight: var(--wm-font-weight-medium);
    letter-spacing: var(--wm-letter-spacing-tight);
    color: var(--wm-label-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--wm-duration-fast) var(--wm-ease-standard),
      transform var(--wm-duration-fast) var(--wm-ease-emphasized);
  }

  .wm-segmented__item:hover:not([aria-checked="true"]):not(:disabled) {
    color: var(--wm-label-primary);
  }

  .wm-segmented__item:active:not(:disabled) {
    transform: scale(0.96);
  }

  .wm-segmented__item[aria-checked="true"] {
    color: var(--wm-label-primary);
  }

  .wm-segmented__item:focus-visible {
    outline: 2px solid var(--wm-accent);
    outline-offset: var(--wm-focus-ring-offset);
    box-shadow: 0 0 0 var(--wm-focus-halo-width) var(--wm-accent-fill);
  }

  .wm-segmented__item:disabled {
    color: var(--wm-label-quaternary);
    cursor: not-allowed;
  }

  .wm-segmented--block {
    display: flex;
  }
  .wm-segmented--block .wm-segmented__item {
    flex: 1 1 0;
  }

  .wm-segmented--small .wm-segmented__item {
    height: 22px;
    padding-inline: var(--wm-space-4);
    font-size: var(--wm-font-size-caption);
  }

  @media (prefers-reduced-motion: reduce) {
    .wm-segmented__indicator,
    .wm-segmented__item {
      transition: none;
    }
    .wm-segmented__item:active:not(:disabled) {
      transform: none;
    }
  }
}
