/* Mingo - ui/kit.css (agent C): styles for the ui/kit.js widgets. Needs ui/theme.css first (tokens).
   Size hooks a page may set on a container: --zh-size (sentence Chinese), --en-size (sentence English),
   --cousin-r-size / --cousin-zh-size (Word Cousins). */

/* ---------- Word Cousins ---------- */
/* one row per language (ChineseCard SPEC 19): dot · label · the reading over its characters · and INLINE on the same row what people say
   (≈ X shifted, → X different); never a line under it */
.mg-cousins {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
  gap: var(--space-2) var(--space-3);
  font-family: var(--font-reading);
  color: var(--fg);
}
.mg-cousins-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 3.2em;
  padding-bottom: 0.35em;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--fg-2);
}
.mg-cousins-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--status-new); flex: none; }
.mg-cousins[data-state="same"] .mg-cousins-dot { background: var(--cognate-same); }
.mg-cousins[data-state="shifted"] .mg-cousins-dot { background: var(--cognate-shifted); }
.mg-cousins[data-state="different"] .mg-cousins-dot { background: var(--cognate-different); }

.mg-cousins-pairs { display: inline-flex; gap: 6px; }
.mg-cousin {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 2.6em;
}
/* each language's own colour (ui/theme.css --lang-*): the reading and the link's top dot */
.mg-cousins { --cousin-color: var(--accent-text); --cousin-mark: var(--accent-text); }
.mg-cousins[data-lang="hok"] { --cousin-color: var(--lang-hok-text); --cousin-mark: var(--lang-hok); }
.mg-cousins[data-lang="ja"] { --cousin-color: var(--lang-ja-text); --cousin-mark: var(--lang-ja); }
.mg-cousins[data-lang="ko"] { --cousin-color: var(--lang-ko-text); --cousin-mark: var(--lang-ko); }
.mg-cousins[data-lang="vi"] { --cousin-color: var(--lang-vi-text); --cousin-mark: var(--lang-vi); }
.mg-cousin-r {
  font-size: var(--cousin-r-size, var(--text-md));
  font-weight: var(--weight-semibold);
  color: var(--cousin-color);
  line-height: 1.2;
  white-space: nowrap;
}
.mg-cousins[data-lang="hok"] .mg-cousin-r,
.mg-cousins[data-lang="hok"] .mg-cousins-plain,
.mg-cousins[data-lang="hok"] .mg-cousins-target { font-family: var(--font-poj); }
.mg-cousin-link { display: block; margin: 2px 0; overflow: visible; }
.mg-cousin-link-top { fill: var(--cousin-mark); }
.mg-cousin-link-line { stroke: var(--border-strong); stroke-width: 2; stroke-dasharray: 3 2.5; fill: none; }
.mg-cousin-link-end { fill: var(--sun); }
.mg-cousin-zh {
  font-family: var(--font-zh);
  font-size: var(--cousin-zh-size, 26px);
  font-weight: 500;   /* the headword's own character, the same size, weight and face for every language */
  line-height: 1.15;
  color: var(--fg);
}
.mg-cousin-py { font-size: var(--text-xs); color: var(--fg-2); line-height: 1.3; }
.mg-cousins-plain {
  padding-bottom: 0.2em;
  font-size: var(--cousin-r-size, var(--text-md));
  font-weight: var(--weight-semibold);
  color: var(--cousin-color);
}
/* Japanese / Korean: kana / hangul on top in their own face; the romanization takes the same cell while the block is hovered or
   focused (both stacked in one grid area, so the width never changes and nothing moves) */
.mg-swap { display: inline-grid; justify-items: center; }
.mg-cousins-plain .mg-swap, .mg-cousins-says .mg-swap { justify-items: start; }
.mg-swap > * { grid-area: 1 / 1; }
.mg-swap-rom { visibility: hidden; font-family: var(--font-reading); }
.mg-cousins:hover .mg-swap-rom, .mg-cousins:focus-visible .mg-swap-rom { visibility: visible; }
.mg-cousins:hover .mg-swap-native, .mg-cousins:focus-visible .mg-swap-native { visibility: hidden; }
.mg-cousins[tabindex] { border-radius: var(--radius-sm); }
.mg-cousins[tabindex]:focus-visible { box-shadow: var(--focus-ring); }
.mg-cousins[data-state="different"] .mg-cousin-r,
.mg-cousins[data-state="different"] .mg-cousins-plain { color: var(--fg-2); }
.mg-cousins-says { flex: 0 1 auto; min-width: 0; padding-bottom: 0.3em; font-size: var(--cousin-r-size, var(--text-md)); color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-cousins-arrow { color: var(--fg-3); }
.mg-cousins[data-state="different"] .mg-cousins-arrow { color: var(--danger); }
.mg-cousins[data-state="different"] .mg-cousins-target { color: var(--fg); }
.mg-cousins-target :lang(zh) { font-family: var(--font-zh); }


/* ---------- status buttons: a segment track (New · Learning · Known) ---------- */
/* ChineseCard's segment (SPEC 51) with the status rings of SPEC 17/18: the track is a glass-in capsule; exactly ONE segment looks
   selected - the raised capsule (GlassInHover, hairline, the light from above, a soft lift) with its label in the text colour. The dot
   keeps its status colour in every state: a hollow ring, filled with that same colour when selected. Hover = a quiet ground change on
   the OTHER segments only; the selected one shows nothing and a click on it does nothing (kit.statusButtons). */
.mg-status {
  display: inline-flex;
  align-self: flex-start;
  width: max-content;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--glass-edge);
}
.mg-status-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--seg-h);
  height: var(--seg-h);
  min-width: 0;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}
/* the hit area reaches 44 px tall whatever the drawn height */
.mg-status-btn::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: var(--tap); transform: translateY(-50%); }
.mg-status-btn:hover { background: var(--fill-quiet); color: var(--fg); }
.mg-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--mg-st); background: transparent; flex: none;
}
.mg-status-btn[data-status="new"] { --mg-st: var(--status-new); }
.mg-status-btn[data-status="learning"] { --mg-st: var(--status-learning); }
.mg-status-btn[data-status="known"] { --mg-st: var(--status-known); }
.mg-status-btn[aria-pressed="true"],
.mg-status-btn[aria-pressed="true"]:hover {
  background: var(--surface-hover);
  border-color: var(--glass-edge);
  color: var(--fg);
  font-weight: var(--weight-semibold);
  cursor: default;
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 1px 2px rgba(0, 0, 0, 0.10);
}
.mg-status-btn[aria-pressed="true"] .mg-status-dot { background: var(--mg-st); }
.mg-status-btn:focus-visible { box-shadow: var(--focus-ring); }
.mg-status-btn[aria-pressed="true"]:focus-visible { box-shadow: inset 0 1px 0 var(--glass-hi), var(--focus-ring); }

/* ---------- sentence ---------- */
.mg-sentence { display: flex; flex-direction: column; gap: var(--space-3); }
.mg-zh {
  font-family: var(--font-zh);
  font-size: var(--zh-size, 24px);
  line-height: 1.9;
  color: var(--fg);
}
.mg-sentence[data-pinyin="off"] .mg-zh { line-height: 1.6; }
.mg-chunk { position: relative; border-radius: var(--radius-xs); outline: none; }
.mg-chunk + .mg-chunk { margin-left: 0.18em; }
.mg-w { display: inline; }
.mg-w + .mg-w { margin-left: 0.08em; }
.mg-chunk-lined .mg-core {
  text-decoration-line: underline;
  text-decoration-color: var(--chunk);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.28em;
  text-decoration-skip-ink: none;
}
.mg-target .mg-core { color: var(--accent-text); }
.mg-particle .mg-core, .mg-punct { color: var(--fg-3); }
.mg-zh ruby, .mg-zh rt { ruby-align: center; }
.mg-zh rt {
  font-family: var(--font-reading);
  font-size: max(10px, calc(var(--zh-size, 24px) * 0.5));
  font-weight: var(--weight-regular);
  color: var(--fg-3);
  letter-spacing: 0;
  line-height: 1.2;
  padding-bottom: 0.15em;
}
.mg-target rt { color: var(--accent-text); }
/* an atomic box: Chrome's ruby justification would otherwise pull a font-decomposed ā apart */
/* padding = a guard: two neighbouring pinyins wider than their words never touch (ChineseCard Size.RubyGuard) */
.mg-rt { display: inline-block; white-space: nowrap; padding: 0 0.2em; }

.mg-chunk[tabindex]:hover .mg-core, .mg-chunk[tabindex]:focus-visible .mg-core { background: var(--fill-quiet); border-radius: 3px; }
.mg-chunk[tabindex]:focus-visible { box-shadow: var(--focus-ring); }
.mg-gloss {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  z-index: 20;
  transform: translate(-50%, 0);
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-reading);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;   /* shown and hidden at once: never a fade (the owner) */
}
.mg-chunk:hover > .mg-gloss, .mg-chunk:focus-visible > .mg-gloss, .mg-chunk:focus > .mg-gloss {
  visibility: visible;
}
.mg-en {
  font-family: var(--font-reading);
  font-size: var(--en-size, var(--text-base));
  color: var(--fg-2);
  line-height: 1.5;
}
.mg-en-span {
  color: var(--fg);
  text-decoration-line: underline;
  text-decoration-color: var(--chunk);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* ---------- mark ---------- */
.mg-mark, .mg-glyph { display: inline-block; flex: none; vertical-align: middle; }
