/* ServiceSwitcher (0.36.0): the button after the brand and the panel of Gem services it opens (service-switcher.tsx).
   Its own entry, loaded by the component (and so by BrandLockup, which renders it). The panel's ✕ is the kit popup's
   (`.ui-modal__close`, 28px, 44 under a thumb), its search box the kit's field made of parts (`gemboss-field
   gemboss-field--group` + `gemboss-field__bare`). Tokens only, but the tints: each is a hue, never painted as it is,
   always mixed with the theme's own surface (the mark) and text (the glyph), so one value reads in light and dark.
   `<button class="gb-svc-trigger" aria-haspopup="dialog" aria-expanded="false" aria-controls="svc" aria-label="Switch
   service">…</button><dialog class="gb-svc" id="svc" aria-labelledby="svc-t"><div class="gb-svc__head"><h2
   class="gb-svc__title" id="svc-t">Gem services</h2><button class="ui-modal__close">…</button></div><div
   class="gb-svc__search">…</div><div class="gb-svc__body"><div class="gb-svc__group" role="group"><h3
   class="gb-svc__heading">Build the store</h3><ul class="gb-svc__grid" role="list"><li><a class="gb-svc__tile"
   href="…" data-tint="blue" aria-current="page"><span class="gb-svc__mark">…</span><span class="gb-svc__name">GemFactory
   </span><span class="gb-svc__purpose">…</span></a></li></ul></div></div><div class="gb-svc__foot"><a
   class="gb-svc__all" href="…">All services and their health →</a></div></dialog>` */

/* The hues (services.ts SERVICE_TINTS). Iris is the kit accent; the rest are drawn lighter on a dark theme. */
:root {
  --gb-svc-iris: var(--gemboss-accent, #5661f5);
  --gb-svc-blue: #2563eb; --gb-svc-teal: #0d9488; --gb-svc-green: #16a34a; --gb-svc-amber: #d97706;
  --gb-svc-orange: #ea580c; --gb-svc-rose: #e11d48; --gb-svc-violet: #9333ea; --gb-svc-slate: #64748b;
  --gb-svc-wash: 14%;
}
:root[data-theme="dark"] {
  --gb-svc-blue: #60a5fa; --gb-svc-teal: #2dd4bf; --gb-svc-green: #4ade80; --gb-svc-amber: #fbbf24;
  --gb-svc-orange: #fb923c; --gb-svc-rose: #fb7185; --gb-svc-violet: #c084fc; --gb-svc-slate: #94a3b8;
  --gb-svc-wash: 22%;
}

/* ── the button: right after the brand, 4px from it (the topbar slot's gap is 8) ── */
.gb-svc-trigger {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: 0; padding: 0; box-sizing: border-box;
  border: 0; border-radius: var(--gemboss-radius-md, 8px); background: transparent;
  color: var(--gemboss-text-muted); cursor: pointer;
  transition: background-color var(--gemboss-transition-base, 0.15s) ease;
}
.gb-brand + .gb-svc-trigger { margin-left: -4px; }
.gb-svc-trigger[aria-expanded="true"] { background: var(--gemboss-hover); color: var(--gemboss-text); }
@media (hover: hover) { .gb-svc-trigger:hover { background: var(--gemboss-hover); color: var(--gemboss-text); } }
.gb-svc-trigger:focus-visible { outline: 2px solid var(--gemboss-primary); outline-offset: 2px; }
/* A finger's 44, and at phone width (the kit's pair: a narrow window with a mouse measured 32 and failed tap_target_size). */
@media (pointer: coarse), (max-width: 47.9975em) { .gb-svc-trigger { width: 44px; height: 44px; } }
/* Where the brand is its 44px mark alone, the phone topbar is full (☰, mark, search at its 96px floor, assistant,
   account): the button touches the mark (no gap) and is 40 wide, so the bar still fits at 360 (topbar.test.tsx). */
@media (max-width: 460px) { .gb-brand + .gb-svc-trigger { width: 40px; margin-left: -8px; } }
/* Under 360 nothing else can give: the search goes below its 96px floor, to 56 (still a box to tap), rather than the
   account leaving the screen or the switcher leaving the bar. Only in a bar that holds the switcher. */
@media (max-width: 359.98px) {
  .gemboss-platform-topbar:has(.gb-svc-trigger) .gemboss-topbar-center:not(:empty) { min-width: 56px; container: gb-svc-search / inline-size; }
}
/* 0.37.1: and under that floor its words no longer read (58 wide at 320 left them 2px, a sliver of the first letter), so
   the box is the search icon alone, centred, still the box to tap. TopbarSearch: the input covers the whole box (a tap
   anywhere is in it; it was 0-2px wide), its placeholder unpainted, its name the aria-label it always has; the icon steps
   aside once it is focused or holds words. SearchDialog's `field`: its words stay the link's name, drawn nowhere. */
@container gb-svc-search (max-width: 95.98px) {
  .gemboss-topbar-center .gemboss-topbar-search { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .gemboss-topbar-center .gemboss-topbar-search > * { grid-area: 1 / 1; }
  .gemboss-topbar-center .gemboss-topbar-search-icon { justify-self: center; pointer-events: none; }
  .gemboss-topbar-center .gemboss-topbar-search-input { justify-self: stretch; width: auto; padding: 0 8px; }
  .gemboss-topbar-center .gemboss-topbar-search-input::placeholder { color: transparent; }
  .gemboss-topbar-center .gemboss-topbar-search:is(:focus-within, :has(> .gemboss-topbar-search-input:not(:placeholder-shown))) > .gemboss-topbar-search-icon { visibility: hidden; }
  .gemboss-topbar-center .gb-search-field-text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ── the panel: under the topbar from the brand's left edge (--gb-svc-x / -y, set when it opens) ── */
dialog.gb-svc {
  position: fixed; inset: var(--gb-svc-y, 62px) auto auto var(--gb-svc-x, 16px); margin: 0; padding: 0; box-sizing: border-box;
  width: min(760px, calc(100vw - 24px)); max-width: none;
  max-height: min(80vh, calc(100dvh - var(--gb-svc-y, 62px) - 12px));
  border: 1px solid var(--gemboss-divider); border-radius: var(--gemboss-radius-lg, 12px);
  background: var(--gemboss-surface); color: var(--gemboss-text);
  box-shadow: var(--gemboss-shadow-overlay); overflow: hidden;
  /* Opened with showModal() it sits in the top layer and this does nothing; drawn with the `open` attribute (the
     catalog) it still covers the fixed topbar (z 300) instead of sliding under its account chip. */
  z-index: 400;
}
dialog.gb-svc[open] { display: flex; flex-direction: column; animation: gb-svc-in 120ms ease-out; }
dialog.gb-svc::backdrop { background: rgba(0, 0, 0, 0.16); }
@keyframes gb-svc-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes gb-svc-up { from { opacity: 0; transform: translateY(16px); } }
/* The page behind holds still (the kit popups' rule, kit-plain.css, names `.ui-modal` only). */
html:has(dialog.gb-svc:modal) { overflow: hidden; }

.gb-svc__head { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 12px 4px 16px; }
.gb-svc__title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 14px; line-height: 20px; font-weight: 650; color: var(--gemboss-text-strong); }
.gb-svc__search { flex: none; padding: 4px 16px 8px; }
.gb-svc__search svg { flex: none; width: 16px; height: 16px; color: var(--gemboss-text-muted); }
.gb-svc__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 16px; }
.gb-svc__group + .gb-svc__group { margin-top: 16px; }
.gb-svc__heading {
  margin: 0 0 8px; font-size: 11px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--gemboss-text-muted);
}
.gb-svc__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.gb-svc__grid > li { display: flex; min-width: 0; }

/* A tile: the mark, the name, what it is for. The whole tile is the link. */
.gb-svc__tile {
  --gb-svc-tint: var(--gb-svc-slate);
  flex: 1 1 auto; min-width: 0; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px; border: 1px solid var(--gemboss-divider); border-radius: var(--gemboss-radius-lg, 12px);
  background: var(--gemboss-surface); color: var(--gemboss-text); text-decoration: none;
  transition: background-color var(--gemboss-transition-fast, 0.12s) ease, border-color var(--gemboss-transition-fast, 0.12s) ease;
}
@media (hover: hover) { .gb-svc__tile:hover { background: var(--gemboss-hover); } }
.gb-svc__tile:focus-visible { outline: 2px solid var(--gemboss-accent); outline-offset: 2px; }
/* You are here: the accent ring (border + 1px inside it). Still a link, to this service's home. */
.gb-svc__tile[aria-current="page"] { border-color: var(--gemboss-accent); box-shadow: inset 0 0 0 1px var(--gemboss-accent); }
.gb-svc__tile[data-tint="iris"] { --gb-svc-tint: var(--gb-svc-iris); }
.gb-svc__tile[data-tint="blue"] { --gb-svc-tint: var(--gb-svc-blue); }
.gb-svc__tile[data-tint="teal"] { --gb-svc-tint: var(--gb-svc-teal); }
.gb-svc__tile[data-tint="green"] { --gb-svc-tint: var(--gb-svc-green); }
.gb-svc__tile[data-tint="amber"] { --gb-svc-tint: var(--gb-svc-amber); }
.gb-svc__tile[data-tint="orange"] { --gb-svc-tint: var(--gb-svc-orange); }
.gb-svc__tile[data-tint="rose"] { --gb-svc-tint: var(--gb-svc-rose); }
.gb-svc__tile[data-tint="violet"] { --gb-svc-tint: var(--gb-svc-violet); }
.gb-svc__tile[data-tint="slate"] { --gb-svc-tint: var(--gb-svc-slate); }
.gb-svc__mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-bottom: 8px;
  border-radius: var(--gemboss-radius-lg, 12px);
  background: color-mix(in srgb, var(--gb-svc-tint) var(--gb-svc-wash), var(--gemboss-surface));
  color: color-mix(in srgb, var(--gb-svc-tint) 78%, var(--gemboss-text-strong));
}
.gb-svc__name { max-width: 100%; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--gemboss-text-strong); overflow-wrap: anywhere; }
.gb-svc__purpose {
  max-width: 100%; font-size: 12px; line-height: 16px; color: var(--gemboss-text-muted);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
/* Switcher (0.40.0): a tile with an illustration on top (a community, a workspace), not the small mark. The picture is an
   image, or the item's glyph drawn big on a panel of its tint (mixed with the surface: one value reads light and dark). */
.gb-svc__grid--media { grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 12px; }
.gb-svc__tile--media { padding: 8px 8px 12px; }
.gb-svc__tile--media > .gb-svc__name, .gb-svc__tile--media > .gb-svc__purpose { padding-inline: 4px; }
.gb-svc__media {
  display: block; width: 100%; aspect-ratio: 16 / 9; margin-bottom: 8px; overflow: hidden;
  border-radius: var(--gemboss-radius-md, 8px);
  background:
    radial-gradient(120% 100% at 85% 0%, color-mix(in srgb, var(--gb-svc-tint) calc(var(--gb-svc-wash) * 2), var(--gemboss-surface)), transparent 70%),
    color-mix(in srgb, var(--gb-svc-tint) var(--gb-svc-wash), var(--gemboss-surface));
}
.gb-svc__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gb-svc__media-glyph {
  display: grid; place-items: center; width: 100%; height: 100%; font-size: 44px; line-height: 1; font-weight: 700;
  color: color-mix(in srgb, var(--gb-svc-tint) 78%, var(--gemboss-text-strong));
}
.gb-svc__glyph { font-size: 20px; line-height: 1; font-weight: 700; }
.gb-svc__badge {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; vertical-align: 1px;
  font-size: 11px; line-height: 16px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--gemboss-accent) 12%, var(--gemboss-surface)); color: var(--gemboss-accent-strong);
}
.gb-svc__empty { margin: 0; padding: 24px 0; font-size: 13px; color: var(--gemboss-text-muted); text-align: center; }
.gb-svc__foot { flex: none; padding: 4px 16px; border-top: 1px solid var(--gemboss-divider-soft); }
.gb-svc__all {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; font-size: 13px; font-weight: 500;
  color: var(--gemboss-accent-strong); text-decoration: none;
}
@media (hover: hover) { .gb-svc__all:hover { text-decoration: underline; } }
.gb-svc__all:focus-visible { outline: 2px solid var(--gemboss-accent); outline-offset: 2px; border-radius: 4px; }
@media (pointer: coarse) { .gb-svc__all { min-height: 44px; } }

/* ── a phone: the whole screen, two columns, clear of the notch and the home bar ── */
@media (max-width: 640px) {
  dialog.gb-svc {
    inset: 0; width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  dialog.gb-svc[open] { animation-name: gb-svc-up; }
  .gb-svc__head { padding: 8px 8px 4px 16px; border-bottom: 0; }
  .gb-svc__search, .gb-svc__body { padding-inline: 12px; }
  .gb-svc__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gb-svc__grid--media { gap: 8px; }
  .gb-svc__media-glyph { font-size: 36px; }
  .gb-svc__foot { padding-inline: 12px; }
  .gb-svc__all { min-height: 44px; }
}
/* Last, so it holds over the phone's own animation too. */
@media (prefers-reduced-motion: reduce) { dialog.gb-svc[open] { animation: none; } }
