/*
 * codetip.css - the code cards (codetip.js): ligand, PDB and UniProt cards, one card that
 * changes its rows. Paper, ink, rules and shadow are the --tt-* tokens in custom.css, and the
 * hover / pinned states copy #richtip's (richtip.css), so the cards read and behave as one family.
 */
#codetip {
    position: fixed; top: 0; left: 0;
    z-index: 1200;                       /* above #richtip (1000) and the seqsim modal (1100) */
    width: 240px; box-sizing: border-box; padding: 8px 10px;
    background: var(--tt-bg); color: var(--tt-fg);
    border: 1px solid var(--tt-border); border-radius: 6px;
    box-shadow: var(--tt-shadow);
    font-size: 12px; line-height: 1.45; text-align: left;
    pointer-events: none;                /* a hover preview; pinned, it takes clicks */
    opacity: 0; visibility: hidden;
    transition: opacity 80ms ease-out, visibility 0s linear 80ms;
}
#codetip[data-show="1"] { opacity: 1; visibility: visible; transition: opacity 80ms ease-out; }
#codetip[data-pinned] { pointer-events: auto; border-color: var(--tt-pinned); }
#codetip[data-show="1"]:not([data-pinned])::after {
    content: "click to pin"; display: block; margin-top: 4px;
    color: var(--tt-faint); font-size: 10px; font-style: italic;
    text-align: right; letter-spacing: 0.04em;
}
/* the pin richtip shows on a pinned card; escaped, as everything here stays ASCII */
#codetip[data-pinned] .ct-links::before { content: "\1F4CC"; margin-right: -6px; }

#codetip .ct-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
#codetip .ct-code {
    flex-shrink: 0; padding: 0 5px; border-radius: 3px;
    background: var(--tt-inset); color: var(--tt-title);
    font-family: "Roboto Mono", monospace; font-size: 11.5px; font-weight: 600;
}
#codetip .ct-name { color: var(--tt-title); font-weight: 600; overflow-wrap: anywhere; }
/* a PDB entry's title runs long (three lines of it are shown) and a protein card has four
   links and "131 binding sites at threshold 1.00" on one line: both cards are wider */
#codetip[data-kind="pdb"] { width: 280px; }
#codetip[data-kind="unp"] { width: 290px; }
#codetip[data-kind="pdb"] .ct-name {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3;
    overflow: hidden; font-weight: 500;
}
#codetip[data-kind="pdb"] .ct-key { flex-basis: 5.8em; }
#codetip[data-kind="unp"] .ct-key { flex-basis: 4.9em; }  /* "Organism" */
/* wwPDB writes the classification in capitals ("DNA BINDING PROTEIN/DNA"): kept, but small */
#codetip .ct-class { font-size: 10.5px; letter-spacing: 0.03em; }

#codetip .ct-fig {
    position: relative; height: 150px; margin: 4px 0 6px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--tt-rule); border-radius: 4px; background: var(--tt-bg);
}
#codetip .ct-fig[hidden] { display: none; }
#codetip .ct-fig img { max-width: 100%; max-height: 100%; object-fit: contain; }
#codetip .ct-fig--loading img { visibility: hidden; }
#codetip .ct-fig > .ct-spin { position: absolute; margin: 0; }
#codetip .ct-fig:not(.ct-fig--loading) > .ct-spin { display: none; }

#codetip .ct-row { display: flex; gap: 10px; padding: 1px 0; }
#codetip .ct-key { flex: 0 0 5.4em; color: var(--tt-muted); }
#codetip .ct-val { color: var(--tt-fg); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#codetip .ct-val sub { font-size: 0.75em; }
#codetip .ct-val a { color: var(--tt-accent); text-decoration: none; }
#codetip .ct-val a:hover { text-decoration: underline; }
#codetip .ct-status { display: flex; align-items: center; color: var(--tt-muted); font-style: italic; }
#codetip .ct-note { margin-top: 4px; color: var(--tt-muted); font-size: 11px; }
#codetip .ct-note b { color: var(--tt-fg); font-weight: 600; }

#codetip .ct-spin {
    display: inline-block; width: 10px; height: 10px; margin-right: 6px; flex-shrink: 0;
    border: 2px solid var(--tt-track); border-top-color: var(--tt-accent); border-radius: 50%;
    animation: ct-spin 0.8s linear infinite;
}
@keyframes ct-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #codetip .ct-spin { animation-duration: 2.4s; } }

#codetip .ct-links {
    display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 6px; padding-top: 5px;
    border-top: 1px solid var(--tt-rule); font-size: 11px;
}
#codetip .ct-links a { color: var(--tt-accent); text-decoration: none; white-space: nowrap; }
#codetip .ct-links a:hover { text-decoration: underline; }
/* the site's link markers: the arrow leaves the site, the chevron stays on it */
#codetip .ct-links a.ct-ext::after { content: " \2197"; font-size: 0.85em; color: var(--tt-faint); }
#codetip .ct-links a.ct-own::after { content: " \203A"; }

/* a code: plain text that answers to pointing, marked by a dotted underline in the cards' accent
   (the help words' dotted underline is in the ink: a definition there, data here), solid under
   the pointer. A click pins its card, so it takes the hand (as Bootstrap gives every
   role="button"), never richtip's question mark. */
[data-lig], [data-pdb], [data-unp] {
    cursor: pointer;
    /* longhands: without the --tt-* tokens only the colour is lost (currentColor), not the mark */
    text-decoration-line: underline;
    text-decoration-style: dotted;
    text-decoration-color: color-mix(in srgb, var(--tt-accent) 65%, transparent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}
[data-lig]:hover, [data-pdb]:hover, [data-unp]:hover {
    text-decoration-style: solid; text-decoration-color: var(--tt-accent);
}
[data-lig]:focus-visible, [data-pdb]:focus-visible, [data-unp]:focus-visible {
    outline: 2px solid var(--tt-pinned); outline-offset: 1px; border-radius: 2px;
}
