/*
 * The control for which rules the site shows (DESIGN §20, js/site-edition.js), on every page of the fork. It sits on
 * the fork's header band, blue by day and near-black by night, so the button is drawn in translucent white there; on a
 * phone it sits in the navbar's row on the page's own background and takes the page's ink instead. Sizes are in px:
 * the fork's root font size is 10px. The fork swaps css/<name>.css for a mirrored .rtl.css in right-to-left languages,
 * which this folder is outside of; the file is written with logical properties.
 */

.site-edition,
.site-edition__row {
  --edition-on-band: #fff;
  --edition-band-fill: rgb(255 255 255 / 14%);
  --edition-band-line: rgb(255 255 255 / 38%);
  --edition-card: #fff;
  --edition-ink: #1d1b19;
  --edition-muted: #6b645c;
  --edition-accent: #8a2c1b;
  --edition-tint: rgb(138 44 27 / 8%);
  --edition-hover: rgb(40 20 10 / 5%);
  --edition-rule: rgb(40 20 10 / 10%);
  --edition-note: #fbf3e4;
  --edition-shadow: 0 1px 2px rgb(40 20 10 / 8%), 0 18px 40px -12px rgb(40 20 10 / 35%);
}

.site-edition {
  position: relative;
  flex: none;
  /* The fork's header row aligns by text baseline (.ve-flex-v-baseline), which would hang the pill off-centre. */
  align-self: center;
  margin-inline-start: auto;
  padding-inline-start: 16px;
  font-family: inherit;
  line-height: 1.5;
}

:where(:root.ve-night-mode) :is(.site-edition, .site-edition__row) {
  --edition-band-fill: rgb(255 255 255 / 7%);
  --edition-band-line: rgb(255 255 255 / 20%);
  --edition-card: #242424;
  --edition-ink: #ece7e1;
  --edition-muted: #aaa29a;
  --edition-accent: #e0604a;
  --edition-tint: rgb(224 96 74 / 12%);
  --edition-hover: rgb(255 255 255 / 5%);
  --edition-rule: rgb(255 255 255 / 10%);
  --edition-note: rgb(224 170 74 / 12%);
  --edition-shadow: 0 18px 40px -12px rgb(0 0 0 / 75%);
}

/* The fork's subtitle is one long line; it gives way to the control instead of pushing it off the row. */
.page__header > .container > .page__subtitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------------------- */
/* The button */

.site-edition__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--edition-band-line);
  border-radius: 999px;
  background: var(--edition-band-fill);
  color: var(--edition-on-band);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.site-edition__button:hover,
.site-edition__button[aria-expanded="true"] {
  background: color-mix(in srgb, var(--edition-band-fill), var(--edition-on-band) 12%);
}

.site-edition__button:focus-visible {
  outline: 2px solid var(--edition-on-band);
  outline-offset: 2px;
}

.site-edition__button::after {
  content: "";
  width: 6px;
  height: 6px;
  /* Physical borders on purpose: the chevron is turned by a physical rotation, so logical sides would flip it in RTL. */
  border-bottom: 1.5px solid currentcolor;
  border-right: 1.5px solid currentcolor;
  opacity: 0.8;
  translate: 0 -2px;
  rotate: 45deg;
  transition:
    rotate 150ms ease,
    translate 150ms ease;
}

.site-edition__button[aria-expanded="true"]::after {
  translate: 0 2px;
  rotate: 225deg;
}

.site-edition__label {
  /* "2014 + 2024" keeps its order in a right-to-left page */
  direction: ltr;
  unicode-bidi: isolate;
}

/*
 * The mark says the state at a glance: a full disc for the newest rules, a ring for the 2014 rules, a half-filled disc
 * for both, and a dashed ring for a blocklist the reader set up by hand.
 */
.site-edition__mark {
  width: 10px;
  height: 10px;
  border: 1.5px solid currentcolor;
  border-radius: 50%;
  background: currentcolor;
}

.site-edition--2014 .site-edition__mark {
  background: none;
}

.site-edition--both .site-edition__mark {
  background: linear-gradient(to left, currentcolor 50%, transparent 50%);
}

.site-edition--custom .site-edition__mark {
  border-style: dashed;
  background: none;
}

/* -------------------------------------------- */
/* The menu */

.site-edition__menu {
  position: absolute;
  z-index: 1100;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: min(320px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--edition-rule);
  border-radius: 14px;
  background: var(--edition-card);
  box-shadow: var(--edition-shadow);
  color: var(--edition-ink);
  text-align: start;
  animation: site-edition-open 140ms ease-out;
}

.site-edition__menu[hidden] {
  display: none;
}

@keyframes site-edition-open {
  from {
    opacity: 0;
    translate: 0 -4px;
  }
}

.site-edition__menu-title {
  margin: 4px 10px 6px;
  color: var(--edition-muted);
  font-size: 12px;
}

.site-edition__note {
  margin: 0 4px 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--edition-note);
  font-size: 12px;
  line-height: 1.7;
}

.site-edition__choice {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

/* The radio dot of each choice, filled for the rules the site shows now. */
.site-edition__choice::before {
  content: "";
  grid-row: 1 / span 2;
  width: 14px;
  height: 14px;
  margin-block-start: 4px;
  border: 1.5px solid var(--edition-muted);
  border-radius: 50%;
}

.site-edition__choice:hover,
.site-edition__choice:focus-visible {
  background: var(--edition-hover);
  outline: none;
}

.site-edition__choice[aria-checked="true"] {
  background: var(--edition-tint);
  cursor: default;
}

.site-edition__choice[aria-checked="true"]::before {
  border-color: var(--edition-accent);
  background: radial-gradient(circle, var(--edition-accent) 45%, transparent 50%);
}

.site-edition__choice-title {
  font-size: 14px;
  font-weight: 700;
}

.site-edition__choice[aria-checked="true"] .site-edition__choice-title {
  color: var(--edition-accent);
}

.site-edition__choice-text {
  grid-column: 2;
  color: var(--edition-muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.site-edition__link {
  margin: 6px 4px 2px;
  padding: 8px 6px 2px;
  border-block-start: 1px solid var(--edition-rule);
  color: var(--edition-muted);
  font-size: 12px;
}

.site-edition__link:hover {
  color: var(--edition-accent);
}

/* -------------------------------------------- */
/* On a phone */

/*
 * The fork hides its header at this width (.ve-mobile-sm__hidden in css/main.css), so the navbar list gets one more
 * item, drawn as its neighbours are (the fork's `.nav > li > a` boxes, 33px tall): the label where their text sits and
 * a three-way switch at the far end. The fork's "Menu" button adds .ve-block, which is `display: block !important`, to
 * every .page__nav-hidden-mobile item to show it, so the layout lives on the bar inside the item.
 */
.site-edition__row {
  display: none;
  font-family: inherit;
}

/* Between the header and the phone layout both are visible; the header's control is the one to keep. */
@media (width > 768px) {
  li.site-edition__row {
    /* biome-ignore lint/complexity/noImportantStyles: overrides the fork's `.ve-block`, which is `display: block !important` */
    display: none !important;
  }
}

@media (width <= 768px) {
  .site-edition__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 33px;
    padding-inline: 14px 3px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  :root.ve-night-mode .site-edition__bar {
    border-color: rgb(85 85 85 / 63%);
    background: #222;
    color: #bbb;
  }

  .site-edition__switch {
    display: flex;
    gap: 2px;
  }

  .site-edition__segment {
    padding: 2px 10px;
    border: 0;
    border-radius: 3px;
    background: none;
    color: var(--edition-muted);
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition:
      background-color 150ms ease,
      color 150ms ease;
  }

  .site-edition__segment:hover {
    background: var(--edition-hover);
  }

  .site-edition__segment[aria-checked="true"] {
    background: var(--edition-tint);
    color: var(--edition-accent);
    font-weight: 700;
    cursor: default;
  }

  .site-edition__segment:focus-visible {
    outline: 2px solid var(--edition-accent);
    outline-offset: -2px;
  }

  .site-edition__row-note {
    margin: 0;
    padding: 4px 14px 2px;
    color: var(--edition-muted);
    font-size: 12px;
    line-height: 1.7;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-edition__button,
  .site-edition__button::after,
  .site-edition__segment,
  .site-edition__menu {
    transition: none;
    animation: none;
  }
}

@media print {
  .site-edition {
    display: none;
  }
}

/* -------------------------------------------- */
/*
 * The notice above an entry the reader opened by a link while the lists hide it (js/site-edition.js
 * `hiddenNoticeHtml`). It replaces the fork's one red line, so it has to be seen before the entry is read.
 */

.site-hidden {
  --hidden-ink: #1d1b19;
  --hidden-muted: #5c544b;
  --hidden-accent: #8a2c1b;
  --hidden-on-accent: #fff;
  --hidden-fill: #fbf0e0;
  --hidden-line: rgb(138 44 27 / 35%);

  display: grid;
  gap: 4px;
  margin-block: 4px 8px;
  padding: 12px 16px;
  border: 1px solid var(--hidden-line);
  border-inline-start-width: 4px;
  border-inline-start-color: var(--hidden-accent);
  border-radius: 8px;
  background: var(--hidden-fill);
  color: var(--hidden-ink);
  font-size: 14px;
  line-height: 1.6;
  text-align: start;
}

:where(:root.ve-night-mode) .site-hidden {
  --hidden-ink: #ece7e1;
  --hidden-muted: #b8b0a7;
  --hidden-accent: #e0604a;
  --hidden-on-accent: #1a1a1a;
  --hidden-fill: rgb(224 96 74 / 12%);
  --hidden-line: rgb(224 96 74 / 40%);
}

.site-hidden p {
  margin: 0;
}

.site-hidden__title {
  color: var(--hidden-accent);
  font-size: 15px;
  font-weight: 700;
}

.site-hidden__text {
  color: var(--hidden-muted);
}

.site-hidden__label {
  font-weight: 600;
}

.site-hidden__action {
  justify-self: start;
  margin-block-start: 6px;
  padding: 4px 14px;
  border: 1px solid var(--hidden-accent);
  border-radius: 999px;
  background: var(--hidden-accent);
  color: var(--hidden-on-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.site-hidden__action:hover,
.site-hidden__action:focus {
  color: var(--hidden-on-accent);
  text-decoration: none;
  filter: brightness(1.08);
}

.site-hidden__action:focus-visible {
  outline: 2px solid var(--hidden-accent);
  outline-offset: 2px;
}

/* A hover window is a glance: the notice keeps its title, and an older printing its link to the newer one. */
.hwin .site-hidden {
  padding: 6px 10px;
  font-size: 13px;
}

.hwin :is(.site-hidden__text, .site-hidden__action) {
  display: none;
}

@media print {
  .site-hidden {
    display: none;
  }
}

/* Upstream's Classic/Modern stat-block style in the Preferences window (fork js/utils-config/utils-config-registry.js,
   the setting whose name links to 2014.5e.tools): beside the rules control it read as a second edition switch.
   `site-chrome.js` moves a reader who chose Classic back to the default. The row's `.ve-split-v-center` sets `display`
   with `!important` inside the fork's `vetools` layer, which no rule outside the layer outranks, and its parent holds
   the other settings, so the row is taken out of the flow and out of sight instead. */
.ve-ui-modal__inner label:has(a[href*="2014.5e.tools"]) {
  position: absolute;
  visibility: hidden;
}
