/* diff.qft.org — diff.css: result bar and the comparison view */

.result { scroll-margin-top: 8px; }
.result.stale .diff, .result.stale .same { opacity: .5; }

/* ---------- sticky bar ---------- */
.rbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
}
.stats { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-right: auto; font-size: 13px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip.del { background: var(--del-bg); color: var(--del); }
.chip.ins { background: var(--ins-bg); color: var(--ins); }
.stats .dim { color: var(--muted); }
.rbar-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.seg button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--line-strong); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { border-color: var(--accent); }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 250px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--pop);
}
.menu-panel hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.check:hover, .menu-item:hover { background: var(--surface-2); }
.field { display: grid; gap: 4px; padding: 6px 8px; color: var(--muted); font-size: 12px; }
.field select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.menu-item { padding: 7px 8px; border: 0; border-radius: 6px; background: none; font-size: 13px; text-align: left; cursor: pointer; }
.nav { display: inline-flex; align-items: center; }
.nav-pos { min-width: 58px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: center; }

/* ---------- notes and the "identical" state ---------- */
.notes {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
}
.notes span + span::before { content: "·"; margin: 0 8px; color: var(--faint); }
.same {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 20px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}
.same strong { color: var(--text); font-size: 16px; }
.same .ok {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--ins-bg);
  color: var(--ins);
}
.same .ok .ico { width: 20px; height: 20px; stroke-width: 2; }
.notfound { margin-top: 40px; border-top: 1px solid var(--line); border-radius: var(--radius); }
.notfound .btn { margin-top: 14px; text-decoration: none; }

/* ---------- the diff ---------- */
.diff {
  --nw: 44px;                     /* line-number column, set from script */
  --gw: calc(var(--nw) + 14px);   /* number + sign */
  --lh: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  font: 12.5px/var(--lh) var(--font-mono);
}
.chunk { content-visibility: auto; }
.r { display: grid; grid-template-columns: var(--gw) minmax(0, 1fr) var(--gw) minmax(0, 1fr); }
.unified .r { grid-template-columns: var(--nw) var(--gw) minmax(0, 1fr); }

.n {
  position: relative;
  padding: 0 6px 0 8px;
  background: var(--surface-2);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
}
.n::before { content: attr(data-n); }
.split .n, .unified .nr { padding-right: 20px; }
.n::after { position: absolute; top: 0; right: 6px; font-weight: 600; }
.split .n.d::after, .unified .nr.d::after { content: "−"; }
.split .n.i::after, .unified .nr.i::after { content: "+"; }

.t {
  min-width: 0;
  min-height: var(--lh);
  padding: 0 12px 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}
.split .tl { border-right: 1px solid var(--line); }
.nowrap .t { overflow: hidden; white-space: pre; overflow-wrap: normal; text-indent: calc(var(--sx, 0px) * -1); }

.n.d { background: var(--del-gut); color: var(--del); }
.t.d { background: var(--del-bg); }
.n.i { background: var(--ins-gut); color: var(--ins); }
.t.i { background: var(--ins-bg); }
.n.e, .t.e {
  background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--line) 5px 6px) var(--empty);
}
.x { border-radius: 3px; }
.t.d .x { background: var(--del-x); }
.t.i .x { background: var(--ins-x); }

/* selecting text on one side leaves the other side alone */
.diff.sel-l .tr, .diff.sel-r .tl { user-select: none; -webkit-user-select: none; }

.hunk { position: relative; scroll-margin: 120px 0 80px; }
.hunk.cur::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  pointer-events: none;
}
.mg {
  position: absolute;
  top: 0;
  right: 50%;
  z-index: 2;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 7px 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.unified .mg { right: 10px; }
.hunk:hover > .mg, .hunk.cur > .mg, .mg:focus-within { display: flex; }
.mg button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 21px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.mg button + button { border-left: 1px solid var(--line); }
.mg button:hover { background: var(--accent); color: var(--accent-ink); }
.mg .ico { width: 14px; height: 14px; }

.fold {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  border-block: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font: 12px var(--font-ui);
  cursor: pointer;
}
.fold:first-child { border-top: 0; }
.fold:last-child { border-bottom: 0; }
.fold:hover { background: var(--accent-soft); color: var(--accent); }
.fold .ico { width: 14px; height: 14px; }

.hscroll {
  position: sticky;
  bottom: 0;
  z-index: 10;
  height: 16px;
  margin-top: -1px;
  overflow: auto hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: var(--surface-2);
}
.hscroll > div { height: 1px; }

@media (max-width: 760px) {
  .rbar { position: static; gap: 8px; }
  .menu-panel { right: auto; left: 0; }
  #exportMenu .menu-panel { right: 0; left: auto; }
  .diff { font-size: 12px; }
}

@media print {
  .rbar { position: static; border: 0; padding: 0 0 8px; }
  .diff { border: 0; border-radius: 0; }
  .chunk { content-visibility: visible; }
  .t { white-space: pre-wrap !important; overflow-wrap: anywhere !important; text-indent: 0 !important; }
  .fold { height: 20px; }
  .mg { display: none !important; }
}
