/* Brand launcher: waffle button + dropdown grid of all tools.
   Pair with launcher.js. Uses brand.css tokens only. */

.bl-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.bl-toggle:hover,
.bl-toggle[aria-expanded="true"] {
  color: var(--color-primary-hover);
  border-color: var(--color-primary);
}

.bl-toggle[aria-expanded="true"] {
  background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
}

.bl-toggle svg {
  width: 20px;
  height: 20px;
}

/* Fallback placement when the page has no [data-brand-launcher] mount. */
.bl-floating {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9998;
}

.bl-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
}

.bl-panel {
  position: fixed;
  z-index: 9999;
  width: min(560px, calc(100vw - 40px));
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 16px 48px color-mix(in srgb, var(--brand-950) 18%, transparent);
  font-family: var(--font-family);
  animation: bl-in 160ms ease-out;
}

.bl-panel[hidden],
.bl-backdrop[hidden] {
  display: none;
}

@keyframes bl-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bl-panel { animation: none; }
}

.bl-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bl-category {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 0;
  font-family: var(--font-heading);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.bl-category:first-child {
  margin-top: 0;
}

/* Tile: per-tool pastel gradient; --hue is set inline from tools.json. */
.bl-tile {
  position: relative;
  display: flex;
  min-height: 64px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid hsl(var(--hue) 40% 82%);
  border-radius: var(--radius);
  background: linear-gradient(135deg, hsl(var(--hue) 70% 96%), hsl(var(--hue) 65% 90%));
  transition: transform 150ms, box-shadow 150ms, border-color 150ms;
}

.bl-tile:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--hue) 55% 55%);
  box-shadow: 0 6px 16px hsl(var(--hue) 50% 40% / 0.18);
}

.bl-glyph {
  position: absolute;
  right: -8px;
  bottom: -18px;
  z-index: -1;
  font-size: 68px;
  line-height: 1;
  opacity: 0.12;
  transform: rotate(-12deg);
  filter: saturate(0.8);
  pointer-events: none;
  transition: opacity 150ms, transform 150ms;
}

.bl-tile:hover .bl-glyph {
  opacity: 0.28;
  transform: rotate(-6deg) scale(1.06);
}

.bl-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 26px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: hsl(var(--hue) 60% 10%);
  text-shadow:
    0 0 6px hsl(0 0% 100% / 0.95),
    0 0 12px hsl(0 0% 100% / 0.8),
    0 1px 2px hsl(0 0% 100% / 0.9);
}

.bl-star {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--hue) 20% 38%);
  cursor: pointer;
}

.bl-star svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.bl-star:hover,
.bl-star[aria-pressed="true"] {
  color: #d99a00;
}

.bl-star:hover {
  background: hsl(0 0% 100% / 0.6);
}

.bl-star[aria-pressed="true"] svg {
  fill: currentColor;
}

@media (max-width: 600px) {
  .bl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
