/*
 * The translator page /translate (phase PN1 of docs/translator-plan-2026-10-13.md).
 *
 * The layout of the mockup mockups/translator-2026-10-13: two panes on a computer (variant A), one
 * column on a phone (variant C), aligned rows on demand (variant B). It styles the server form, so
 * the page looks the same with and without /assets/translator.js; the parts the script adds use the
 * `.tr-js` classes. Colours come from the shared shell's variables, so the light and dark themes and
 * the theme switch keep working; the soft tints are mixed from them where the browser can.
 */

.tr { --tr-surface: var(--bg); --tr-soft: var(--bg); --tr-hl: rgba(15, 122, 107, .18); --tr-hl-soft: rgba(15, 122, 107, .08); }
@supports (background: color-mix(in srgb, red 50%, blue)) {
  .tr {
    --tr-surface: color-mix(in srgb, var(--ink) 4%, var(--bg));
    --tr-soft: color-mix(in srgb, var(--brand) 12%, var(--bg));
    --tr-hl: color-mix(in srgb, var(--brand) 24%, transparent);
    --tr-hl-soft: color-mix(in srgb, var(--brand) 9%, transparent);
  }
}

/* The script hides the form and the panels with the `hidden` attribute; the shell's `.tr form
   { display: block }` would otherwise win over the browser's own rule for it. */
.tr [hidden] { display: none !important; }

.tr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; margin: 0 0 8px; }
.tr-top h2 { margin: 0; font-size: 21px; }
.tr-privacy { margin: 0; }
.tr-privacy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--brand); }

/* Pills: the direction radios of the form and the buttons the script adds. */
/* min-inline-size: a fieldset is as wide as its content by default, and on a phone the row of pills
   would widen the whole page instead of scrolling sideways. */
.tr .tr-dir { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; padding: 0; border: 0;
  min-width: 0; min-inline-size: 0; }
.tr .tr-dir legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tr-dir input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.tr-dir label, .tr-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink);
  font: 14px/1.2 system-ui, sans-serif; cursor: pointer; white-space: nowrap;
}
.tr-dir input:checked + label, .tr-pill[aria-pressed="true"] { border-color: var(--brand); background: var(--tr-soft); font-weight: 600; }
.tr-dir input:focus-visible + label { outline: 3px solid var(--brand); outline-offset: 2px; }
.tr-swap { min-width: 40px; justify-content: center; padding: 0 10px; font-size: 17px; }
.tr-detected { color: var(--muted); font-size: 13px; }

.tr-tabs, .tr-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.tr-tabs .tr-pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--button-ink); }

/* The two panes. */
.tr-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.tr-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 230px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.tr-label { display: block; padding: 10px 16px 0; color: var(--muted); font-size: 12.5px; }
.tr .tr-in textarea { flex: 1; min-height: 190px; margin: 0; padding: 8px 16px 14px; border: 0; border-radius: 14px;
  background: transparent; font: 17px/1.55 system-ui, sans-serif; resize: vertical; }
.tr .tr-in textarea:focus-visible { outline: none; }
.tr-in:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tr-bar, .tr-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 10px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; }
.tr-bar .tr-go { margin-left: auto; }
.tr-sp { flex: 1; }
.tr-acts { display: flex; gap: 2px; margin-left: auto; }
.tr-foot .tr-time { flex: 1 1 220px; }
.tr-count, .tr-time { font-variant-numeric: tabular-nums; }
.tr-res { background: var(--tr-surface); }
.tr-res > .tr-ph, .tr-res > section, .tr-res > .result-state { margin: 0; padding: 14px 16px; }
.tr-ph { color: var(--muted); }
.tr-res .tr-out { margin: 0; }

/* The live result the script writes. */
.tr-live { flex: 1; padding: 14px 16px; font-size: 17px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.tr-live p { margin: 0 0 6px; }
.tr-s { border-radius: 4px; }
.tr-s.tr-pending { color: var(--muted); }
.tr-s.tr-on, .tr-s:hover { background: var(--tr-hl); }
.tr-mark-line { padding: 0 16px 12px; margin: 0; }
.tr-icon { min-height: 36px; padding: 4px 10px; border: 1px solid transparent; border-radius: 8px; background: none;
  color: var(--ink); font: 13px/1.2 system-ui, sans-serif; cursor: pointer; }
.tr-icon:hover { border-color: var(--line); }

/* The sentence highlight behind the text field: a mirror of the text with the same metrics. */
.tr-field { position: relative; flex: 1; display: flex; }
.tr-mirror { position: absolute; inset: 0; margin: 0; padding: 8px 16px 14px; overflow: hidden; color: transparent;
  font: 17px/1.55 system-ui, sans-serif; white-space: pre-wrap; overflow-wrap: break-word; pointer-events: none; }
.tr-mirror mark { background: none; color: transparent; border-radius: 4px; }
.tr-mirror mark.tr-on { background: var(--tr-hl-soft); }
.tr-field textarea { position: relative; width: 100%; }
.tr-js .tr-in textarea { resize: none; overflow: hidden; }

/* Checks under the panes. */
.tr-checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.tr-ck { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; }
.tr-ck.tr-ok::before { content: "✓"; color: var(--brand); font-weight: 700; }
.tr-ck.tr-warn { border-color: var(--warn); }
.tr-ck button { min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
  color: var(--ink); font: 12.5px/1 system-ui, sans-serif; cursor: pointer; }

/* Variant B: aligned rows. */
.tr-rows { margin: 12px 0 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tr-rows[hidden] { display: none; }
.tr-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 120px; gap: 12px; padding: 10px 12px;
  border-top: 1px solid var(--line); align-items: start; }
.tr-row:first-child { border-top: 0; background: var(--tr-surface); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tr-row .tr-n, .tr-row .tr-from { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tr-rows-on .tr-res { display: none; }
.tr-rows-on .tr-panes { grid-template-columns: minmax(0, 1fr); }

/* "My dictionary" and the history. */
.tr-panel[hidden] { display: none; }
.tr-panel { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; }
.tr-panel h3 { margin: 0 0 6px; font-size: 17px; }
.tr-panel form { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tr-panel input[type="text"], .tr-panel input[type="search"], .tr-panel select {
  min-height: 40px; min-width: 0; flex: 1 1 160px; padding: 6px 10px; box-sizing: border-box; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); color: var(--ink); font: 16px/1.3 system-ui, sans-serif; }
.tr-panel select { flex: 0 1 auto; }
.tr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tr-table th, .tr-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.tr-table th { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tr-switch { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.tr-switch input { width: 20px; height: 20px; }
.tr-keys { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; }
.tr-kbd { padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; font: 12px ui-monospace, Menlo, monospace; }
.tr-toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: calc(100vw - 32px); box-sizing: border-box;
  transform: translateX(-50%); padding: 9px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; }
.tr-toast[hidden] { display: none; }

/* The word breakdown of the non-neural engine (variant B of mockups/plan-2026-10-15): every piece of
   the translation is a button with a dotted underline; the open one is tinted, the visitor's own
   choice is solid, an unknown word is marked so it is checked first. */
.tr-w { all: unset; cursor: pointer; border-bottom: 1.5px dotted var(--link); border-radius: 3px; }
.tr-w:hover, .tr-w:focus-visible { background: color-mix(in srgb, var(--link) 12%, transparent); outline: none; }
.tr-w-on { background: color-mix(in srgb, var(--link) 18%, transparent); }
.tr-w-mine { border-bottom-style: solid; }
.tr-w-unk { border-bottom-color: #c2410c; }
.tr-hint { margin: 6px 0 0; font-size: 12.5px; }
.tr-hint[hidden], .tr-why[hidden], .tr-compare[hidden] { display: none; }
.tr-why { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 14.5px; }
.tr-why-head { display: flex; align-items: baseline; gap: 6px; margin: 0 0 4px; flex-wrap: wrap; }
.tr-why-close { margin-left: auto; }
.tr-why .m { margin: 0 0 8px; }
.tr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.tr-chip { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--ink);
  font: 14px/1.2 system-ui, sans-serif; cursor: pointer; }
.tr-chip[aria-pressed="true"] { border-color: var(--link); background: color-mix(in srgb, var(--link) 12%, transparent); }
.tr-own { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-own input { flex: 1 1 160px; min-width: 0; min-height: 36px; padding: 4px 10px; box-sizing: border-box; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); color: var(--ink); font: 16px/1.3 system-ui, sans-serif; }
.tr-own button { flex: 0 0 auto; }
.tr-compare { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--line); color: var(--muted); font-size: 15px; }
.tr-compare p { margin: 0 0 4px; }
.tr-compare-head { font-size: 12.5px; }
.tr-sources { margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.tr-sources summary { cursor: pointer; }
.tr-sources ul { margin: 6px 0; padding-left: 20px; }

.tr-card[hidden] { display: none; }
.tr-card { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; }
.tr-card-head { margin: 0 0 6px; }
.tr-senses { margin: 0 0 8px; padding-left: 22px; }
.tr-senses li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.tr-bar-p { flex: 0 0 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.tr-bar-p i { display: block; height: 100%; background: var(--link); }

/* Phone: variant C — one column, the language and option rows scroll sideways in one line each, so
   the text field stays in the first screen; 16 px text keeps Safari from zooming on focus. */
@media (max-width: 820px) {
  .tr-panes { grid-template-columns: minmax(0, 1fr); }
  .tr-pane { min-height: 0; }
  .tr .tr-in textarea { min-height: 140px; }
  .tr-row { grid-template-columns: 24px minmax(0, 1fr); }
  .tr-row > :nth-child(3), .tr-row > :nth-child(4) { grid-column: 2; }
}
@media (max-width: 600px) {
  .tr .tr-dir, .tr-tabs, .tr-opts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .tr-dir label, .tr-pill { flex: 0 0 auto; min-height: 38px; padding: 0 12px; font-size: 13.5px; }
  .tr .tr-in textarea, .tr-mirror { font-size: 16px; padding-left: 12px; padding-right: 12px; }
  .tr-live { font-size: 17px; padding: 12px; }
  .tr-label { padding-left: 12px; }
  /* The shell stretches every button on a phone (`button { flex: 1 1 auto }`); the small actions of
     the checks and the panes keep their own width, and the hotkeys need a keyboard. */
  .tr-ck button, .tr-icon, .tr-pill { flex: 0 0 auto; }
  .tr-keys { display: none; }
}
@media print {
  .tr-dir, .tr-tabs, .tr-opts, .tr-bar, .tr-foot, .tr-checks button, .tr-keys { display: none; }
}
/* The "Site" tab: translated blocks as paragraphs, or original and translation side by side. */
.tr-site h4 { margin: 12px 0 8px; font-size: 18px; }
.tr-site p { margin: 0 0 10px; }
.tr-site .tr-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 600px) { .tr-site .tr-row { grid-template-columns: minmax(0, 1fr); } }
