/* ---------- History: the panel, the earlier-version banner, comparisons ----------
   Tokens only, so light and dark both come from styles.css. */

/* The way in, in the document header: "Updated 5d ago by SK" reads as the
   sentence it always was, and is a button. */
.doc-meta-history {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  border-bottom: 1px dashed var(--border-hover);
}
.doc-meta-history:hover { color: var(--accent); border-bottom-color: var(--accent); }
.doc-meta-history:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
#history-btn[aria-expanded="true"] { background: var(--accent-tint); color: var(--accent); }

/* ---------- the panel ---------- */
.hist-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 100vw);
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--e3);
  transform: translateX(16px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.hist-panel.show { transform: none; opacity: 1; }
.hist-panel[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .hist-panel { transition: none; transform: none; }
}

.hist-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 16px 12px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.hist-titles { flex: 1; min-width: 0; }
.hist-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  outline: none;
}
.hist-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 28px;
  overscroll-behavior: contain;
}

.hist-current {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 2px 0 6px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.hist-current strong { display: block; font-size: 13.5px; font-weight: 600; }
.hist-current-sub { display: block; font-size: 12px; color: var(--text-soft); }
.hist-current:hover { background: var(--surface-hover-card); }
.hist-current.selected { background: var(--accent-wash); border-color: var(--accent-tint); }
.hist-dot {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-tint);
  position: relative;
}
.hist-dot::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.hist-day {
  margin: 16px 10px 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-entry {
  position: relative;
  border-radius: var(--r-md);
  margin-bottom: 2px;
}
.hist-entry.selected { background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent-tint); }
.hist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 10px 6px;
  border: 0;
  background: none;
  border-radius: var(--r-md);
  text-align: left;
  font: inherit;
  color: var(--text-body);
  cursor: pointer;
}
.hist-entry:not(.selected) .hist-item:hover { background: var(--surface-hover-card); }
.hist-item[aria-disabled="true"] { cursor: default; }
.hist-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hist-item .avatar { margin-top: 1px; flex: none; }
.hist-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.hist-line { font-size: 13.5px; line-height: 1.4; color: var(--text-mid); }
.hist-line strong { color: var(--text); font-weight: 600; }
.hist-summary {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-body);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hist-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-soft);
}
.hist-meta time { margin-right: 2px; }
.hist-chip,
.hist-status,
.hist-src {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-sunken);
  color: var(--text-quiet);
}
.hist-chip.add { background: var(--diff-add-bg); color: var(--diff-add-text); }
.hist-chip.del { background: var(--diff-del-bg); color: var(--diff-del-text); }
.hist-status.pending { background: var(--attn-bg); color: var(--attn-text); box-shadow: inset 0 0 0 1px var(--attn-border); }
.hist-status.merged { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-border); }
.hist-status.closed { background: var(--surface-sunken); color: var(--text-quiet); text-decoration: line-through; }
.hist-src { background: none; box-shadow: inset 0 0 0 1px var(--border); font-family: var(--font-mono); font-weight: 500; }
.hist-entry.pending .hist-item .avatar { box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--attn-chip); }
.hist-nover { font-size: 11.5px; color: var(--text-faint); font-style: italic; }
.hist-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 10px 10px 50px;
  font-size: 12px;
}
.hist-links a,
.hist-older-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 550;
  text-decoration: none;
}
.hist-links a:hover,
.hist-older-link:hover { text-decoration: underline; }
.hist-links .ic,
.hist-older-link .ic { width: 12px; height: 12px; }
.hist-sha { font-family: var(--font-mono); color: var(--text-soft); }

.hist-empty {
  margin: 20px 8px;
  padding: 22px 18px;
  text-align: center;
  border: 1px dashed var(--border-dashed);
  border-radius: var(--r-lg);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
}
.hist-empty p { margin: 4px 0; }
.hist-empty strong { color: var(--text); }
.hist-empty-icon { color: var(--text-faint); margin-bottom: 6px; }
.hist-empty-icon .ic { width: 22px; height: 22px; }
.hist-empty .ghost-btn { margin-top: 10px; }

.hist-foot { margin: 18px 10px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.hist-foot-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-faint); }

/* ---------- an earlier version on screen ---------- */
/* The invitation to select a passage and comment is not true of an earlier
   version, so it steps aside while one is on screen. */
#doc-pane.viewing-history #document-guide { display: none; }
.hist-banner {
  position: sticky;
  top: 57px;
  z-index: 4;
  max-width: calc(var(--measure) - 24px);
  width: calc(100% - 32px);
  margin: 16px auto 0;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  background: var(--ink);
  color: var(--ink-text);
  box-shadow: var(--e2);
  font-size: 13.5px;
  animation: fade-up 0.2s ease;
}
.hist-banner.proposal { background: var(--attn-bg); color: var(--attn-text); border: 1px solid var(--attn-border); box-shadow: var(--e1); }
.hist-banner.proposal strong { color: var(--attn-chip-text); }
.hb-text { display: flex; gap: 10px; align-items: flex-start; }
.hb-text .ic { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--ink-accent); }
.hist-banner.proposal .hb-text .ic { color: var(--attn-text); }
.hb-text p { margin: 0; line-height: 1.5; }
.hb-text strong { color: var(--ink-accent); font-weight: 650; }
.hb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-left: 26px; }
.hb-actions .ic { width: 14px; height: 14px; }
.hist-banner .ghost-btn { background: transparent; color: var(--ink-text); border-color: var(--ink-line); }
.hist-banner .ghost-btn:hover { color: var(--ink-accent); border-color: var(--ink-accent); }
.hist-banner .primary { background: var(--ink-accent); border-color: var(--ink-accent); color: var(--ink); padding: 6px 12px; font-size: 12.5px; }
.hist-banner.proposal .ghost-btn { color: var(--attn-text); border-color: var(--attn-border); background: var(--card); }
.hist-banner.proposal .ghost-btn:hover { color: var(--accent); border-color: var(--accent); }
.hist-banner.proposal .primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.hb-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.hist-banner button:focus-visible { outline: 2px solid var(--ink-accent); outline-offset: 2px; }
.hist-banner.proposal button:focus-visible { outline-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .hist-banner { animation: none; } }
.hist-banner + #doc-meta + .markdown-body,
.hist-banner ~ .markdown-body { padding-top: 26px; }

.hist-binary {
  margin: 40px auto;
  max-width: 420px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-soft);
}
.hist-binary p { margin: 6px 0; }
.hist-binary .ghost-btn { margin-top: 10px; }

/* ---------- a comparison ---------- */
.hist-compare { font-family: var(--font-doc); }
.hc-head h1 { margin: 0 0 6px; }
.hc-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-soft);
}
.hc-key { padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.hc-key.del { background: var(--diff-del-bg); color: var(--diff-del-text); }
.hc-key.add { background: var(--diff-add-bg); color: var(--diff-add-text); }
.hc-summary { font-family: var(--font-ui); font-size: 13px; color: var(--text-soft); margin: 0 0 22px; }
.hc-none { font-family: var(--font-ui); font-size: 15px; color: var(--text-soft); }
.hc-more { font-family: var(--font-ui); font-size: 12.5px; color: var(--text-faint); }
.hc-block {
  position: relative;
  margin: 0 0 14px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid transparent;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hc-block.same { color: var(--text-quiet); }
.hc-h { display: block; font-weight: 650; color: var(--text); font-size: 1.15em; }
.hc-block.add .hc-h, .hc-block.del .hc-h { color: inherit; }
.hc-block.add { border-left-color: var(--diff-add-gutter); background: var(--diff-add-bg); color: var(--diff-add-text); padding: 8px 12px 8px 16px; border-radius: 0 8px 8px 0; }
.hc-block.del { border-left-color: var(--diff-del-gutter); background: var(--diff-del-bg); color: var(--diff-del-text); padding: 8px 12px 8px 16px; border-radius: 0 8px 8px 0; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--diff-del-text) 45%, transparent); }
.hc-block.changed { border-left-color: var(--accent); }
.hc-tag {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.85;
}
.hc-block.del .hc-tag { text-decoration: none; display: block; }
.hc-block.changed .hc-tag { color: var(--accent); }
.hc-block ins { text-decoration: none; background: var(--diff-add-bg); color: var(--diff-add-text); box-shadow: inset 0 -2px 0 var(--diff-add-gutter); border-radius: 3px; padding: 0 1px; }
.hc-block del { background: var(--diff-del-bg); color: var(--diff-del-text); text-decoration-color: var(--diff-del-gutter); border-radius: 3px; padding: 0 1px; }
.hc-skip {
  margin: 0 0 14px;
  padding: 4px 0 4px 16px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-faint);
  border-left: 3px dotted var(--border-strong);
}
.hc-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.markdown-body .hc-table { display: table; width: 100%; margin: 0; border-collapse: collapse; font-family: var(--font-ui); font-size: 13.5px; }
.markdown-body .hc-table th { border: 0; text-align: left; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); background: var(--bg-soft); padding: 8px 12px; }
.markdown-body .hc-table td { border: 0; border-top: 1px solid var(--border-soft); padding: 8px 12px; vertical-align: top; overflow-wrap: anywhere; }
.hc-ref { font-family: var(--font-mono); font-size: 12px; color: var(--text-mid); white-space: nowrap; }
.hc-before { color: var(--diff-del-text); background: var(--diff-del-bg); }
.hc-after { color: var(--diff-add-text); background: var(--diff-add-bg); }
.hc-emptycell { color: var(--text-faint); font-style: italic; }

/* ---------- phones: the panel is a sheet over everything ---------- */
@media (max-width: 768px) {
  .hist-panel {
    width: 100vw;
    border-left: 0;
    z-index: 66;
    transform: translateY(16px);
  }
  .hist-panel.show { transform: none; }
  .hist-head { padding: 14px 12px 10px 16px; }
  .hist-body { padding: 8px 8px 40px; }
  .hist-banner { position: static; width: calc(100% - 24px); margin-top: 12px; }
  .hb-actions { padding-left: 0; }
  .hist-links { padding-left: 48px; }
}
