/* Styles for the Light / Dark / System menu (see theme-switch.js). */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
}

.theme-switch .ts-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 150ms;
}
.theme-switch .ts-current {
  display: grid;
}
.theme-switch .ts-btn:hover,
.theme-switch .ts-btn[aria-expanded="true"] {
  color: var(--color-accent);
}
.theme-switch svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:is(.theme-switch, .tabs-more) .ts-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  min-width: 132px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}
:is(.theme-switch, .tabs-more) .ts-menu[hidden] {
  display: none;
}
.theme-switch[data-side="up"] .ts-menu {
  top: auto;
  bottom: calc(100% + 6px);
}
.theme-switch[data-align="left"] .ts-menu {
  right: auto;
  left: 0;
}
:is(.theme-switch, .tabs-more) .ts-menu :is(button, a) {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
:is(.theme-switch, .tabs-more) .ts-menu :is(button, a):hover,
:is(.theme-switch, .tabs-more) .ts-menu :is(button, a):focus-visible {
  background: rgba(128, 128, 128, 0.14);
  outline: 0;
}
.ts-menu :is(button[aria-checked="true"], a[aria-current]) {
  color: var(--color-accent);
}
.theme-switch .ts-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* Added briefly by theme-switch.js while the theme changes */
.theme-fade,
.theme-fade *,
.theme-fade *::before,
.theme-fade *::after {
  transition:
    background-color 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease,
    fill 0.35s ease,
    stroke 0.35s ease !important;
}

/* "More" menu for the tool tab row (see tabs-overflow.js): same look as the theme menu */
.tabs-more {
  position: relative;
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
}
.tabs-more[hidden] {
  display: none;
}
.tabs-more .ts-menu {
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  white-space: nowrap;
}
.tabs-more.align-right .ts-menu {
  left: auto;
  right: 0;
}
.ts-menu a {
  text-decoration: none;
}

/* Bookmark button (see bookmark.js): same button and menu look as the theme switch */
.bookmark {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
}
.bookmark .ts-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  white-space: nowrap;
  font: inherit;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 150ms;
}
.bookmark .ts-btn:hover,
.bookmark .ts-btn[aria-expanded="true"] {
  color: var(--color-accent);
}
.bookmark .ts-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.bookmark svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bookmark .ts-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  width: 232px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}
.bookmark .ts-menu[hidden] {
  display: none;
}
.bm-title {
  margin: 0 0 12px;
  font-weight: var(--weight-bold);
  color: var(--color-ink);
}
.bm-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0; /* the menu's own padding sets the bottom space */
  color: var(--color-muted);
  line-height: 1.4;
}
.bm-keys {
  display: inline-flex;
  gap: 4px;
}
.bm-keys kbd {
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-field);
  color: var(--color-text);
  font: inherit;
  text-align: center;
}
.bookmark .bm-sep {
  width: 1px;
  height: 12px;
  background: rgba(128, 128, 128, 0.7);
}
.bookmark .ts-btn svg {
  flex-shrink: 0;
}
/* Vertical separator between the bookmark button and the theme switch */
.bookmark::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -2px;
  width: 1px;
  height: 12px;
  margin-top: -6px;
  background: rgba(128, 128, 128, 0.7);
}

/* Small screens: icon-only buttons so the actions fit beside the breadcrumb */
@media (max-width: 800px) {
  .bookmark .ts-btn span,
  .bookmark .bm-sep,
  .bookmark::after {
    display: none;
  }
  .bookmark .ts-btn {
    justify-content: center;
    width: 28px;
    padding: 0;
  }
  .bookmark {
    gap: 10px;
  }
  /* Same gap between the bookmark and the theme switch */
  .topbar-actions,
  .page-actions {
    gap: 10px;
  }
}
