/* assets/graph.js (window.HSKGraph). Every colour is a styles.css token, so dark mode needs no rule here.
   The card keeps .hg-card for tests and charcard.js; `.ug .hg-card` undoes graph.css's floating pane,
   because here the card sits under the graph instead of over it. */
.ug { margin: 0; position: relative; font-family: var(--serif-body); color: var(--ink); }
.ug-q { font-family: var(--serif-display); font-size: 21px; line-height: 1.35; margin: 0 0 12px; max-width: 46em; text-wrap: pretty; }
.ug-zh { font-family: var(--han); font-size: .92em; }
.ug-svg { display: block; width: 100%; height: auto; overflow: visible; }

.ug-row { font: 600 9.5px/1 var(--serif-body); letter-spacing: .14em; fill: var(--ink-faded); stroke: var(--ug-bg, var(--paper)); stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; }
.ug-meter { fill: var(--hairline); }
.ug-meter-on { fill: var(--correct); }
.ug-e { fill: none; stroke: var(--ink-whisper); stroke-width: 1.1; opacity: .55; }
.ug-e-held { stroke: var(--ink-faded); opacity: .7; }
.ug-e-gate { stroke: var(--accent); stroke-dasharray: 3 3; opacity: .7; }
.has-sel .ug-e { opacity: .18; }
.has-sel .ug-e.on { opacity: 1; stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: none; }

.ug-n { cursor: pointer; --lv: var(--ink-faded); }
.ug-box { fill: var(--paper-raised); stroke: var(--hairline); stroke-width: 1; transition: stroke .15s, fill .15s; }
.ug-bar { fill: var(--lv); }
.ug-t-zh { font-family: var(--han); fill: var(--ink); }
.ug-t-en { fill: var(--ink-faded); }
.ug-t-title { font-family: var(--serif-display); font-weight: 600; fill: var(--ink); }
.ug-t-tag { font: 600 9.5px/1 var(--serif-body); letter-spacing: .12em; text-transform: uppercase; fill: var(--lv); }
.ug-dot { fill: var(--accent); }

.ug-m-held .ug-box, .ug-m-said .ug-box { fill: rgba(var(--ink-rgb), .07); stroke: transparent; }
.ug-m-said { --lv: var(--correct); }
.ug-m-next .ug-box { stroke: var(--accent); stroke-width: 1.6; }
.ug-m-near { --lv: var(--gold); }
.ug-m-near .ug-box { stroke: var(--gold); stroke-width: 1.4; stroke-dasharray: 4 3; }
.ug-m-near .ug-dot { fill: var(--gold); }
.ug-m-locked .ug-box, .ug-m-far .ug-box { fill: transparent; stroke-dasharray: 3 3; stroke: var(--ink-whisper); stroke-opacity: .55; }
.ug-m-locked .ug-t-zh, .ug-m-far .ug-t-zh { fill: var(--ink-faded); }
.ug-m-locked .ug-t-en, .ug-m-far .ug-t-en { fill: var(--ink-whisper); }
.ug-k-move { --lv: var(--accent); }
.ug-focus .ug-box { fill: var(--paper-raised); stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: none; filter: drop-shadow(0 6px 14px rgba(var(--shadow-rgb), .12)); }
.ug-more rect { fill: transparent; stroke: var(--hairline); stroke-dasharray: 2 3; }
.ug-more text { font-size: 12px; fill: var(--ink-faded); }

.ug-n:hover .ug-box, .ug-n.kf .ug-box { stroke: var(--ink); }
.ug-n.on .ug-box { stroke: var(--accent); stroke-width: 2; stroke-dasharray: none; }
.ug-n.kf .ug-box { stroke-width: 2.5; }
.ug-flash .ug-box { animation: ug-flash 1.2s ease-in-out 3; }
@keyframes ug-flash { 50% { fill: rgba(var(--gold-rgb), .35); } }

.ug-list { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; padding: 0; }
.ug-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-faded); margin: 6px 0 0; }
.ug-lg { display: inline-flex; align-items: center; gap: 6px; }
.ug-lg i { width: 14px; height: 10px; border-radius: 3px; border: 1px solid var(--hairline); background: var(--paper-raised); }
.ug-lg.ug-m-held i, .ug-lg.ug-m-said i { background: rgba(var(--ink-rgb), .1); border: 0; border-left: 3px solid var(--ink-faded); }
.ug-lg.ug-m-said i { border-left-color: var(--correct); }
.ug-lg.ug-m-next i { border: 1.5px solid var(--accent); }
.ug-lg.ug-m-near i { border: 1.5px dashed var(--gold); }
.ug-lg.ug-m-locked i, .ug-lg.ug-m-far i { background: transparent; border: 1px dashed var(--ink-whisper); }

.ug .hg-card { --c-ink: var(--ink); --c-body: var(--ink-faded); --c-mute: var(--ink-whisper); --c-line: var(--hairline);
  border: 1px solid var(--hairline); border-radius: 12px; color: var(--c-body); overflow: visible; position: relative; inset: auto; z-index: auto; width: auto; max-height: none; margin: 14px 0 0;
  background: var(--paper-raised); backdrop-filter: none; font-size: 14px; padding: 8px 18px 16px; max-width: 560px; }
.ug .hg-card:hover, .ug .hg-card:focus-within { box-shadow: none; background: var(--paper-raised); }
.ug .hg-card-grip { display: none; }
.ug .hg-card-close { position: absolute; top: 6px; right: 6px; background: none; border: 0; color: var(--c-mute); font-size: 16px; cursor: pointer; min-width: 40px; min-height: 40px; }
.ug .hg-card-close:hover { color: var(--c-ink); }
.ug .hg-card-level { --lv: var(--ink-faded); display: inline-flex; align-items: center; gap: 7px; margin: 10px 0 0; padding-right: 36px;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--c-body); }
.ug .hg-card-level::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--lv); }
.ug .hg-card-zh { font-family: var(--han); font-size: 26px; line-height: 1.3; color: var(--c-ink); margin: 6px 0 0; }
.ug-card-en, .ug-card-title { font-family: var(--serif-display); font-size: 18px; color: var(--c-ink); margin: 2px 0 8px; }
.ug-card-p { margin: 8px 0 4px; line-height: 1.5; }
.ug-links, .ug-lines { list-style: none; margin: 0; padding: 0; }
.ug-links li { padding: 3px 0; }
.ug-link { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; min-height: 32px; }
.ug-link span { font-family: var(--han); }
.ug-via { font-family: var(--han); color: var(--c-ink); }
.ug-lines li { padding: 8px 0; border-top: 1px solid var(--c-line); }
.ug-lines li:first-child { border-top: 0; }
.ug-lines p { margin: 0; }
.ug-line-zh { font-family: var(--han); font-size: 18px; color: var(--c-ink); }
.ug-line-py { font-style: italic; color: var(--c-mute); font-size: 13px; }
.ug-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ug-acts:empty { display: none; }
.ug-btn { font-size: 14px; padding: 9px 16px; min-height: 40px; }

@media (max-width: 480px) { .ug-q { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { .ug-box { transition: none; } .ug-flash .ug-box { animation: none; fill: rgba(var(--gold-rgb), .3); } }

.ugm { margin: 0 0 22px; padding: 0 0 18px; border-bottom: 1px solid var(--hairline); }
.ugm-head { font-family: var(--serif-display); font-size: 17px; line-height: 1.4; min-height: 1.4em; margin: 0 0 14px; color: var(--ink-faded); font-variant-numeric: tabular-nums; }
.ugm-head b { color: var(--accent); font-weight: 600; }
.ugm-box { position: relative; }
.ugm-svg { display: block; width: 100%; height: auto; overflow: visible; cursor: pointer; touch-action: manipulation; border-radius: 6px; }
.ugm-svg:focus { outline: none; }
.ugm-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.ugm-cv { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; }
.ugm-ring { fill: none; stroke: var(--accent); stroke-width: 1.6; pointer-events: none; transition: cx .25s ease, cy .25s ease; }
.ugm-hov { fill: none; stroke: var(--ink); stroke-width: 1.3; pointer-events: none; }
.ugm-cols { position: absolute; inset: 0; pointer-events: none; }
.ugm-col { position: absolute; pointer-events: auto; background: none; border: 0; border-radius: 6px; padding: 2px 0; margin: 0; cursor: pointer; color: var(--ink);
  font: 12px/1.3 var(--serif-body); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1px; font-variant-numeric: tabular-nums; }
.ugm-col b { font-weight: 600; letter-spacing: .02em; white-space: nowrap; line-height: 1.3; }
.ugm-col span { color: var(--ink-faded); font-size: 11px; }
.ugm-col:hover b, .ugm-col[aria-current] b { color: var(--accent); }
.ugm-col[aria-current] b { text-decoration: underline; text-underline-offset: 3px; }
.ugm-col:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ugm-tip { position: absolute; z-index: 2; margin: 0; width: max-content; max-width: min(260px, 100%); transform: translateY(calc(-100% - 10px)); pointer-events: none;
  background: var(--paper-raised); border: 1px solid var(--hairline); border-radius: 8px; padding: 6px 10px; font-size: 13.5px; line-height: 1.35; color: var(--ink);
  box-shadow: 0 6px 18px rgba(var(--shadow-rgb), .14); }
.ugm-tip.below { transform: translateY(14px); }
.ugm-tip [lang] { font-family: var(--han); }
.ugm-tip-k { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--ink-faded); }
.ugm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-faded); margin: 12px 0 0; }
.ugm-lg { display: inline-flex; align-items: center; gap: 6px; }
.ugm-lg i { width: 8px; height: 8px; border-radius: 50%; background: rgba(var(--ink-rgb), .13); }
.ugm-lg.ugm-held i { background: var(--ink); opacity: .78; }
.ugm-lg.ugm-here i { background: var(--accent); width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--accent); margin: 0 2px; }
.ugm-lg.ugm-near i { background: transparent; border: 1.3px solid var(--accent); }
@media (max-width: 639px) {
  .ugm-head { font-size: 15.5px; min-height: 2.8em; }
  .ugm-col { align-items: flex-start; text-align: left; padding: 0; }
  .ugm-col b { font-size: 11px; line-height: 1.15; }
  .ugm-col span { font-size: 10px; line-height: 1.1; }
}
@media (prefers-reduced-motion: reduce) { .ugm-ring { transition: none; } }
