/* Text Diff Checker: styles for this page only. The page frame, bar, panes and buttons come from encoders.css and tools.css.
   Added and removed use the success and danger tokens as a tint, and every changed line also carries a + or - marker,
   so colour is never the only signal. */

.td-card {
  max-width: 1200px;
}
.td-heads-stat {
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.td-panes .enc-pane .textarea {
  min-height: 12rem;
  max-height: 24rem;
  white-space: pre;
  overflow: auto;
  word-break: normal;
  overflow-wrap: normal;
}
.td-actions {
  align-items: center;
}
.td-actions .td-spacer {
  flex: 1;
}

/* Result header: counts on one side, change navigation on the other */
.td-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-6);
  min-height: 2rem;
}
.td-counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}
.td-count {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
}
.td-count-word {
  font-family: var(--font);
  font-weight: var(--weight-regular);
  color: var(--color-muted);
}
.td-count-add {
  color: var(--color-success);
}
.td-count-del {
  color: var(--color-danger);
}
.td-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.td-pos {
  min-width: 6.5rem;
  text-align: right;
  font-size: var(--text-sm);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.td-empty-msg {
  margin: var(--space-3) 0 0;
  padding: var(--space-8) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-field);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* The diff */
.td-diff {
  position: relative;
  margin-top: var(--space-3);
  max-height: 36rem;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-ink);
  outline: none;
  transition: border-color var(--duration);
}
.td-diff:hover {
  border-color: var(--color-muted);
}
.td-diff:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}
.td-diff.is-side {
  --td-min: 40rem;
}
.td-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: var(--td-min, 0);
}
.td-diff.is-side .td-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.td-diff.is-side .td-row > .td-side + .td-side {
  border-left: 1px solid var(--color-border);
}
.td-side {
  display: grid;
  grid-template-columns: 3rem 1.25rem minmax(0, 1fr);
  min-width: 0;
}
.td-side.td-inl {
  grid-template-columns: 3rem 3rem 1.25rem minmax(0, 1fr);
}
.td-num {
  padding: 0 var(--space-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  user-select: none;
}
.td-sign {
  text-align: center;
  font-weight: var(--weight-bold);
  user-select: none;
}
.td-text {
  min-width: 0;
  min-height: 1.5em;
  padding: 0 var(--space-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.td-ins {
  background: color-mix(in srgb, var(--color-success) 11%, var(--color-surface));
}
.td-del {
  background: color-mix(in srgb, var(--color-danger) 11%, var(--color-surface));
}
.td-ins .td-sign {
  box-shadow: inset 3px 0 0 var(--color-success);
}
.td-del .td-sign {
  box-shadow: inset 3px 0 0 var(--color-danger);
}
.td-empty {
  background: var(--color-field);
}
.td-text ins,
.td-text del {
  color: inherit;
  text-decoration-thickness: 2px;
  border-radius: 2px;
}
.td-text ins {
  background: color-mix(in srgb, var(--color-success) 36%, var(--color-surface));
  text-decoration: underline;
}
.td-text del {
  background: color-mix(in srgb, var(--color-danger) 36%, var(--color-surface));
  text-decoration: line-through;
}

/* One change = one hunk; the one you jumped to gets an outline */
.td-hunk {
  min-width: var(--td-min, 0);
}
.td-hunk.is-current {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.td-hunk .td-row {
  min-width: 0;
}

/* Folded run of unchanged lines */
.td-fold {
  display: flex;
  justify-content: center;
  padding: var(--space-2);
  background: var(--color-field);
  min-width: var(--td-min, 0);
}
.td-fold .btn {
  font-family: var(--font);
}

@media (max-width: 720px) {
  .td-card {
    padding: var(--space-4);
  }
  .td-panes {
    grid-template-columns: minmax(0, 1fr);
  }
  .td-nav {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
  .td-pos {
    text-align: left;
    order: -1;
    flex: 1;
  }
  .td-actions .td-spacer {
    display: none;
  }
}
