/**
 * ui-kit.css — “Apple” foundation kit (2026-06-18)
 * Reusable components that application screens will later inherit from:
 *   - .btn-pill        pill button (press state, focus ring)
 *   - .segmented       segmented control with sliding thumb (JS: segmented.js)
 *   - .skeleton(-text) shimmer placeholders (disabled with reduced-motion)
 *   - .halo            desaturated navy/blue radial glow (headers, heroes)
 *   - .empty-state     empty state (icon + halo + text + action)
 *
 * Tokens used (defined in app.css): --ease, --ease-spring, --dur*,
 * shadow-*, --r-pill, --halo-color, --tint, --label-*, --fill-*, --bg-*,
 * separator, --ring-focus. Dark theme handled through these tokens (auto).
 * No inline JS (CSP); ARIA is handled by the markup / segmented.js.
 */

/* ════════════════════════════════════════════════════════════════════
   1. Pill button — .btn-pill
   Solid capsule (tint), press-state scale(.97) + darkening,
   crisp focus ring. Variants: .btn-pill--ghost (outline), .btn-pill--quiet
   (subtle fill). Size: .btn-pill--sm / .btn-pill--lg.
   ════════════════════════════════════════════════════════════════════ */
.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.6rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--r-pill, 100px);
  background: var(--tint);
  color: var(--bg-secondary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-fast, 0.15s) var(--ease, ease),
    filter var(--dur-fast, 0.15s) var(--ease, ease),
    box-shadow var(--dur-fast, 0.15s) var(--ease, ease),
    background var(--dur-fast, 0.15s) var(--ease, ease);
}
.btn-pill > svg { width: 1.15em; height: 1.15em; flex: 0 0 auto; }
.btn-pill:hover { filter: brightness(1.08); }
.btn-pill:active { transform: scale(0.97); filter: brightness(0.92); }
.btn-pill:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus, 0 0 0 3px rgba(94,127,168,0.35));
}
.btn-pill:disabled,
.btn-pill[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Outline variant (ghost): neutral surface, crisp border */
.btn-pill--ghost {
  background: var(--bg-secondary);
  color: var(--label-primary);
  border-color: var(--separator);
}
.btn-pill--ghost:hover { filter: none; background: var(--fill-tertiary); }
.btn-pill--ghost:active { filter: none; background: var(--fill-secondary); transform: scale(0.97); }

/* Subtle variant (quiet): translucent fill, no border */
.btn-pill--quiet {
  background: var(--fill-primary);
  color: var(--label-primary);
}
.btn-pill--quiet:hover { filter: none; background: var(--fill-secondary); }
.btn-pill--quiet:active { filter: none; background: var(--fill-secondary); transform: scale(0.97); }

/* The destructive variant */
.btn-pill--danger { background: var(--system-red); color: #fff; }

.btn-pill--sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-pill--lg { padding: 0.8rem 1.6rem; font-size: 1.05rem; }

@media (prefers-reduced-motion: reduce) {
  .btn-pill { transition: filter var(--dur-fast, 0.15s) linear, background var(--dur-fast, 0.15s) linear; }
  .btn-pill:active { transform: none; }
}

/* ════════════════════════════════════════════════════════════════════
   2. Segmented control — .segmented
   role="tablist"; each option = <button role="tab">. A sliding thumb
   (.segmented-thumb) is positioned by segmented.js (variables --seg-x /
   --seg-w). Without JS: remains readable (the selected button is tinted).
   ════════════════════════════════════════════════════════════════════ */
.segmented {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  padding: 3px;
  background: var(--fill-secondary);
  border-radius: var(--r-pill, 100px);
  isolation: isolate;
}
.segmented-thumb {
  position: absolute;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  width: var(--seg-w, 0px);
  transform: translateX(var(--seg-x, 0px));
  background: var(--bg-secondary);
  border-radius: var(--r-pill, 100px);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--dur, 0.25s) var(--ease, ease),
    width var(--dur, 0.25s) var(--ease, ease);
  z-index: 0;
  pointer-events: none;
}
.segmented-thumb[hidden] { display: none; }
.segmented [role="tab"] {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--label-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.45rem 1rem;
  border-radius: var(--r-pill, 100px);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur, 0.25s) var(--ease, ease);
}
.segmented [role="tab"]:hover { color: var(--label-primary); }
.segmented [role="tab"][aria-selected="true"] { color: var(--label-primary); }
.segmented [role="tab"]:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus, 0 0 0 3px rgba(94,127,168,0.35));
}
/* Fallback without JS / hidden thumb: tints the active button */
.segmented:not(.segmented--ready) [role="tab"][aria-selected="true"] {
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
}
@media (prefers-reduced-motion: reduce) {
  .segmented-thumb { transition: none; }
}

/* ════════════════════════════════════════════════════════════════════
   3. Skeleton shimmer — .skeleton / .skeleton-text
   Loading placeholder. The shimmer is disabled if reduced-motion
   (remains a static gray block, still readable as « en attente »).
   ════════════════════════════════════════════════════════════════════ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--fill-secondary);
  border-radius: var(--radius-md, 10px);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    var(--fill-primary),
    transparent
  );
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
.skeleton-text {
  height: 0.85em;
  margin: 0.35em 0;
  border-radius: var(--radius-sm, 6px);
}
.skeleton-text:last-child { width: 65%; }
.skeleton-circle { border-radius: 50%; }
@keyframes skeletonShimmer {
  100% { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { display: none; }
}

/* ════════════════════════════════════════════════════════════════════
   4. Radial halo — .halo
   DESATURATED navy/blue glow (--halo-color = #5e7fa8, blue-light guidelines)
   diffused behind headers / heroes / empty states. Decorative:
   implicitly aria-hidden (no text), pointer-events:none.
   Place on a position:relative parent (the halo is centered behind it).
   ════════════════════════════════════════════════════════════════════ */
.halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 480px;
  height: 480px;
  max-width: 120%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--halo-color) 0%, transparent 68%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}
.halo--top { top: 0; }
.halo--sm { width: 280px; height: 280px; }
.halo--lg { width: 680px; height: 680px; }
/* Container that holds a halo: keeps the content above it */
.has-halo { position: relative; }
.has-halo > :not(.halo) { position: relative; z-index: 1; }

/* ════════════════════════════════════════════════════════════════════
   5. Empty state — .empty-state
   SVG pictogram (in .empty-state-icon) + halo + title + text + action.
   Centered, spacious. The icon is decorative (aria-hidden in the markup).
   ════════════════════════════════════════════════════════════════════ */
.empty-state {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: clamp(2rem, 6vw, 3.5rem) 1.5rem;
  overflow: hidden;
}
.empty-state > * { position: relative; z-index: 1; }
.empty-state > .halo { z-index: 0; }
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-xl, 18px);
  background: var(--fill-secondary);
  color: var(--label-secondary);
}
.empty-state-icon svg { width: 30px; height: 30px; }
.empty-state-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--label-primary);
}
.empty-state-text {
  margin: 0;
  max-width: 38ch;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--label-secondary);
}
.empty-state-action { margin-top: 0.75rem; }
