/* ── Shared automatic-translation widgets ─────────────────────────────
   Used by resources/translate-client.js on every multi-lingual page.
   Markup contract:
     - translatable elements carry  data-translate-block="<block-id>"
     - the language bar is injected by the script before .t2b-logo-container
   Pure CSS here: no page-specific selectors, so any page can include it. */

.trn-spinner {
    color: var(--color-primary-3);
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Anti-English-flash: pages include a tiny inline head snippet that adds
   .trn-boot to <html> before first paint when a non-English language is
   saved; visibility:hidden keeps the layout at the source-text size (no
   jumping), and translate-client.js removes the class the moment it has
   swapped the source text for placeholders. While blocks stream in, the
   .trn-spinner wheel doubles as the generating indicator. */
html.trn-boot [data-translate-block] { visibility: hidden; }

.trn-spinner::before {
    content: '';
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    border-radius: 50%;
    border: 0.16em solid var(--color-primary-2);
    border-top-color: var(--color-accent-0);
    display: inline-block;
    animation: trn-spin 0.9s linear infinite;
}

@keyframes trn-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .trn-spinner::before { animation-duration: 2.5s; }
}

.trn-note {
    color: var(--color-primary-3);
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.75;
    cursor: help;
}

.trn-navgroup {
    display: inline-flex;
    align-items: center;
}

.trn-langbar {
    /* Fixed 5-per-row grid: nine languages + the ellipsis flow into two
       aligned rows of five (the popup child is position:absolute and thus
       not part of the grid). */
    display: grid;
    grid-template-columns: repeat(5, auto);
    column-gap: 0.7rem;
    row-gap: 0;
    justify-items: center;
    margin-right: 1.75rem;
    /* nudge the two rows up so the block optically centers with the logo */
    position: relative;
    top: -3px;
}

.trn-langbar button {
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    font-family: inherit;
    font-size: 1.05rem;
    font-variant: small-caps;
    color: #333;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    cursor: pointer;
    opacity: 0.8;
}

.trn-langbar button:hover { opacity: 1; }

.trn-langbar button[aria-current="true"] {
    font-weight: 700;
    opacity: 1;
    text-decoration-thickness: 0.12em;
}

/* Language popup behind the ellipsis: absolute so it takes no grid slot. */
.trn-lang-pop {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 0.15rem 1rem;
    justify-items: start;
    background: #ffffff;
    border: 1px solid var(--color-primary-2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 0.6rem 0.9rem;
    max-height: 60vh;
    overflow-y: auto;
    font-variant: normal;
}

.trn-lang-pop button {
    text-decoration: none;
    font-size: 0.95rem;
    text-align: left;
    white-space: nowrap;
}

/* display:grid above outranks the UA [hidden] rule, so hide explicitly */
.trn-lang-pop[hidden] {
    display: none;
}

.trn-lang-pop button:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

/* ── Model out of service (see translate-client.js health gating) ──────
   Languages the server cannot currently serve render greyed and inert:
   no underline, no pointer, unclickable. The current language (usually
   'en') keeps its bold current-mark styling but is disabled too, so the
   bar reads as plain status, not decoration. Fully cached languages
   stay normal buttons. */
.trn-langbar button[disabled],
.trn-lang-pop button[disabled],
.trn-langbar button[disabled][aria-current="true"] {
    color: #b6b6b6;
    opacity: 1;
    text-decoration: none;
    cursor: default;
    pointer-events: none;   /* also drops the hover raise and the tooltip */
    font-variant-caps: small-caps; /* unchanged; keeps the bar aligned */
}

/* The status message inside the banner: same line, visibly muted so the
   page does not read as broken. Which languages remain switchable is not
   spelled out here — the language bar above shows it, button by button. */
.lang-hint .trn-offline {
    opacity: 0.85;
}
