/* Liquid glass segmented control (see segmented-glass.js). The track is a recessed, darker
   material; the thumb is a lighter glass layer floating above it, with a bright top edge and a
   pointer-following rim light. Labels never sit on stacked translucent layers. */
.seg {
  position: relative; isolation: isolate;
  display: inline-flex; flex-wrap: wrap; align-items: stretch; gap: 2px;
  width: fit-content; max-width: 100%; padding: 4px;
  border: 1px solid #ffffff14; border-radius: 14px;
  background: linear-gradient(180deg, #00000033, #0000000d), #0c0f10b3;
  box-shadow: inset 0 1px 2px #00000066, inset 0 -1px 0 #ffffff0a;
}
.seg > button {
  position: relative; z-index: 1;
  min-height: 44px; padding: 10px 16px; border: 0; border-radius: 10px;
  background: none !important; box-shadow: none !important;
  color: var(--secondary); font: inherit; font-size: 16px; white-space: nowrap;
  transition: color 200ms var(--ease-out), opacity 120ms ease-out;
}
.seg > button:hover { color: var(--text); }
.seg > button:active { opacity: .62; transition-duration: 60ms; } /* instant feedback on press */
.seg > button[aria-pressed=true] { color: var(--text) !important; opacity: 1; }
.seg > button[aria-pressed=true] span { color: var(--secondary) !important; }
.seg > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.seg-thumb {
  position: absolute; left: 0; top: 0; z-index: 0;
  border-radius: 10px; pointer-events: none; transform-origin: 50% 50%; will-change: transform, width;
  background: linear-gradient(180deg, #ffffff2b, #ffffff0f 55%, #ffffff17);
  box-shadow: inset 0 1px 0 #ffffff4d, inset 0 -1px 0 #ffffff12, 0 0 0 1px #ffffff1f, 0 6px 18px #00000066, 0 1px 3px #00000059;
  -webkit-backdrop-filter: blur(12px) saturate(1.6); backdrop-filter: blur(12px) saturate(1.6);
  transition: opacity 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.seg-thumb::before { /* rim light that follows the pointer, same recipe as the other glass controls */
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(90px circle at var(--light-x, 30%) var(--light-y, 0%), #f4faffcc, #a9cbd955 40%, transparent 75%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask-composite: exclude;
}
.seg-thumb.is-held { box-shadow: inset 0 1px 0 #ffffff5c, inset 0 -1px 0 #ffffff12, 0 0 0 1px #ffffff2e, 0 10px 26px #00000073, 0 1px 3px #00000059; }
.seg-thumb.seg-fade { animation: seg-fade 220ms ease-out; }
@keyframes seg-fade { from { opacity: 0; } to { opacity: 1; } }

:root[data-theme=light] .seg {
  border-color: #1a1d1c14;
  background: linear-gradient(180deg, #1a1d1c12, #1a1d1c08);
  box-shadow: inset 0 1px 2px #1a1d1c1f, inset 0 -1px 0 #ffffff99;
}
:root[data-theme=light] .seg-thumb {
  background: linear-gradient(180deg, #ffffff, #f6f8f5);
  box-shadow: inset 0 1px 0 #ffffff, 0 0 0 .5px #1a1d1c1f, 0 3px 10px #1a1d1c1f, 0 1px 2px #1a1d1c1a;
}
:root[data-theme=light] .seg-thumb::before { background: radial-gradient(90px circle at var(--light-x, 30%) var(--light-y, 0%), #314b5466, transparent 75%); }

/* Home catalog: the toolbar becomes a quiet glass bar holding the control and the search. */
.catalog .catalog-toolbar { background: linear-gradient(180deg, #ffffff06, #ffffff00), var(--panel); border-color: var(--line); }
:root[data-theme=light] .catalog .catalog-toolbar { background: var(--panel); border-color: var(--line); }
.catalog .filters.seg { margin: 16px 20px; padding: 4px; gap: 2px; align-self: center; }
.catalog .filters.seg > button { padding: 10px 18px; min-height: 44px; }
.catalog .search { border-left-color: var(--line); }

@media (max-width: 800px) {
  .catalog .filters.seg { display: flex; align-self: stretch; width: auto; margin: 12px; padding: 4px; gap: 2px; justify-content: stretch; flex-wrap: nowrap; }
  .catalog .filters.seg > button { flex: 1 1 0; min-width: 0; padding: 10px 6px; font-size: 15px; }
  .pill-group.seg, .library-tabs.seg { display: flex; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .pill-group.seg::-webkit-scrollbar, .library-tabs.seg::-webkit-scrollbar { display: none; }
}
@media (max-width: 380px) { .catalog .filters.seg > button { font-size: 14px; } }
@media (prefers-reduced-transparency: reduce) {
  .seg-thumb { -webkit-backdrop-filter: none; backdrop-filter: none; background: #2a3132; }
  :root[data-theme=light] .seg-thumb { background: #fff; }
}
@media (forced-colors: active) {
  .seg-thumb { background: Highlight; }
  .seg > button[aria-pressed=true] { color: HighlightText !important; }
}

/* Liquid lens (Chromium): the rim refracts what sits behind the thumb, so the material reads as
   clear glass rather than a frosted chip. Set by segmented-glass.js; other browsers keep the blur. */
.seg-thumb.has-lens {
  -webkit-backdrop-filter: var(--lens) blur(.6px) saturate(1.8) brightness(1.1);
  backdrop-filter: var(--lens) blur(.6px) saturate(1.8) brightness(1.1);
  background: linear-gradient(180deg, #ffffff24, #ffffff06 50%, #ffffff12);
}
.seg-thumb.has-lens::after { /* specular sheen along the top, the bright edge of real glass */
  content: ""; position: absolute; inset: 1px 1px auto; height: 45%; border-radius: 9px 9px 40% 40% / 9px 9px 14px 14px; pointer-events: none;
  background: linear-gradient(180deg, #ffffff2e, #ffffff00);
}
:root[data-theme=light] .seg-thumb.has-lens { background: linear-gradient(180deg, #ffffffd9, #ffffffa6); }
.seg-thumb.is-held.has-lens { background: linear-gradient(180deg, #ffffff1a, #ffffff03 50%, #ffffff0d); }
