/*
 * Gallery charts (assets/js/charts.js): an Image / Interactive switch and a
 * theme picker above each chart, the chart itself, and the theme's code name
 * beneath it. The switch is the site's segmented control, as in the header's
 * theme switch. The picker is the site's own dropdown (.beacon-menu), drawn
 * like the app's popover menus: a native select's open list is drawn by the
 * browser and cannot take the site's colours.
 */

.md-typeset .beacon-chart {
  margin: 16px 0 28px;
}

.beacon-chart__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.beacon-chart__renderer {
  display: inline-flex;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.beacon-chart__option {
  padding: 3px 10px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.beacon-chart__option[aria-checked='true'] {
  font-weight: 400;
  color: var(--accent);
  background: var(--sidebar-active-bg);
}

.beacon-chart__option:focus-visible,
.beacon-menu__button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* The theme dropdown: a button showing the choice, and its list. ------- */

.beacon-menu {
  position: relative;
}

.beacon-menu__button {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 3px 8px 3px 10px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.beacon-menu__button:hover {
  color: var(--text-primary);
}

/* A chevron drawn in currentColor, so it follows the button's text. */
.beacon-menu__button::after {
  width: 5px;
  height: 5px;
  margin-top: -3px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  content: '';
}

.beacon-menu__button[aria-expanded='true']::after {
  margin-top: 2px;
  transform: rotate(-135deg);
}

/* The app's chrome popover: the glass fill, a hairline and a soft shadow. */
.beacon-menu__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 3;
  min-width: 260px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--glass);
  border: 0.5px solid var(--chrome-border);
  border-radius: 4px;
  box-shadow: var(--md-shadow-z3);
  backdrop-filter: blur(12px);
}

.beacon-menu__list:focus {
  outline: none;
}

.md-typeset .beacon-menu__item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.beacon-menu__item.is-active {
  background: var(--sidebar-active-bg);
}

.beacon-menu__name {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary);
}

.beacon-menu__item[aria-selected='true'] .beacon-menu__name {
  font-weight: 400;
  color: var(--accent);
}

.beacon-menu__hint {
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

/*
 * The stage holds the image and any live charts made so far, only one shown.
 * [hidden] needs saying: the site's live-chart rule sets iframes to display
 * block, which would otherwise win over the attribute.
 */
.beacon-chart__stage {
  border-radius: 4px;
}

.beacon-chart__stage > [hidden] {
  display: none !important;
}

.beacon-chart__stage img {
  display: block;
  max-width: 100%;
}

/*
 * The live chart's page declares no color-scheme, so it is light. On a dark
 * page Chromium would paint an opaque backdrop behind an iframe whose own
 * color-scheme differs from its document's, which would hide the transparent
 * themes' see-through ground. Matching it keeps the iframe transparent.
 */
.beacon-chart__stage iframe {
  color-scheme: light;
  border: 0;
}

/* The chart inside takes the pointer; a ring around the whole frame on click
   says nothing. Keyboard focus still shows, in the accent. */
.beacon-chart__stage iframe:focus {
  outline: none;
}

.beacon-chart__stage iframe:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* A transparent theme on the background it was drawn for (data-tokens). */
.beacon-chart__stage--backdrop {
  padding: 8px;
  background: var(--canvas);
  border: 1px solid var(--border);
}

.md-typeset .beacon-chart__code {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.beacon-chart__purpose {
  margin-left: 4px;
}
