/* ── Page actions menu (copy page / view raw / open in assistant) ────────── */

.aai-actions {
  position: relative;
  float: right;
  display: flex;
  margin: 0.2rem 0 0.4rem 0.8rem;
  font-size: 0.65rem;
  line-height: 1.4;
}

.aai-actions__primary,
.aai-actions__toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  transition: color 125ms, background-color 125ms;
}

.aai-actions__primary {
  border-radius: 0.2rem 0 0 0.2rem;
  border-right: none;
  white-space: nowrap;
}

.aai-actions__toggle {
  border-radius: 0 0.2rem 0.2rem 0;
}

.aai-actions__primary:hover,
.aai-actions__toggle:hover,
.aai-actions__toggle[aria-expanded="true"] {
  color: var(--md-accent-fg-color);
  background: var(--md-accent-fg-color--transparent);
}

/* ── Menu ───────────────────────────────────────────────────────────────── */

.aai-actions__menu {
  position: absolute;
  top: calc(100% + 0.2rem);
  right: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  min-width: 14rem;
  padding: 0.2rem;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.2rem;
  box-shadow: var(--md-shadow-z2);
}

.aai-actions__menu[hidden] {
  display: none;
}

/* `.md-typeset a` wins on specificity, so menu links must be scoped to match. */
.md-typeset .aai-actions__item,
.md-typeset .aai-actions__item:hover,
.md-typeset .aai-actions__primary,
.md-typeset .aai-actions__toggle {
  text-decoration: none;
}

.md-typeset .aai-actions__item {
  color: var(--md-default-fg-color);
}

.md-typeset .aai-actions__item:hover {
  color: var(--md-accent-fg-color);
}

.aai-actions__item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  width: 100%;
  padding: 0.4rem 0.5rem;
  color: var(--md-default-fg-color);
  text-align: left;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 0.15rem;
}

.aai-actions__item:hover {
  color: var(--md-accent-fg-color);
  background: var(--md-accent-fg-color--transparent);
}

.aai-actions__item strong {
  display: block;
  font-weight: 500;
}

.aai-actions__item em {
  display: block;
  font-size: 0.85em;
  font-style: normal;
  color: var(--md-default-fg-color--light);
}

.aai-actions__item:hover em {
  color: inherit;
}

/* ── Icons ──────────────────────────────────────────────────────────────── */

.aai-actions__icon {
  flex-shrink: 0;
}

.aai-actions__icon svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentcolor;
}

.aai-actions__item .aai-actions__icon {
  margin-top: 0.1rem;
}

/* Keep the menu on screen on narrow viewports. */
@media screen and (max-width: 44.984375em) {
  .aai-actions__primary .aai-actions__label {
    display: none;
  }

  .aai-actions__menu {
    min-width: 12rem;
  }
}
