/* The History window (history.js): the steps that can be undone, and what the chosen one changed.
   Its sizes (--hi-margin, --hi-max, --hi-list, --hi-pad) and whether it is narrow (the class `narrow`)
   come from history.js's LAYOUT, which also works out the snippets' width from them. */

.hi-overlay {
  z-index: 72;
  animation: pm-fade 0.16s ease-out;
}
.hi-scrim {
  position: absolute;
  inset: 0;
}
.hi {
  position: relative;
  display: grid;
  grid-template-columns: var(--hi-list) minmax(0, 1fr);
  width: min(var(--hi-max), calc(100vw - var(--hi-margin)));
  height: calc(100vh - var(--hi-margin));
  border-radius: 18px;
  background: radial-gradient(700px 240px at 10% -10%, rgba(212, 175, 55, 0.1), transparent 70%), linear-gradient(180deg, #1c1821, #0f0d12);
  border: 1px solid var(--line-3);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.7),
    var(--glow),
    inset 0 1px 0 rgba(255, 240, 200, 0.07);
  overflow: hidden;
  animation: pm-rise 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------------------------------------------------------------- the steps */

.hi-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(6, 5, 8, 0.35);
}
.hi-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 10px 18px;
}
.hi-mark {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--metal-soft);
  color: #231804;
}
.hi-mark .glyph {
  width: 18px;
  height: 18px;
}
.hi-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hi-title h2 {
  margin: 0;
  font: italic 600 26px/1.1 var(--serif);
  color: var(--gold-hi);
}
.hi-song {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hi-about {
  margin: 0;
  padding: 0 18px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.hi-empty {
  padding: 24px 18px;
  color: var(--dim);
  font: italic 500 16px/1.4 var(--serif);
}
.hi-steps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
}
.hi-step {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
/* The thread of time down the list: each step a bead on it. */
.hi-step::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line-2);
}
.hi-step:first-child::before {
  top: 16px;
}
.hi-step:last-child::before {
  bottom: calc(100% - 16px);
}
.hi-step:hover {
  background: rgba(212, 175, 55, 0.05);
}
.hi-step.on {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.16), rgba(212, 175, 55, 0.05));
  border-color: var(--line-3);
}
.hi-dot {
  position: relative;
  flex: none;
  width: 11px;
  height: 11px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--ob-3);
  border: 2px solid var(--gold-mid);
}
.hi-dot.agent {
  border-color: var(--sapphire);
}
.hi-step.on .hi-dot {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.7);
}
.hi-step.on .hi-dot.agent {
  background: var(--sapphire);
  box-shadow: 0 0 8px rgba(91, 130, 196, 0.8);
}
.hi-step-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hi-step-line {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hi-step.on .hi-step-line {
  color: var(--gold-hi);
}
.hi-step-more {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hi-step-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--dim);
}
.hi-who {
  font: 600 9.5px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-mid);
}
.hi-who.agent {
  color: var(--sapphire);
}
.hi-latest {
  padding: 2px 6px;
  border-radius: 99px;
  font: 600 9.5px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #231804;
  background: var(--metal-soft);
}

/* ---------------------------------------------------------------- the tabs and the saved versions */

.hi-tabs {
  display: flex;
  gap: 4px;
  margin: 0 12px 10px 18px;
  padding: 3px;
  border-radius: 99px;
  background: rgba(6, 5, 8, 0.55);
  border: 1px solid var(--line);
}
.hi-tab {
  flex: 1;
  padding: 6px 10px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1.2 var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.hi-tab:hover {
  color: var(--text);
}
.hi-tab.on {
  color: #231804;
  background: var(--metal-soft);
}
.hi-vsave {
  padding: 10px 12px 2px 18px;
}
.btn.hi-save {
  width: 100%;
}
.hi-ver-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 14px;
  color: var(--gold-mid);
}
.hi-ver-mark .glyph {
  width: 13px;
  height: 13px;
}
.hi-ver.on .hi-ver-mark .glyph path {
  fill: var(--gold);
  stroke: var(--gold);
}
/* A bookmark is not a bead on the thread of time: no thread. */
.hi-ver::before {
  display: none;
}
.hi-intro {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* The top bar's bookmark, filled while the song on screen is a saved version. */
.btn.save-version.saved .glyph path {
  fill: currentColor;
}
.btn.save-version.saved {
  color: var(--gold-hi);
}

/* ---------------------------------------------------------------- the chosen step */

.hi-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.hi-pane-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--line);
}
.hi-pane-title {
  flex: 1;
  min-width: 0;
}
.hi-pane-title h3 {
  margin: 0 0 3px;
  font: 600 22px/1.15 var(--serif);
  color: var(--champagne);
}
.hi-pane-meta {
  font-size: 12px;
  color: var(--muted);
}
.hi-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px var(--hi-pad) 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.hi-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hi-sec-head {
  margin: 0;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-mid);
}
.hi-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hi-line {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(6, 5, 8, 0.45);
  border: 1px solid var(--line);
}
.hi-line-text {
  font-size: 13.5px;
  color: var(--text);
}
.hi-line-detail {
  margin-left: auto;
  font: 12px/1 var(--mono);
  color: var(--champagne);
  white-space: nowrap;
}
.hi-nothing {
  color: var(--dim);
  font: italic 500 18px/1.4 var(--serif);
}

/* A pattern's notes: Before over After, each on paper. */
.hi-pat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
  border-radius: 14px;
  background: rgba(6, 5, 8, 0.45);
  border: 1px solid var(--line);
}
.hi-pat-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hi-pat-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.hi-pat-name {
  font: 600 17px/1.2 var(--serif);
  color: var(--champagne);
  margin-right: 4px;
}
.hi-count {
  padding: 2px 7px;
  border-radius: 99px;
  font: 600 11px/1.3 var(--mono);
}
.hi-count.added {
  color: #8fe3a8;
  background: rgba(31, 138, 70, 0.22);
  border: 1px solid rgba(111, 224, 143, 0.35);
}
.hi-count.removed {
  color: #ff9a8f;
  background: rgba(209, 38, 28, 0.2);
  border: 1px solid rgba(255, 106, 92, 0.35);
}
.hi-side {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.hi-side-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 12px;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.hi-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.hi-paper {
  --ink: #1b1712;
  --staff: rgba(27, 23, 18, 0.82);
  --ink-soft: #6b5f4d;
  padding: 10px 14px 6px;
  border-radius: 4px;
  background: #fbf7ec;
  box-shadow:
    inset 0 0 40px rgba(150, 106, 38, 0.12),
    0 0 0 1px rgba(120, 96, 52, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.45);
  overflow-x: auto;
}
.hi-paper .hi-sys {
  position: static;
  display: block;
  will-change: auto;
}
.hi-box {
  stroke-width: 0.14;
}
.hi-none {
  padding: 16px 4px;
  color: var(--ink-soft);
  font: italic 500 15px/1.4 var(--serif);
}

/* ---------------------------------------------------------------- narrow screens */

/* The steps over the diff (history.js's LAYOUT.upTo), and the window the whole screen. */
.hi.narrow {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  width: calc(100vw - var(--hi-margin));
  border-radius: 14px;
}
.hi.narrow .hi-list {
  max-height: 38vh;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}
.hi.narrow .hi-about {
  display: none;
}
.hi.narrow .hi-pane-head {
  padding: 12px 16px 10px;
}
.hi.narrow .hi-pane-title h3 {
  font-size: 18px;
}
/* A saved version's name over its three buttons. */
.hi.narrow .hi-vhead {
  flex-wrap: wrap;
  gap: 8px 10px;
}
.hi.narrow .hi-vhead .hi-pane-title {
  flex-basis: 100%;
}
.hi.narrow .hi-scroll {
  padding: 12px var(--hi-pad) 20px;
}
.hi.narrow .hi-line {
  flex-wrap: wrap;
  gap: 4px 14px;
}
.hi.narrow .hi-line-detail {
  margin-left: 0;
}
.hi.narrow .hi-side {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}
.hi.narrow .hi-side-tag {
  padding-top: 2px;
}
