/* ===================================================================
   History page (a section's releases over time) and the citator page
   (who cites it), which reuses the history list markup for its own rows.
   ================================================================== */

.history-page .history-list {
  margin-top: 1.5rem;
}

.history-group {
  margin-bottom: 2rem;
}
.history-group h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: .85rem;
  font-weight: 650;
  letter-spacing: .06em;
  color: var(--faint);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--rule);
  padding-bottom: var(--space-3);
}
.history-group-range {
  font-weight: 500;
  letter-spacing: normal;
  font-variant-numeric: tabular-nums;
}

.history-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: .55rem var(--space-6);
  margin-bottom: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  font-family: var(--sans);
  font-size: var(--text-xs);
  gap: var(--space-4);
}
.history-item.changed {
  border-left: 3px solid var(--accent);
}
.history-item.current {
  background: var(--accent-soft);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.history-rp {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  flex: 1 1 0%;
  min-width: 3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date-main {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.history-rp-sub {
  font-family: var(--sans);
  font-size: var(--text-xs);
  color: var(--faint);
  white-space: nowrap;
}

.history-date {
  font-family: var(--sans);
  font-size: var(--text-xs);
  color: var(--faint);
  white-space: nowrap;
}

/* A dot rather than a pill: it has to sit on every changed row without
   turning the list back into the wall of badges this replaced. */
.history-dot {
  flex: none;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--accent);
}

.history-flag {
  flex: none;
  font-size: var(--text-3xs);
  padding: var(--space-1) var(--space-4);
  font-weight: 600;
}
.history-flag-current { background: var(--accent); color: #ffffff; }
.history-flag-absent { background: var(--bg); color: var(--faint); border: 1px solid var(--rule); }

.history-actions {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex: none;
}

.history-link {
  font-size: var(--text-xs);
  text-decoration: none;
  font-weight: 550;
}
.history-link.view-link { color: var(--accent); }
.history-link.view-link:hover { text-decoration: underline; }
.history-link.diff-link { color: var(--muted); }
.history-link.diff-link:hover { color: var(--accent); text-decoration: underline; }

/* Below this, .history-meta and .history-actions no longer both fit on one
   row -- .history-actions is flex: none, so it doesn't shrink, and the date
   sub-label is white-space: nowrap, so it doesn't wrap either. Without a
   line break the two collide. Dropping just the Public-Law sub-label to a
   second line (via `order`, so it wraps after the flag/dot rather than
   before) frees enough width for the date and the actions to share the
   first line without touching .history-item or .history-actions at all. */
@media (max-width: 40rem) {
  .history-meta {
    flex-wrap: wrap;
    row-gap: .1rem;
  }
  .history-rp-sub {
    order: 1;
    flex-basis: 100%;
  }
}

/* Collapsed runs of unchanged releases: closed by default, opened with a tap
   on the summary, no JS -- <details> already does exactly this. */
.history-collapsed-group {
  border: none;
  background: none;
  padding: 0;
  margin-bottom: .4rem;
  display: block;
}
/* Child combinators throughout: the rows inside carry their own <details>
   (the compare menu), which must not pick up the group's box or marker. */
.history-collapsed-group > details {
  border: 1px dashed var(--rule);
  border-radius: var(--radius-md);
}
.history-collapsed-group > details[open] {
  border-style: solid;
}
.history-collapsed-group > details > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4) var(--space-6);
  font-family: var(--sans);
  font-size: var(--text-xs);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.history-collapsed-group > details > summary::-webkit-details-marker { display: none; }
.history-collapsed-group > details > summary::before {
  content: "▸";
  font-size: .7rem;
  color: var(--faint);
  transition: transform .15s ease;
}
.history-collapsed-group > details[open] > summary::before {
  transform: rotate(90deg);
}
.history-collapsed-group > details > summary:hover { color: var(--accent); }
.history-items-nested {
  padding: 0 var(--space-5) var(--space-5);
}

/* -------------------------------------------------------- citator (cites) page
   Extends the history list above with a quoted excerpt of the citing text. */

.cite-item {
  display: block;
  padding: .75rem 1rem;
}

.cite-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.cite-link-title {
  color: var(--ink);
  text-decoration: none;
}
.cite-link-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.cite-target-header-link {
  color: var(--accent);
  text-decoration: underline;
  font-weight: inherit;
}

.cite-excerpt {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-7);
  border-left: 3px solid var(--rule);
  font-family: var(--serif);
  font-size: var(--text-lg);
  line-height: 1.4;
  color: var(--ink);
}

.cite-excerpt-block {
  margin-bottom: .35rem;
}
.cite-excerpt-block:last-child {
  margin-bottom: 0;
}

.cite-marker {
  font-weight: 650;
  margin-right: var(--space-4);
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--text-sm);
}

mark.cite-target {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: .1rem .25rem;
  font-weight: 650;
}
