/* The kautian-mirror look (its src/styles.css), so the taigikeyboard.tw pages read
   as one site. Every state has its slot in the layout: nothing that appears
   shifts the page. */

/* Follows the system unless Appearance pins one. "auto" pins none. */
:root {
  color-scheme: light dark;
  /* ZenPen's `.yin` (light) and `.yang` (dark). */
  --bg: light-dark(#fdfdfd, #111111);
  --card: light-dark(#ffffff, #1c1c1e);
  --glass: light-dark(rgba(246, 246, 248, 0.72), rgba(44, 44, 46, 0.72));
  --text: light-dark(#111111, #fafafa);
  --secondary: light-dark(#6e6e73, #98989d);
  --border: light-dark(#d2d2d7, #3a3a3c);
  --field: light-dark(#fafafa, #2c2c2e);
  --hairline: light-dark(#e8e8ed, #38383a);
  --hover: light-dark(#f5f5f7, #2c2c2e);
  --accent: light-dark(#0071e3, #2997ff);
  --ring: light-dark(rgba(0, 113, 227, 0.15), rgba(41, 151, 255, 0.25));
  --menu-shadow: 0 4px 24px light-dark(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.5));
  --system-font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, "PingFang TC", "Noto Sans TC", Arial,
    sans-serif;
  --font: var(--system-font);
  /* ZenPen's `article`: the editor. */
  --editor-font: 22px / 30px var(--font);
  /* ZenPen's `section`. */
  --measure: 600px;
  --sidebar-width: 21rem;
  --candidate-size: 17px;
  --tps-cap-height: 2.75rem;
  --tps-keyboard-height: calc(4 * var(--tps-cap-height) + 1.25rem);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Set on the root with the rest of the settings, so `--font` needs no redefining
   in each rule that reads it. */
:root[data-font="openHuninn"] {
  --font: "jf-openhuninn", var(--system-font);
}

:root[data-font="iansui"] {
  --font: "Iansui", var(--system-font);
}

:root[data-font="genYoMin"] {
  --font: "GenYoMin2 TW", var(--system-font);
}

:root[data-font="genYoGothic"] {
  --font: "GenYoGothic2 TW", var(--system-font);
}

/* The markup's English holds the slots, unseen, until i18n.js has run; by then
   `header.js` has put back an edited title. */
:root:not([data-translated])
  :is([data-i18n], #title, .setting select, .setting input) {
  visibility: hidden;
}

* {
  box-sizing: border-box;
}

/* The scrollbar's room is kept, so a long page does not shift the centered one. */
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  margin: 0;
  padding: 4rem 1rem 2rem;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem / 1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ZenPen's page (zenpen.io): one centered column, the text filling the window. */
main {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: var(--measure);
}

/* ZenPen's `header`: 38px bold at the font's own line height, on the column's
   left, edited in place (`header.js`) with no box or ring. An emptied title
   keeps its line, so a click can write it again. */
h1 {
  min-height: 1lh;
  margin: 0;
  outline: none;
  font-size: 38px;
  font-weight: 700;
  line-height: normal;
  overflow-wrap: break-word;
}

button {
  border: 0;
  background: none;
  color: var(--secondary);
  font: inherit;
  cursor: pointer;
  transition:
    color 0.2s,
    background 0.2s;
}

button:hover {
  background: var(--hover);
  color: var(--text);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.corner-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

.corner-button svg {
  width: 18px;
  height: 18px;
}

/* Solid, so the docked sidebar's rows scroll behind it rather than through it. */
#sidebar-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  background: var(--bg);
}

#sidebar-toggle:hover {
  background: var(--hover);
}

#sidebar {
  inset: 0 auto 0 0;
  width: min(var(--sidebar-width), 85vw);
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 1rem 1.5rem 1.5rem;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--menu-shadow);
  transform: translateX(-100%);
  transition:
    transform 0.25s ease,
    overlay 0.25s allow-discrete,
    display 0.25s allow-discrete;
}

/* A column, so the footer can sit at its foot. */
#sidebar:popover-open {
  display: flex;
  flex-direction: column;
  transform: none;
}

@starting-style {
  #sidebar:popover-open {
    transform: translateX(-100%);
  }
}

#sidebar::backdrop {
  background: rgba(0, 0, 0, 0.3);
}

.sidebar-close {
  display: flex;
  justify-content: flex-end;
  margin: -0.25rem -0.5rem 0 0;
}

/* Docked, and out of the tab order while closed. `display: flex` overrides the
   closed popover's `none` so it can slide. Same width as sidebar.js. */
@media (min-width: 50rem) {
  #sidebar {
    position: fixed;
    display: flex;
    flex-direction: column;
    padding-top: 3.5rem;
    box-shadow: none;
    visibility: hidden;
    transition:
      transform 0.25s ease,
      visibility 0.25s;
  }

  .sidebar-close {
    display: none;
  }

  body {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
    transition: padding-left 0.25s ease;
  }

  /* Visible at once: a Tab into it must not wait for the slide. */
  :root[data-sidebar="open"] #sidebar {
    transform: none;
    visibility: visible;
    transition:
      transform 0.25s ease,
      visibility 0s;
  }

  :root[data-sidebar="open"] body {
    padding-left: calc(var(--sidebar-width) + 1.5rem);
  }
}

.sidebar-section {
  border-bottom: 1px solid var(--hairline);
}

.sidebar-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.sidebar-section summary::-webkit-details-marker {
  display: none;
}

.sidebar-section summary::after {
  content: "";
  width: 10px;
  height: 10px;
  background: url("chevron.svg") center / contain no-repeat;
  transform: rotate(-90deg);
  transition: transform 0.2s;
}

.sidebar-section[open] summary::after {
  transform: none;
}

.sidebar-section summary:focus-visible {
  border-radius: 6px;
}

.setting-group {
  margin: 0.75rem 0 0.25rem;
  color: var(--secondary);
  font-size: 0.8125rem;
  font-weight: 400;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
  font-size: 0.9375rem;
}

.setting + .setting {
  border-top: 1px solid var(--hairline);
}

.setting-nested {
  padding-left: 1rem;
}

/* The greyed keys tell a row that only reads from one that changes something. */
.setting-keys {
  color: var(--secondary);
  text-align: right;
  white-space: pre-wrap;
}

.setting small {
  display: block;
  color: var(--secondary);
  font-size: 0.8125rem;
}

.setting select {
  min-width: 0;
  max-width: 60%;
  padding: 0.25rem 1.125rem 0.25rem 0.25rem;
  border: 0;
  border-radius: 6px;
  background: url("chevron.svg") right center / 10px no-repeat;
  color: var(--secondary);
  font: inherit;
  text-align: right;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.setting select:hover {
  color: var(--text);
}

.setting input {
  flex: none;
  margin: 0;
  accent-color: var(--accent);
}

/* In place outside TPS, as the desktop menu keeps its row. */
.setting:has(:disabled) {
  color: var(--secondary);
}

/* The desktop panes' reset button; Save's format buttons share its look. */
.setting-reset,
.save-format {
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  font-size: 0.9375rem;
}

/* A row at the foot of its section. */
.setting-reset {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0.75rem;
}

.save-formats {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
}

.save-format {
  flex: 1;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.75rem;
  font-size: 0.9375rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.25rem;
  margin-top: 0.5rem;
}

#progress {
  width: 6rem;
  accent-color: var(--accent);
}

#load-slot {
  display: grid;
  align-items: center;
  justify-items: start;
  margin-right: auto;
}

#load-slot > * {
  grid-area: 1 / 1;
  visibility: hidden;
}

#load-slot[data-show="progress"] > #progress,
#load-slot[data-show="retry"] > #retry {
  visibility: visible;
}

/* No box: the text sits on the page, as in ZenPen. It takes the window's room
   left over, so the key panel stays on screen. */
#editor {
  position: relative;
  display: flex;
  /* A zero basis, not `1`'s 0%: against the body's indefinite height a percentage
     reads as the content, and the editor's text would stretch the page. */
  flex: 1 1 0;
  flex-direction: column;
  min-height: 14rem;
}

/* The editor (Lexical's root): not a flex container, which Lexical's blocks
   would break; `#editor` is. Lexical sets `white-space` itself. */
#text {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  /* ZenPen's `article` sits 22px under the title. */
  padding: 22px 0 0;
  outline: none;
  font: var(--editor-font);
  overflow-wrap: break-word;
}

#text[contenteditable="false"] {
  color: var(--secondary);
}

/* A blank line between blocks, as the textarea's text had between paragraphs.
   Line heights in px: the panel reads them, and `normal` reads as nothing. */
#text :is(p, h1, h2, h3, blockquote, ul, ol) {
  margin: 0 0 30px;
}

#text h1 {
  font-size: 34px;
  line-height: 42px;
}

#text h2 {
  font-size: 28px;
  line-height: 36px;
}

#text h3 {
  font-size: 24px;
  line-height: 32px;
}

#text blockquote {
  padding-left: 16px;
  border-left: 3px solid var(--border);
  color: var(--secondary);
}

#text :is(ul, ol) {
  padding-left: 1.5em;
}

#text .is-bold {
  font-weight: bold;
}

#text .is-italic {
  font-style: italic;
}

#text .is-underline {
  text-decoration: underline;
}

#text .is-link {
  color: var(--accent);
}

/* macOS Tahoe's candidate window (`CandidateMetrics.swift`, base values at 16 pt,
   chrome ratio 0.7). Every length follows `--candidate-size`, unrounded. */
#panel {
  --candidate-annotation: calc(var(--candidate-size) * 0.875);
  --candidate-index: calc(var(--candidate-size) * 0.625);
  --candidate-annotation-gap: calc(var(--candidate-size) * 0.4375);
  --candidate-index-gap: calc(var(--candidate-size) * 0.125);
  --candidate-padding-x: calc(var(--candidate-size) * 0.39375);
  --candidate-padding-y: calc(var(--candidate-size) * 0.525);
  --candidate-separator-inset: calc(var(--candidate-size) * 0.35);
  --candidate-row: calc(var(--candidate-size) + var(--candidate-padding-y));
  --candidate-radius: 16px;
  --candidate-highlight-inset: 4px;
  position: absolute;
  z-index: 1;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--candidate-radius);
  background: var(--glass);
  /* A ring, not a `border`: the expandable widths have no number for one. */
  box-shadow:
    0 0 0 1px var(--border),
    var(--menu-shadow);
  font-size: var(--candidate-size);
  line-height: 1.2;
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

/* One-line cells draw a capsule, two-line cells a fixed radius. */
#panel:has(.candidates[data-inline]) {
  --candidate-radius: calc(var(--candidate-row) / 2);
  --candidate-highlight-inset: 2px;
}

/* Hidden, but laid out: `#panel[hidden]` measures nothing, and the first key of
   a word measures before the panel is shown. */
#ruler {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  width: max-content;
  contain: layout style;
}

#ruler span {
  display: block;
  width: max-content;
  white-space: nowrap;
}

/* Reads as the line it sits on: the editor's font, its background over what
   the composition covers. */
#preedit {
  position: absolute;
  z-index: 1;
  width: max-content;
  max-width: 100%;
  background: var(--bg);
  font: var(--editor-font);
  text-decoration: underline var(--accent);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#preedit:empty {
  display: none;
}

#preedit span {
  color: var(--accent);
}

.list {
  display: flex;
}

.candidates {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.candidates:empty {
  display: none;
}

.candidates li {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template:
    "index text" auto
    "index annotation" auto / auto auto;
  align-content: center;
  align-items: center;
  column-gap: var(--candidate-index-gap);
  padding: calc(var(--candidate-padding-y) / 2) var(--candidate-padding-x);
  cursor: default;
}

.candidates .index {
  grid-area: index;
  min-width: calc(var(--candidate-index) + 2px);
  color: var(--secondary);
  font: var(--candidate-index) / 1 var(--system-font);
  text-align: center;
}

.candidates .text {
  grid-area: text;
  justify-self: center;
}

.candidates .annotation {
  grid-area: annotation;
  justify-self: center;
  color: var(--secondary);
  font-size: var(--candidate-annotation);
}

/* A cell with one script keeps its line in the middle of a two-line row. */
.candidates li:not(:has(.annotation)) .text {
  grid-row: 1 / -1;
}

.candidates li[data-literal] .index {
  display: none;
}

.candidates li[data-literal] .text,
.candidates li[data-literal] .annotation {
  grid-column: 1 / -1;
}

.candidates[data-vertical] {
  display: grid;
  grid-template-columns: auto auto auto;
}

/* Rows share their columns, so every annotation starts at one x. */
.candidates[data-vertical] li {
  grid-column: 1 / -1;
  grid-template: auto / subgrid;
  height: var(--candidate-row);
  padding-block: 0;
}

/* The packed row: `ExpandableListModel`'s widths and height, which is what the
   keys go by. */
.candidates[data-row] {
  flex-wrap: nowrap;
}

.candidates:is([data-row], [data-grid]) li {
  box-sizing: border-box;
  height: var(--candidate-item);
  min-width: 0;
  padding-block: 0;
  justify-content: center;
}

/* The unfolded grid. No scrollbar: a classic one takes a width the model has
   no number for, and the half row under the last full one says there is more.
   The hairlines scroll with the rows. */
.candidates[data-grid] {
  position: relative;
  display: grid;
  flex: none;
  box-sizing: border-box;
  grid-template-columns: repeat(
      var(--candidate-columns, 6),
      var(--candidate-column)
    );
  grid-auto-rows: var(--candidate-item);
  row-gap: 1px;
  align-content: start;
  height: var(--candidate-window);
  padding-bottom: var(--candidate-peek);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  background:
    repeating-linear-gradient(
      transparent 0 var(--candidate-item),
      var(--hairline) 0 calc(var(--candidate-item) + 1px)
    )
    0 0 / 100% var(--candidate-grid) no-repeat local;
}

.candidates[data-grid]::-webkit-scrollbar {
  display: none;
}

/* The row (or column) the keys number: `keyed_band_rect`. */
.candidates[data-grid]::before {
  content: "";
  position: absolute;
  top: var(--candidate-band-y);
  left: var(--candidate-band-x);
  width: var(--candidate-band-width);
  height: var(--candidate-band-height);
  background: var(--hairline);
}

.candidates[data-vertical] li + li {
  margin-top: 1px;
}

/* An unfolded column: every annotation at one x, as in the collapsed column. */
.candidates[data-grid][data-inline] li {
  grid-template: auto / auto minmax(var(--candidate-primary), auto) auto;
  justify-content: start;
}

.candidates[data-vertical] li + li::after {
  content: "";
  position: absolute;
  top: -1px;
  right: var(--candidate-separator-inset);
  left: var(--candidate-separator-inset);
  height: 1px;
  background: var(--hairline);
}

.candidates[data-inline] li .index {
  grid-area: auto / 1;
}

.candidates[data-inline] li .text {
  grid-area: auto / 2;
  justify-self: start;
}

.candidates[data-inline] li .annotation {
  grid-area: auto / 3;
  justify-self: start;
  margin-left: var(--candidate-annotation-gap);
}

.candidates[data-inline] li[data-literal] .text {
  grid-column: 1 / -1;
  justify-self: center;
}

.candidates li[aria-current="true"]::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: var(--candidate-highlight-inset);
  border-radius: calc(
    var(--candidate-radius) -
    var(--candidate-highlight-inset)
  );
  background: var(--accent);
}

.candidates li[aria-current="true"] > span {
  color: #ffffff;
}

/* `CandidatePageArrowView.swift`: a chevron tint marks a page to turn to. */
.page-arrows {
  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  justify-content: center;
  width: calc(var(--candidate-size) * 1.5);
}

.page-arrows[hidden] {
  display: none;
}

.page-arrows::before {
  content: "";
  position: absolute;
  top: calc(var(--candidate-separator-inset) / 2);
  bottom: calc(var(--candidate-separator-inset) / 2);
  left: 0;
  width: 1px;
  background: var(--hairline);
}

.page-arrows button {
  display: grid;
  flex: 1;
  place-items: center;
  padding: 0;
  background: none;
  color: var(--secondary);
  cursor: default;
}

.page-arrows button:disabled {
  opacity: 0.4;
}

.page-arrows button[hidden] {
  display: none;
}

.page-arrows svg {
  width: calc(var(--candidate-size) * 0.625);
  height: calc(var(--candidate-size) * 0.625);
}

.unfold[data-column] svg {
  rotate: -90deg;
}

/* The desktops' mode flash, a third of the way up the editor rather than the
   screen. Plain show and hide, as on Windows (`mode_flash.rs`). */
#mode-flash {
  position: absolute;
  bottom: calc(100% / 3);
  left: 50%;
  z-index: 2;
  max-width: calc(100% - 2rem);
  width: max-content;
  padding: 14px 28px;
  border-radius: 16px;
  background: var(--glass);
  box-shadow: var(--menu-shadow);
  font-size: 24px;
  font-weight: 500;
  text-align: center;
  translate: -50% 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

#notice {
  visibility: hidden;
}

#notice[data-active] {
  visibility: visible;
}

.action {
  flex: none;
  min-height: 2rem;
  padding: 0 0.75rem;
  border-radius: 8px;
  font-size: 0.9375rem;
}

.action svg {
  display: block;
  width: 1.0625rem;
  height: 1.0625rem;
}

/* Asked for, so it may move what is below the editor. `height` is set before
   the wasm arrives: the caps fill the room `prepaint.js` kept. */
#tps-keyboard {
  display: none;
  flex-direction: column;
  height: var(--tps-keyboard-height);
  margin-top: 0.5rem;
  gap: 0.25rem;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
}

:root[data-tps-keyboard] #tps-keyboard {
  display: flex;
}

/* The macOS Telex guide (`TelexGuidePanel.swift`): a small HUD card on the mode
   flash's chrome, floating over the editor's bottom centre as the macOS one floats
   over the screen's, so it moves nothing. Display-only: clicks go to the text under
   it, and the candidate panel draws over it. Unseen until the session spells it:
   a marker, not `:empty`, which Firefox does not re-match after `replaceChildren`. */
#telex-guide {
  position: absolute;
  bottom: 24px;
  left: 50%;
  z-index: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(360px, 100%);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--glass);
  box-shadow: var(--menu-shadow);
  font: 13px / 1.3 var(--system-font);
  -webkit-user-select: none;
  user-select: none;
  translate: -50% 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

:root[data-telex-guide] #telex-guide[data-drawn] {
  display: flex;
}

#telex-guide h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* Key | meaning. The key is monospaced semibold: a thing the user types, and the
   one the eye lands on. */
#telex-guide dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 16px;
  margin: 0;
}

#telex-guide dt {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
}

#telex-guide dd {
  margin: 0;
}

/* Twelve keys wide, the number row. `--indent` is the row's stagger. */
.tps-row {
  --tps-cap: min(3.25rem, 100cqw / 12);
  display: flex;
  flex: none;
  width: calc(12 * var(--tps-cap));
  margin-inline: auto;
  padding-left: calc(var(--indent) * var(--tps-cap));
}

/* Shift glyph top right, bare glyph below, as the desktop panels draw a cap; the
   top half is the Shift layer. */
.tps-cap {
  display: grid;
  grid-template: auto 1fr / 1fr 1fr;
  flex: none;
  width: var(--tps-cap);
  height: var(--tps-cap-height);
  padding: 0.125rem 0.1875rem;
  border-radius: 6px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text);
  font-size: 0.6875rem;
  line-height: 1.2;
  transition: none;
}

.tps-cap:hover {
  background: var(--hover);
}

.tps-cap span:not(:last-child) {
  color: var(--secondary);
}

.tps-cap span:nth-child(2) {
  text-align: right;
}

.tps-cap span:last-child {
  grid-column: 1 / -1;
  align-self: center;
  font-size: 1rem;
  text-align: center;
}

.tps-cap:active,
.tps-cap[data-lit] {
  background: var(--accent);
  color: #ffffff;
}

.tps-cap:active span,
.tps-cap[data-lit] span {
  color: inherit;
}

/* Read aloud, never drawn. Not `hidden`, which silences a live region. */
.unseen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  margin: 0;
  white-space: nowrap;
}

/* At the sidebar's foot, so it closes with the sidebar; `auto` holds it at the
   window's foot, and open sections push it down. */
footer {
  flex: none;
  margin-top: auto;
  padding-top: 2.5rem;
  color: var(--secondary);
  font-size: 13px;
  letter-spacing: -0.01em;
}

footer a {
  color: var(--secondary);
  transition: color 0.2s;
}

footer a:hover {
  color: var(--text);
  text-decoration: none;
}

footer p {
  margin: 0.25rem 0 0;
  text-align: center;
}

/* The official site's Issues icons, in the footer's quiet colour. */
.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.social-links a svg {
  flex: none;
  width: 15px;
  height: 15px;
}

/* Last, to outrank the docked `@media` block. The sidebar `prepaint.js` opened
   is there from the first frame, not slid in: `sidebar.js` sets
   `data-animated` once that frame is drawn. */
:root:not([data-animated]) :is(body, #sidebar) {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  body,
  button,
  #sidebar,
  :root[data-sidebar="open"] #sidebar {
    transition: none;
  }
}

/* The format bubble wears the candidate panel's glass. It shows where the
   selection is, over the text, so nothing slides and nothing below it moves. */
#format-bubble {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--glass);
  box-shadow:
    0 0 0 1px var(--border),
    var(--menu-shadow);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

#format-bubble[hidden] {
  display: none;
}

#format-bubble button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text);
  /* H1 to H3 are their own labels. */
  font: 600 13px var(--system-font);
  transition: none;
}

#format-bubble svg {
  width: 14px;
  height: 14px;
}

#format-bubble input {
  display: none;
  width: min(18rem, 60vw);
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  outline: none;
  background: var(--field);
  color: var(--text);
  font: 15px var(--system-font);
}

/* Link mode: the link button stays, the field takes the others' room. */
#format-bubble[data-mode="link"] button:not([data-markup="link"]) {
  display: none;
}

#format-bubble[data-mode="link"] input {
  display: block;
}
