/*
 * The translation portal (/translate): its pages and the editor (js/translate.js). Built on the
 * theme's variables (theme.css), so it follows the light and dark themes and the accents.
 */

.tr-page {
    --tr-done: var(--accent-green);
    --tr-draft: #c27c0e;
    --tr-wait: var(--link);
    --tr-todo: var(--text-faint);
    --tr-error: #c62828;
    --tr-warn: #a16207;
    --tr-chip-bg: rgba(45, 125, 196, 0.12);
    --tr-chip-text: #1f5a94;
    --tr-tag-bg: rgba(150, 82, 133, 0.12);
    --tr-tag-text: #7b3f6c;
    font-size: 14px;
    line-height: 1.5;
    /* Laid out by its own width, not the window's: the sidebar takes 240px of a desktop window. */
    container: tr-page / inline-size;
}
[data-theme="dark"] .tr-page {
    --tr-draft: #f0b44c;
    --tr-error: #ff7b7b;
    --tr-warn: #f0c060;
    --tr-chip-bg: rgba(119, 191, 244, 0.16);
    --tr-chip-text: #a9d7f2;
    --tr-tag-bg: rgba(214, 140, 197, 0.16);
    --tr-tag-text: #e6b3d8;
}

.tr-page h1 { margin-top: 12px; }
.tr-muted { color: var(--text-muted); }
.tr-error { color: var(--tr-error); }
.tr-page code, .tr-page kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    color: var(--text-heading);   /* base.css paints code black on white: unreadable on the dark inset */
    overflow-wrap: anywhere;
}

/* ---------- the bar ------------------------------------------------------------------ */

.tr-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 4px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.tr-nav-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.tr-nav-link {
    padding: 6px 0;
    color: var(--link);
    font-weight: 600;
}
.tr-nav-link:hover { color: var(--link-hover); }
.tr-nav-link.is-active { color: var(--text-heading); }
.tr-nav-user { display: flex; align-items: center; gap: 8px; }
.tr-nav-name { font-weight: 600; }
.tr-inline-form { display: inline; margin: 0; }

.tr-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex: none;
    object-fit: cover;
    vertical-align: middle;
}
.tr-avatar-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

/* ---------- buttons ------------------------------------------------------------------ */

.tr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--bg-panel);
    color: var(--text);
    font: 600 13px/1.3 var(--font-body);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.tr-btn:hover { background: var(--bg-hover); }
.tr-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tr-btn:focus-visible, .tr-tab:focus-visible, .tr-item:focus-visible, .tr-box:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.tr-btn-small { padding: 3px 8px; font-size: 12px; }
.tr-btn-primary { background: var(--link); border-color: var(--link); color: #fff; }
.tr-btn-primary:hover { background: var(--link-hover); border-color: var(--link-hover); }
[data-theme="dark"] .tr-btn-primary { color: #0b0b0d; }
.tr-btn-ghost { background: transparent; border-color: transparent; color: var(--link); }
.tr-btn-ghost:hover { background: var(--bg-hover); }
.tr-btn-danger { border-color: var(--tr-error); color: var(--tr-error); }
.tr-btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.tr-btn-discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; }
.tr-btn-discord .sprite-icon { filter: none; }

.tr-badge {
    display: inline-block;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.tr-badge-warn { color: var(--tr-warn); border-color: var(--tr-warn); }

.tr-notice {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-inset);
    margin: 10px 0;
}
.tr-notice-warn { border-color: var(--tr-warn); }

/* ---------- the overview --------------------------------------------------------------- */

.tr-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin: 8px 0 16px;
}
.tr-hero-title { border: 0; padding: 0; margin: 8px 0; }
.tr-hero p { margin: 0 0 8px; }
.tr-steps { list-style: decimal; margin: 8px 0 0; padding-left: 20px; }
.tr-steps li { margin: 4px 0; }
.tr-section-title { margin-top: 22px; }

.tr-lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.tr-lang-card {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-panel);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tr-lang-card:hover { border-color: var(--link); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.tr-lang-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tr-lang-native { font-size: 18px; font-weight: 700; color: var(--text-heading); }
.tr-lang-english { font-size: 12px; color: var(--text-muted); }
.tr-lang-card-stats { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.tr-lang-card-stats b { color: var(--text); }

.tr-progress {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-inset);
    border: 1px solid var(--border);
}
.tr-progress-done { background: var(--tr-done); }
.tr-progress-draft { background: var(--tr-draft); }
.tr-progress-wide { height: 10px; max-width: 520px; margin: 6px 0; }

.tr-people { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 0; }
.tr-person { display: inline-flex; align-items: center; gap: 6px; }

.tr-callout { margin-top: 24px; }
.tr-callout-title { margin: 0 0 6px; font-size: 16px; }
.tr-callout p { margin: 4px 0; }

.tr-credits-lang h2 { margin-top: 18px; }

/* ---------- a language's page --------------------------------------------------------- */

.tr-lang-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 10px;
}
.tr-lang-title { border: 0; padding: 0; margin: 8px 0 4px; }
.tr-lang-title .tr-muted { font-size: 16px; font-weight: 400; }
.tr-lang-summary, .tr-lang-reviewers { margin: 2px 0; }
.tr-lang-head-side { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 420px; }

.tr-app {
    position: relative;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
    gap: 16px;
    align-items: start;
}

.tr-list-pane {
    position: sticky;
    top: calc(var(--header-h) + 8px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-h) - 24px);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-panel);
    min-width: 0;
}
.tr-filters { padding: 8px; border-bottom: 1px solid var(--border); }
.tr-tabs { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 8px; }
.tr-tab {
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: var(--link);
    font: 600 12px/1.4 var(--font-body);
    cursor: pointer;
}
.tr-tab:hover { color: var(--link-hover); }
.tr-tab.is-active { color: var(--text-heading); }
.tr-count { opacity: 0.75; font-weight: 400; margin-left: 2px; }
.tr-search-row { display: flex; gap: 6px; }
.tr-search-row .tr-search { flex: 1 1 auto; min-width: 0; }
.tr-search-row .tr-area { width: auto; flex: none; }

.tr-list { overflow-y: auto; flex: 1 1 auto; margin: 0; padding: 0; }
.tr-list.is-loading { opacity: 0.55; transition: opacity 0.1s 0.25s; }
.tr-list-empty { padding: 16px; color: var(--text-muted); }
.tr-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-bottom: 1px solid var(--border-chrome);
    background: transparent;
    color: var(--text);
    text-align: left;
    font: 13px/1.4 var(--font-body);
    cursor: pointer;
}
.tr-item:hover .tr-item-en { color: var(--link-hover); }
.tr-item.is-active { background: var(--emphasis-bg); box-shadow: inset 3px 0 0 var(--link); }
.tr-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--tr-todo); }
.tr-item.is-done .tr-dot { background: var(--tr-done); }
.tr-item.is-draft .tr-dot { background: var(--tr-draft); }
.tr-item.is-suggested .tr-dot { background: var(--tr-wait); }
.tr-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.tr-item-en, .tr-item-tr {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
.tr-item-tr { color: var(--text-muted); }
.tr-item-count {
    flex: none;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--tr-wait);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.tr-item .tr-nl + br { display: none; }   /* one line per row in the list */
.tr-ctx { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.tr-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-top: 1px solid var(--border); }
.tr-pager:empty { display: none; }

.tr-editor-pane { min-width: 0; }
/* The delay: a load that finishes quickly never dims, so moving between messages does not flicker. */
.tr-editor-pane.is-loading { opacity: 0.6; transition: opacity 0.1s 0.25s; }
.tr-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: 6px; }

.tr-detail > section { padding: 12px 0; }
.tr-detail > section + section { border-top: 1px solid var(--border); }
.tr-detail-nav { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.tr-permalink { margin-left: auto; font-size: 12px; }
.tr-label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin: 6px 0 4px; }
.tr-label:first-child { margin-top: 0; }
.tr-text { white-space: pre-wrap; word-break: break-word; }
.tr-text-source { font-size: 16px; line-height: 1.55; color: var(--text-heading); }
.tr-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.tr-facts b { color: var(--text); }
.tr-notes { margin: 8px 0 0; padding-left: 18px; list-style: disc; font-size: 13px; }
.tr-notes li { margin: 2px 0; }

.tr-diff { white-space: pre-wrap; margin: 4px 0 8px; font-size: 13px; }
.tr-diff del { background: rgba(198, 40, 40, 0.14); color: var(--tr-error); text-decoration: line-through; }
.tr-diff ins { background: rgba(46, 125, 50, 0.16); color: var(--tr-done); text-decoration: none; }

.tr-form-row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px; margin: 2px 0; }
.tr-form-label { font-size: 12px; color: var(--text-muted); }

.tr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: 12px; }
.tr-meta .tr-avatar { width: 20px; height: 20px; }
.tr-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }

.tr-suggestions ul, .tr-more ul { margin: 0; padding: 0; list-style: none; }
.tr-suggestion { padding: 8px 0; }
.tr-suggestion + .tr-suggestion { border-top: 1px solid var(--border-chrome); }
.tr-suggestion.is-rejected { opacity: 0.7; }
.tr-votes { display: inline-flex; align-items: center; gap: 2px; }
.tr-vote {
    width: 24px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-panel);
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
}
.tr-vote:hover:not(:disabled) { color: var(--link); border-color: var(--link); }
.tr-vote.is-on { background: var(--link); border-color: var(--link); color: #fff; }
.tr-vote:disabled { opacity: 0.4; cursor: default; }
.tr-score { min-width: 22px; text-align: center; font-weight: 700; }
.tr-reject-row { display: flex; gap: 6px; margin-top: 6px; }
.tr-reject-row[hidden] { display: none; }
.tr-reject-row input { flex: 1 1 auto; }

/* The box */
.tr-box-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin: 8px 0 4px; }
.tr-box-label:first-child { margin-top: 0; }
.tr-box {
    width: 100%;
    box-sizing: border-box;
    min-height: 56px;
    padding: 8px 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--input-text);
    font: 15px/1.5 var(--font-body);
    resize: vertical;
}
.tr-box:focus { border-color: var(--link); outline: none; }

/* The preview under each box: the message as the game draws it (translate.js, "the preview").
   Dark in both themes, like the game's panels and the wiki's tooltip cards, in the game's pixel
   font at a size it is drawn crisp at; plain text, no outline. */
.tr-preview {
    margin: 6px 0 10px;
    padding: 8px 12px 10px;
    background: var(--card-bg);
    color: var(--card-text);
    border: 1px solid #2a3440;
    border-radius: 6px;
}
.tr-preview-head, .tr-preview-caption {
    display: block;
    font: 600 12px/1.4 var(--font-body);
    color: #8593a3;
}
.tr-preview-head { margin-bottom: 5px; }
.tr-preview-caption { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #2a3440; }
.tr-preview-text {
    min-height: 1.45em;
    font: 16px/1.45 var(--font-display);
    color: #ffffff;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.tr-preview-en { opacity: 0.6; }
/* What the game fills in: a box with the placeholder's name, in the colour around it. */
.tr-pv-value {
    display: inline-block;
    margin: 0 1px;
    padding: 0 5px;
    border: 1px dashed currentColor;
    border-radius: 3px;
    font: 600 11px/1.5 var(--font-body);
    vertical-align: 2px;
    white-space: nowrap;
    opacity: 0.85;
    cursor: help;
}
.tr-pv-emote {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin: 0 1px;
    vertical-align: -0.15em;
    border-radius: 3px;
    background: #f2c14e;
    cursor: help;
}
.tr-insert { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 6px; font-size: 12px; }
.tr-problems { margin: 6px 0; padding: 0; list-style: none; font-size: 13px; }
.tr-problems li { margin: 2px 0; }
.tr-compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.tr-compose-locked { padding: 6px 0; }

/* Placeholders and tags, in the English and in the boxes' helpers */
.tr-ph, .tr-tag, .tr-brace {
    display: inline;
    padding: 0 3px;
    border-radius: 3px;
    border: 0;
    font: 600 0.92em/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--tr-chip-bg);
    color: var(--tr-chip-text);
    white-space: nowrap;
}
.tr-tag { background: var(--tr-tag-bg); color: var(--tr-tag-text); }
.tr-brace { background: var(--bg-inset); color: var(--text-muted); }
button.tr-ph, button.tr-tag, button.tr-nl { cursor: copy; }
button.tr-ph:hover, button.tr-tag:hover, button.tr-nl:hover { outline: 1px solid currentColor; }
.tr-nl { color: var(--text-faint); font-size: 0.85em; padding: 0 2px; }
button.tr-nl { border: 0; border-radius: 3px; background: none; }
.tr-sp { color: var(--tr-warn); font-weight: 700; }

.tr-more { margin: 8px 0; }
.tr-more > summary { cursor: pointer; font-weight: 600; color: var(--link); padding: 4px 0; }
.tr-more > ul > li { padding: 8px 0; border-top: 1px solid var(--border-chrome); }

.tr-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: min(560px, calc(100vw - 32px));
    padding: 10px 16px;
    border-radius: 6px;
    background: var(--text-heading);
    color: var(--bg-panel);
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 50;
}
.tr-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.tr-toast.is-bad { background: var(--tr-error); color: #fff; }

/* ---------- forms and tables (profile, admin) ----------------------------------------- */

.tr-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
.tr-table th, .tr-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-chrome); text-align: left; vertical-align: top; }
.tr-table th { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.tr-table-compact td { padding: 3px 6px; font-size: 12px; }
.tr-row-banned td { opacity: 0.75; }
.tr-settings, .tr-row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }
.tr-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
/* base.css lets every .search-input grow (flex: 1, min-width: 200px); these stay their size. */
.tr-input-short { width: 200px !important; flex: none !important; }
.tr-input-tiny { width: 70px !important; min-width: 0 !important; flex: none !important; }
.tr-log { margin: 4px 0 8px; padding-left: 18px; list-style: disc; font-size: 12px; color: var(--text-muted); }

.tr-prose h2 { margin-top: 20px; }
.tr-prose ul, .tr-prose ol { padding-left: 22px; margin: 6px 0; }
.tr-prose ul { list-style: disc; }
.tr-prose ol { list-style: decimal; }
.tr-prose li { margin: 4px 0; }

/* ---------- narrow: the list, or one message ------------------------------------------------ */

@container tr-page (max-width: 820px) {
    .tr-hero { grid-template-columns: 1fr; }
    .tr-app { grid-template-columns: 1fr; }
    .tr-list-pane { position: static; max-height: none; }
    .tr-list { max-height: 65vh; }
    .tr-app.is-editing .tr-list-pane { display: none; }
    .tr-app:not(.is-editing) .tr-editor-pane { display: none; }
    .tr-lang-head-side { justify-content: flex-start; }
    .tr-form-row { grid-template-columns: 1fr; gap: 0; }
}
