/* The paid troops calculator in the other languages (website translation, part 3a, task 7).

   Linked by web/troops/index.php for a translated page only (<html lang> not "en"), after the calculator's own
   stylesheets (rpg-theme.css, tbc-theme.css). English never loads this file, and neither does the free
   /troops-calculator (free_page.php streams the same app.html but never links it). Every rule is also scoped to a
   translated page or to dir="rtl" (tests/portal_nav/test_troops_i18n_layout.py), so a copy linked by mistake still
   could not change an English page. */

/* ── Every translated page: longer words ─────────────────────────────────────
   Measured in every language at 1440 px and on a phone (the page sets its phone viewport to 820 px). */

/* A switch's segment keeps its words on one line ("8 ODDZIAŁÓW", not "8 / ODDZIAŁÓW"); the row the switch sits in
   wraps instead (the Kill Order title, the Category Order title, the Expected Damage head), the switch going under
   the title, at the row's far end, when both no longer fit side by side. */
html[lang]:not([lang="en"]) :is(.mode-toggle > span, .tier-mode-segment, .category-mode-segment, .mb-btn) {
    white-space: nowrap;
}
html[lang]:not([lang="en"]) :is(#killOrderSection > h2, .kill-order-col > h3, .expected-damage-head) {
    flex-wrap: wrap;
    row-gap: 0.4rem;
}
html[lang]:not([lang="en"]) .kill-order-toggles { flex-wrap: wrap; justify-content: flex-end; row-gap: 0.4rem; }
/* The Expected Damage switch alone is wider than its column on a phone even on a line of its own ("DENGAN TENTARA
   BAYARAN"): it keeps to the column and its segments' words wrap inside them, as English's already do there
   ("WITHOUT / MERCS"). */
html[lang]:not([lang="en"]) #expectedMercToggle { max-width: 100%; }
html[lang]:not([lang="en"]) #expectedMercToggle > span { white-space: normal; text-align: center; }

/* The tier labels beside the troop cards ("Ingenieurkorps", "Dschungelwächter:") break at a hyphenation point in
   their fixed column, or anywhere as the last resort (a language the browser cannot hyphenate). */
html[lang]:not([lang="en"]) :is(.group-label, .tier-group-label) {
    -webkit-hyphens: auto;
    hyphens: auto;
    overflow-wrap: anywhere;
}

/* The four columns of troop cards stay four equal columns: a long troop name ("Pojedynkowicz II:") breaks inside its
   card instead of widening its column, and with it its row, past the panel. */
html[lang]:not([lang="en"]) :is(.troop-columns, .extra-categories-container, .engineer-corps-container,
                                 .column-headers-container) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
html[lang]:not([lang="en"]) :is(.troop-name, .column-header) {
    -webkit-hyphens: auto;
    hyphens: auto;
    overflow-wrap: anywhere;
}

/* The wizard's H / S labels sit in a column one letter wide ("HP" in Indonesian was cut by its field). */
html[lang]:not([lang="en"]) .wz-sub-label { width: auto; min-width: 1em; flex-shrink: 0; text-align: center; }

/* Help texts (495 px, hidden until their icon is hovered) open centred on their icon, and one near the screen's edge
   ran past it: the whole page then scrolled sideways, hidden box included (in English too: 1498 px of page on a
   1440 px screen, 823 on a phone; a translated title moves its icon: 1475 px in German at 1440, 858 on a German phone,
   which also pushed Copy All and the phone bar's last button past the screen). On a translated page none leaves the
   page:
   - the titles across a whole panel (Troops Selection, Kill Order, the three result panels) and the two at the top of
     the Category Order column (its title, Expected Damage) hold their help text in their own box, at the start of a
     panel's title and at the end of the column's, wherever a longer or shorter title puts the icon; the small arrow,
     which could no longer point at the icon, is left out;
   - the input panels' titles keep it under the icon: centred while the panels are stacked, and with the three side by
     side the outer two open inwards, the arrow kept under the icon (18 px wide: its middle 21 px from the box's
     edge). */
html[lang]:not([lang="en"]) :is(.selection-section > h2, .result-section > h2, .kill-order-categories > h3,
                                 .expected-damage-head) {
    position: relative;
}
html[lang]:not([lang="en"]) :is(.selection-section > h2, .result-section > h2, .kill-order-categories > h3,
                                 .expected-damage-head) .tooltip-wrapper {
    position: static;
}
html[lang]:not([lang="en"]) :is(.selection-section > h2, .result-section > h2) .tooltip-text {
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    transform: none;
}
html[lang]:not([lang="en"]) :is(.kill-order-categories > h3, .expected-damage-head) .tooltip-text {
    top: calc(100% + 8px);
    left: auto;
    right: 0;
    transform: none;
}
html[lang]:not([lang="en"]) :is(.selection-section > h2, .result-section > h2, .kill-order-categories > h3,
                                 .expected-damage-head) .tooltip-text::after {
    display: none;
}
@media (min-width: 1101px) {
    html[lang]:not([lang="en"]) .input-section:first-child h2 .tooltip-text { left: -12px; right: auto; transform: none; }
    html[lang]:not([lang="en"]) .input-section:first-child h2 .tooltip-text::after { left: 15px; right: auto; transform: none; }
    html[lang]:not([lang="en"]) .input-section:last-child h2 .tooltip-text { left: auto; right: -12px; transform: none; }
    html[lang]:not([lang="en"]) .input-section:last-child h2 .tooltip-text::after { left: auto; right: 15px; transform: none; }
}
/* Right to left, each from the other side. */
html[dir="rtl"]:not([lang="en"]) :is(.selection-section > h2, .result-section > h2) .tooltip-text { left: auto; right: 0; }
html[dir="rtl"]:not([lang="en"]) :is(.kill-order-categories > h3, .expected-damage-head) .tooltip-text { right: auto; left: 0; }
@media (min-width: 1101px) {
    html[dir="rtl"]:not([lang="en"]) .input-section:first-child h2 .tooltip-text { left: auto; right: -12px; }
    html[dir="rtl"]:not([lang="en"]) .input-section:first-child h2 .tooltip-text::after { left: auto; right: 15px; }
    html[dir="rtl"]:not([lang="en"]) .input-section:last-child h2 .tooltip-text { right: auto; left: -12px; }
    html[dir="rtl"]:not([lang="en"]) .input-section:last-child h2 .tooltip-text::after { right: auto; left: 15px; }
}

/* ── Arabic: right to left ───────────────────────────────────────────────────
   <html dir="rtl"> turns every row and grid by itself; these are the boxes rpg-theme.css and tbc-theme.css place by
   left and right. Arabic letters join, so no letter-spacing on Arabic text (part 2a's rule; it also beats the right-
   click menu's inline spacing). */
html[dir="rtl"] :lang(ar) { letter-spacing: 0 !important; }

/* A troop card's switch: on, its knob at the left (towards the start, as part 2b's switches). It stays at the card's
   top right: at the left, a phone's narrow card put it over the tier badge drawn in the portrait's top left corner. */
html[dir="rtl"] .troop-toggle::after { left: 18px; }
html[dir="rtl"] .troop-toggle[aria-checked="true"]::after { left: 2px; }

/* What a row pushes to its far end with margin-left: auto (the "X / Y used" pills, the Kill Order and Category
   Order switches, Monsters Boost, Adjust All Troops, the Expected Damage switch, whose auto margin is inline) goes
   to the left end; the wizard's Cancel to the right end, Back and Next to the left. */
html[dir="rtl"] :is(.header-used-pill, .kill-order-toggles, .category-mode-toggle, .mb-options, .aa-chips) {
    margin-left: 0;
    margin-right: auto;
}
html[dir="rtl"] #expectedMercToggle { margin-left: 0 !important; margin-right: auto; }
html[dir="rtl"] .wizard-btn-cancel { margin-right: 0; margin-left: auto; }

/* Copy All floats at the bottom left. */
html[dir="rtl"] .copy-all-btn { right: auto; left: 30px; }

/* Switches made of segments: the line between two segments, and the rounded outer corners, on the other side. */
html[dir="rtl"] :is(.mode-toggle span + span, .tier-mode-segment + .tier-mode-segment,
                    .category-mode-segment + .category-mode-segment, .mb-btn + .mb-btn) {
    border-left: 0;
    border-right: 1px solid var(--tbc-border);
}
html[dir="rtl"] :is(.tier-mode-segment, .category-mode-segment, .mode-toggle > span):first-child {
    border-radius: 0 3px 3px 0;
}
html[dir="rtl"] :is(.tier-mode-segment, .category-mode-segment, .mode-toggle > span):last-child {
    border-radius: 3px 0 0 3px;
}

/* Spacing written on one side: the icon before a card's title, the colon-label before the Attacks buttons, the
   small note after a wizard label. */
html[dir="rtl"] .card-icon { margin-right: 0; margin-left: 0.4rem; }
html[dir="rtl"] :is(.multiplier-bar .label, .multiplier-label) { margin-right: 0; margin-left: 0.5rem; }
html[dir="rtl"] .wz-label small { margin-left: 0; margin-right: 0.3rem; }

/* Text aligned to the left in English reads from the right: help texts, the welcome title; the wizard summary's
   values go to the row's far end (the left). */
html[dir="rtl"] :is(.tooltip-text, .welcome-message h2) { text-align: right; }
html[dir="rtl"] .wz-summary-value { text-align: left; }

/* The wizard's Back and Next chevrons point the way they go (Next towards the left). */
html[dir="rtl"] .wizard-btn :is(.fa-chevron-left, .fa-chevron-right) { transform: scaleX(-1); }
