/* One geometry for pronunciation ruby; standalone Hangul tone marks are separate. */
:is(rt, .tli-rt, .entry-headword-reading, rp) {
  -webkit-user-select: none;
  user-select: none;
}
.selecting-ruby :is(rt, .tli-rt, .entry-headword-reading) {
  -webkit-user-select: text;
  user-select: text;
}

:root {
  --tli-ruby-size: 0.55em;
  --tli-ruby-overlap: 0.05em;
  --tli-ruby-block-space: calc(var(--tli-ruby-size) * 1.1);
  --tli-ruby-hit-top: 0.45em;
  --tli-ruby-hit-side: 0.4em;
}

:is(.tli-reading-ruby, .entry-headword-ruby) {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  line-height: 1;
  text-indent: 0;
  isolation: isolate;
}

:is(.tli-reading-ruby > .tli-ruby-base, .entry-headword-base) {
  line-height: 1;
}

:is(.tli-reading-ruby > .tli-rt, .entry-headword-ruby > .entry-headword-reading) {
  position: absolute !important;
  display: block;
  top: auto !important;
  bottom: calc(100% - var(--tli-ruby-overlap)) !important;
  left: 50% !important;
  right: auto !important;
  width: max-content;
  margin: 0;
  /* Expand upward and sideways, leaving the glyphs and base-text hit area in place. */
  padding: var(--tli-ruby-hit-top) var(--tli-ruby-hit-side) 0;
  z-index: 2;
  transform: translateX(-50%) !important;
  font-size: var(--tli-ruby-size) !important;
  line-height: 1.15 !important;
  text-indent: 0;
  text-align: center;
  white-space: nowrap;
}

.tli-reading-ruby {
  white-space: nowrap;
}

/* Hangul readings ending in a tone mark: centre on the Hangul, not on the light mark after it. */
.tli-reading-ruby > .tli-rt.tli-rt-tone-end {
  transform: translateX(calc(-50% + 0.18em)) !important;
}

.tli-reading-ruby.bopomofo-title {
  --tli-ruby-size: 0.37em;
}

/* Lift Zhuyin readings by one CSS pixel in titles, lyrics and editor previews. */
.tli-reading-ruby:is(.bopomofo-title, .tli-bopomofo-reading) > .tli-rt {
  bottom: calc(100% - var(--tli-ruby-overlap) + 1px) !important;
}

@media (pointer: coarse) {
  :root {
    --tli-ruby-hit-top: 0.7em;
    --tli-ruby-hit-side: 0.6em;
  }
}
