/* Translator component (public "/" and app section), language picker, alternatives, dictionary.
 * Layout follows DeepL's signed-in translator: a language bar card over two text cards, an "Editing tools"
 * column on the right from the top of the bar to the bottom of the text cards, the Dictionary card under all. */

.tr {
  --tools-w: clamp(250px, 22vw, 340px);
  display: grid; grid-template-columns: minmax(0, 1fr) var(--tools-w); grid-template-areas: "work tools" "dict dict";
  gap: 16px 16px; align-items: stretch;
}
.tr.tools-closed { --tools-w: 60px; }
.tr .card { border-radius: 12px; box-shadow: none; }
.tr-work { grid-area: work; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* ---------- language bar ---------- */
.tr-langbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; column-gap: 20px; min-height: 58px; padding: 8px 12px; }
.tr-langbar .tr-swap { justify-self: center; }
.tr-langbar .tr-swap svg { width: 22px; height: 22px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
  height: 40px; padding: 0 10px 0 12px; border: 0; border-radius: 8px; background: transparent;
  font-weight: 600; font-size: 15px; color: var(--text); cursor: pointer;
}
.lang-btn[data-side="src"] { justify-self: end; }
.lang-btn[data-side="tgt"] { justify-self: start; }
.lang-btn:hover, .lang-btn[aria-expanded="true"] { background: var(--surface-2); }
.lang-btn .lang-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-btn svg { width: 18px; height: 18px; color: var(--text); flex: none; transition: transform .15s; }
.lang-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.tr-swap { color: var(--text); }
.tr-swap:disabled { opacity: .4; cursor: default; }
.tr-swap:disabled:hover { background: transparent; color: var(--text); }

.tr-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--warn-soft); border: 1px solid #f1dca5; color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm);
}

/* ---------- text cards ---------- */
.tr-panels { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.tr-pane { position: relative; display: flex; flex-direction: column; min-height: clamp(300px, calc(100vh - 440px), 460px); overflow: hidden; }
.tr-input, .tr-out {
  width: 100%; padding: 22px 24px 12px; font-size: 24px; line-height: 1.45; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.tr-long .tr-input, .tr-long .tr-out { font-size: 18px; line-height: 1.55; }
.tr-input { flex: 1 0 auto; min-height: 120px; border: 0; outline: none; resize: none; background: transparent; overflow: hidden; }
.tr-input::placeholder { color: var(--text-2); font-weight: 600; font-size: 24px; opacity: 1; }
.tr-src.is-empty .tr-input { flex: 0 0 auto; min-height: 0; padding-bottom: 0; }
.tr-src { cursor: text; }
.tr-src:focus-within { border-color: var(--border-strong); }
.tr-drop-hint { margin: 22px 24px 0; max-width: 520px; font-size: 16px; line-height: 1.6; color: var(--muted); }
.tr-src:not(.is-empty) .tr-drop-hint { display: none; }
.tr-src.is-empty .tr-foot { margin-top: auto; }
.tr-out { flex: 1 0 auto; outline: none; cursor: text; transition: opacity .15s; }
.tr-out.stale { opacity: .5; }

/* drop a document onto the source card */
.tr-dropzone {
  position: absolute; inset: 8px; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed var(--accent); border-radius: 10px; background: rgba(234, 238, 254, .94); color: var(--accent); pointer-events: none;
}
.tr-dropzone svg { width: 34px; height: 34px; }
.tr-dropzone b { font-size: 16px; }

.tr-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 12px 14px; min-height: 52px; }
.tr-foot-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.tr-foot .icon-btn { width: 34px; height: 34px; color: var(--muted); }
.tr-foot .icon-btn:hover { color: var(--text); }
.tr-foot .icon-btn svg { width: 19px; height: 19px; }
.tr-foot .icon-btn:disabled { opacity: .35; cursor: default; }
.tr-foot .icon-btn:disabled:hover { background: transparent; color: var(--muted); }
.tr-files-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; margin-left: -2px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer;
}
.tr-files-btn:hover { background: var(--surface-2); }
.tr-files-btn svg { width: 20px; height: 20px; flex: none; }
.tr-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 4px; white-space: nowrap; }
.tr-count.over { color: var(--danger); font-weight: 700; }
.tr-hint { font-size: 13px; color: var(--muted); padding-left: 10px; }
.tr-star.on, .tr-foot .tr-star.on { color: #e0a100; }
.icon-btn.busy { animation: tr-pulse 1s ease-in-out infinite; }
@keyframes tr-pulse { 50% { opacity: .45; } }

/* clickable words for alternatives */
.tr-out.clickable .tr-word { cursor: pointer; border-radius: 4px; transition: background .1s; }
.tr-out.clickable .tr-word:hover { background: var(--accent-soft); }
.tr-out .tr-word.active { background: var(--accent-soft); box-shadow: 0 2px 0 var(--accent); }

/* loading */
.tr-shimmer { position: absolute; top: 28px; left: 24px; right: 24px; display: flex; flex-direction: column; gap: 14px; }
.tr-shimmer i {
  display: block; height: 18px; border-radius: 9px;
  background: linear-gradient(90deg, #eceff4 0%, #dfe4ec 40%, #eceff4 80%); background-size: 300% 100%;
  animation: tr-shimmer 1.2s linear infinite;
}
.tr-shimmer i:nth-child(1) { width: 92%; }
.tr-shimmer i:nth-child(2) { width: 78%; }
.tr-shimmer i:nth-child(3) { width: 55%; }
@keyframes tr-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.tr-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; overflow: hidden; background: var(--accent-soft); }
.tr-progress::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--accent);
  animation: tr-bar 1s ease-in-out infinite;
}
@keyframes tr-bar { from { left: -35%; } to { left: 100%; } }

.tr-msg { margin: 0 24px 8px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14.5px; color: var(--text); background: var(--surface-2); }
.tr-msg.warn { background: var(--warn-soft); }
.tr-msg.error { background: var(--danger-soft); color: var(--danger); }
.tr-msg a { font-weight: 600; }

/* ---------- editing tools column ---------- */
.tr-tools { grid-area: tools; min-width: 0; padding: 12px 16px 20px; }
.tt-top { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0 0 14px -4px; }
.tt-toggle { color: var(--text); }
.tt-toggle svg { width: 22px; height: 22px; }
.tt-top-label { display: none; font-weight: 600; cursor: pointer; }
.tools-closed .tr-tools { padding: 12px 8px; }
.tools-closed .tt-top { margin: 0; justify-content: center; }
.tools-closed .tt-content { display: none; }
.tt-label { font-size: 15px; color: var(--muted); margin: 0 0 12px; }
.tt-label ~ .tt-label { margin-top: 26px; }
.tt-item + .tt-item { margin-top: 8px; }
.tt-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 10px 0 12px;
  border: 1px solid transparent; border-radius: 8px; background: var(--surface-2); color: var(--text);
  font-size: 15px; text-align: left; cursor: pointer;
}
button.tt-row:hover, label.tt-row:hover { background: #eef1f5; }
.tt-row > svg { width: 21px; height: 21px; flex: none; color: var(--text-2); }
.tt-row > svg:last-child { width: 16px; height: 16px; transition: transform .15s; }
.tt-row.open > svg:last-child, .tt-row[aria-expanded="true"] > svg:last-child { transform: rotate(180deg); }
.tt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-value { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.tt-row.active { background: var(--accent-soft); }
.tt-row.active > svg:first-child { color: var(--accent); }
.tt-row.locked { color: var(--muted); }
.tt-row.locked > svg { color: var(--muted); opacity: .8; }
.tt-row.locked:hover .tt-name { color: var(--text-2); }
.tt-pro { flex: none; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 13px; font-weight: 600; letter-spacing: 0; }
.tt-select {
  flex: none; max-width: 55%; height: 30px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; outline: none;
}
.tt-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tt-select:disabled { color: var(--muted); cursor: default; }

/* glossaries: a white bordered row with a link to the glossaries section and an on/off switch */
.tt-row-gloss { background: var(--surface); border-color: var(--border-strong); cursor: default; padding-right: 8px; }
.tt-row-gloss.active { background: var(--surface); }
.tt-row-gloss.active > svg:first-child { color: var(--text-2); }
button.tt-row-gloss { cursor: pointer; }
button.tt-row-gloss:hover { background: var(--surface-2); }
.tt-gloss-link { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--text); font-weight: 600; text-decoration: none !important; }
.tt-gloss-link .tt-name { flex: 0 1 auto; }
.tt-gloss-link .tt-count { font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tt-gloss-link svg { width: 16px; height: 16px; flex: none; color: var(--text); transition: transform .15s; }
.tt-gloss-link:hover svg { transform: translateX(2px); }
.tt-gloss-link:hover .tt-name { text-decoration: underline; }
.tt-switch { width: 40px; height: 24px; }
.tt-switch span::before { width: 18px; height: 18px; }
.tt-switch input:checked + span::before { transform: translateX(16px); }
.tt-fake-switch { position: relative; width: 40px; height: 24px; flex: none; border-radius: 12px; background: var(--border-strong); }
.tt-fake-switch::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tt-gloss-sub { padding: 8px 2px 0 45px; }
.tt-gloss-sub .tt-select { max-width: 100%; width: 100%; }
.tt-note { margin: 0; font-size: 13px; color: var(--muted); }
.tt-sub { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.tt-rules-body { padding: 8px 0 0; }
.tt-rules-body .tt-sub:first-child { margin: 0 0 6px; }
.tt-rules-ta { min-height: 110px; font-size: 14px; }
.tt-menu { padding: 6px; }
.tt-menu button[aria-checked="true"] { color: var(--accent); font-weight: 600; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: tr-spin .8s linear infinite;
}
@keyframes tr-spin { to { transform: rotate(360deg); } }

/* ---------- dictionary ---------- */
.tr-dict { grid-area: dict; padding: 22px 24px 24px; border-radius: 12px; box-shadow: none; }
.tr-dict-title { font-size: 17px; font-weight: 600; margin: 0 0 18px; }
.tr-dict-body > p { margin: 0; font-size: 16px; }
.dict-loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.dict-word { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 10px; }
.dict-word b { font-size: 20px; }
.dict-ipa { color: var(--text-2); font-size: 15px; }
.dict-group { padding: 10px 0; border-top: 1px solid var(--border); }
.dict-pos { font-style: italic; color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.dict-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dict-tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.dict-tr b { font-size: 16px; }
.dict-gender { font-size: 12.5px; font-style: italic; color: var(--text-2); }
.dict-sense { font-size: 14px; color: var(--muted); }
.dict-ex { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 14px; color: var(--text-2); margin-top: 2px; padding-left: 12px; border-left: 2px solid var(--border); }
.dict-syn { font-size: 13.5px; color: var(--text-2); margin-top: 8px; }
.dict-syn span { font-weight: 600; }

/* ---------- language picker popover ---------- */
.lp {
  position: absolute; z-index: 95; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; max-height: min(480px, 70vh);
}
.lp-search { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.lp-search svg { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.lp-search input { border: 0; outline: none; flex: 1; height: 32px; font-size: 15px; background: transparent; }
.lp-body { overflow-y: auto; padding: 6px 8px 10px; }
.lp-head { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 8px 4px; }
.lp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 4px; }
.lp-top { grid-template-columns: 1fr; }
.lp-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px; border: 0; border-radius: 8px; background: none;
  text-align: left; cursor: pointer; color: var(--text); font-size: 14.5px; min-width: 0;
}
.lp-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-item:hover, .lp-item.hi { background: var(--surface-2); }
.lp-item.sel { color: var(--accent); font-weight: 650; }
.lp-check { width: 16px; height: 16px; flex: none; display: inline-flex; }
.lp-check svg { width: 16px; height: 16px; }
.lp-det { font-style: normal; color: var(--text-2); font-weight: 500; }
.lp-none { padding: 18px 8px; color: var(--text-2); }

/* ---------- alternatives popover ---------- */
.alt-pop {
  position: absolute; z-index: 95; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; max-height: 340px; overflow-y: auto;
}
.alt-head { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 10px 4px; }
.alt-item {
  display: block; width: 100%; text-align: inherit; border: 0; background: none; border-radius: 8px; padding: 8px 10px;
  cursor: pointer; color: var(--text); font-size: 15px; line-height: 1.4;
}
.alt-item:hover, .alt-item:focus { background: var(--accent-soft); outline: none; }
.alt-item b { font-weight: 600; }
.alt-prefix { color: var(--muted); }
.alt-loading, .alt-none { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; color: var(--text-2); font-size: 14px; }

/* ---------- public page ---------- */
.public-main { max-width: 1280px; margin: 0 auto; padding: 24px 28px 56px; }
.promo-strip {
  display: flex; align-items: center; gap: 16px; margin-top: 16px; padding: 18px 22px;
}
.promo-strip .promo-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.promo-strip .promo-icon svg { width: 24px; height: 24px; }
.promo-strip .promo-text { flex: 1; min-width: 0; }
.promo-strip .promo-text b { display: block; font-size: 16px; }
.promo-strip .promo-text span { color: var(--text-2); font-size: 14.5px; }
.promo-strip .promo-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar-menu { position: absolute; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tr, .tr.tools-closed { grid-template-columns: minmax(0, 1fr); grid-template-areas: "work" "tools" "dict"; }
  .tools-closed .tt-top-label { display: inline; }
  .tt-top { margin-bottom: 6px; }
  .tools-closed .tr-tools { padding: 8px 12px; }
  .tools-closed .tt-top { justify-content: flex-start; }
  .tt-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; align-items: start; }
  .tt-content > .tt-label:first-child { grid-column: 1; grid-row: 1; }
  .tt-content > .tt-formality { grid-column: 1; grid-row: 2; }
  .tt-content > .tt-label ~ .tt-label { grid-column: 2; grid-row: 1; margin-top: 0; }
  .tt-content > .tt-profiles, .tt-content > .tt-gloss, .tt-content > .tt-rules { grid-column: 2; }
  .tt-content > .tt-label:first-child + .tt-item { margin-top: 0; }
}
@media (max-width: 700px) {
  .tr-panels { grid-template-columns: 1fr; }
  .tr-pane { min-height: 200px; }
  .tr-tgt { min-height: 160px; }
  .tr-input, .tr-out { padding: 16px 16px 8px; font-size: 20px; }
  .tr-input::placeholder { font-size: 22px; }
  .tr-long .tr-input, .tr-long .tr-out { font-size: 17px; }
  .tr-input { min-height: 90px; }
  .tr-drop-hint { margin: 14px 16px 0; font-size: 15px; }
  .tr-shimmer { top: 20px; left: 16px; right: 16px; }
  .tr-msg { margin: 0 16px 8px; }
  .tr-langbar { padding: 6px; column-gap: 2px; min-height: 52px; }
  .lang-btn { padding: 0 8px; font-size: 15px; gap: 6px; }
  .tt-content { display: block; }
  .tt-content > .tt-label ~ .tt-label { margin-top: 22px; }
  .tr-dict { padding: 18px 16px 20px; }
  .lp-grid.lp-cols, .lp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dict-ex { grid-template-columns: 1fr; gap: 2px; }
  .public-main { padding: 16px 16px 40px; }
  .promo-strip { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .lp-grid.lp-cols, .lp-grid { grid-template-columns: 1fr; }
  .tr-hint { display: none; }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
