/* Segmented Control — one pill track, one white highlight that slides to the
   chosen option (one element moving, so the change animates for free).
   One size, M: the TGDS drawer's 24h / 7d switch, which Classroom Detail's
   time range now uses too (they were near-copies; unified 2026-09-24).
     32px tall · 3px padding · neutralTint25 track · n0 highlight inset 3,
     Shadow 1 · Title XS labels, n110 → n150 selected · pill radius ·
     var(--dur-240) var(--ease-out) (was its own 0.32, 0.72, 0, 1 curve — merged 2026-09-30)
   L (added 2026-09-30, Classroom v2 Figma 526:15077): page-level range
   controls — 42px tall · 4px padding · n25 track · highlight inset 5 ·
   Shadow 1 · Title XS · 16px slot padding.
   Segments are equal width: an inline grid of 1fr columns sizes every
   segment to the widest label, so the highlight is 1/n of the track and
   moves by whole segments. A fixed width makes the columns share it. */

@layer components {
  .seg {
    /* No fixed height (Corey, 2026-10-06): track padding + item padding +
       a 16px line = 32 (M) / 42 (L), matching Button and Field. */
    --seg-pad: 3px; --seg-inset: 3px; --seg-py: 5px;
    --seg-track: var(--neutralTint25); /* same tint as secondary buttons (2026-10-01) */ --seg-hl-shadow: var(--shadow-1);
    --seg-label: var(--title-xs); --seg-label-ls: var(--title-xs-ls);
    --seg-slot-x: 12px;
    position: relative;
    display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    align-items: stretch;
    padding: var(--seg-pad);
    border-radius: 999px;
    background: var(--seg-track);
    isolation: isolate;
  }

  /* L: bigger sizes, spacing and type (Title S, one up from M's Title XS);
     fills and shadow stay exactly as M. */
  .seg--l { --seg-py: 9px; /* 4 + 9 + 16 + 9 + 4 = 42 = Button L, so L controls line up side by side */ --seg-pad: 4px; --seg-inset: 5px; --seg-slot-x: 16px; --seg-label: var(--title-s); --seg-label-ls: var(--title-s-ls); }

  .seg-hl {
    position: absolute; z-index: 0;
    top: var(--seg-inset); bottom: var(--seg-inset); left: var(--seg-inset);
    width: calc((100% - 2 * var(--seg-inset)) / var(--seg-n));
    border-radius: 999px;
    background: var(--n0);
    box-shadow: var(--seg-hl-shadow);
    transform: translateX(calc(var(--seg-i) * 100%));
    transition: transform var(--dur-240) var(--ease-out);
    pointer-events: none;
  }

  .seg-item {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: center; gap: var(--space-6);
    min-width: 0;
    padding: var(--seg-py) var(--seg-slot-x);
    border: none; border-radius: 999px; background: none;
    cursor: pointer; text-align: center; overflow-wrap: break-word; /* long labels wrap onto more lines; the control grows taller (Santiago, /kit/attention, 2026-10-07). A word wider than its segment breaks rather than running into the next one. */
    font: var(--seg-label); letter-spacing: var(--seg-label-ls); line-height: 16px;
    color: var(--n110);
    transition: color var(--dur-160) var(--ease-fade);
  }
  .seg-item[aria-selected="true"], .seg-item[aria-checked="true"], .seg-item[aria-current="page"] { color: var(--n150); }
  /* Links (options with href): no underline, the current one as selected. */
  a.seg-item { text-decoration: none; }
  .seg-nav { display: inline-flex; }
  /* showIcons: a 16 icon before the label, in the option's iconColor (default ink). */
  .seg-icon { display: flex; flex-shrink: 0; }
  /* leadingIcon (2026-11-11): a 16 icon in its own first column, before the
     equal 1fr segments. Its start padding is the item's top padding, so it
     sits as far from the track's end as from its top and bottom (8 on M,
     13 on L: concentric). The highlight starts after it and splits only
     what's left. Same ink as the unchosen labels. */
  .seg--lead {
    --seg-lead-w: calc(var(--seg-py) + 16px + var(--space-6));
    grid-template-columns: var(--seg-lead-w);
  }
  .seg--lead .seg-hl {
    left: calc(var(--seg-inset) + var(--seg-lead-w));
    width: calc((100% - 2 * var(--seg-inset) - var(--seg-lead-w)) / var(--seg-n));
  }
  .seg-lead { display: flex; align-items: center; padding-inline-start: var(--seg-py); color: var(--n110); }
  /* leadingIconCircle (2026-11-11): the icon in a neutralTint25 circle, so it
     reads as the whole control's icon, not the first option's. Concentric:
     inset from the track like the highlight (3 on M, 5 on L), so its radius
     = the track's radius − that inset; diameter = the highlight's height
     (26 on M, 32 on L), from padding + the 16 line, never fixed. Then
     --space-4 (4px) to the first segment's highlight. */
  .seg--lead-circle {
    --seg-lead-d: calc(2 * var(--seg-pad) + 2 * var(--seg-py) + 16px - 2 * var(--seg-inset));
    --seg-lead-w: calc(var(--seg-inset) - var(--seg-pad) + var(--seg-lead-d) + var(--space-4));
  }
  .seg--lead-circle .seg-lead {
    justify-content: center; align-self: center;
    width: var(--seg-lead-d); aspect-ratio: 1;
    padding: 0; margin-inline-start: calc(var(--seg-inset) - var(--seg-pad));
    border-radius: 999px; background: var(--neutralTint25); /* Tint 5 → 10 → 25 (Santiago, 2026-11-11, inspector) */
  }
  /* While SegmentedControl measures whether labels fit (tight fit), they're held on one line. */
  .seg[data-measure] .seg-item { white-space: nowrap; }
  /* Two lines at most, then "…"; the whole label shows in a Tooltip (Santiago, 2026-10-07). */
  .seg-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .seg[data-measure] .seg-label { display: inline; }
  .seg-item:focus-visible { outline: 2px solid var(--blue100); outline-offset: 1px; }
  .seg-item:disabled { cursor: default; color: var(--n80); }
  .seg[data-disabled] { opacity: 0.55; pointer-events: none; }

  @media (prefers-reduced-motion: reduce) {
    .seg-hl, .seg-item { transition: none; }
  }
}
