/* History slide rule — AnCEstory / Rosetta top rail (µeee History inspired) */

.hsr-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hsr-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
}

.hsr-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.hsr-sub {
  margin: 0;
}

.hsr-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.hsr-btn {
  appearance: none;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line, #30363d);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: 700 0.75rem/1 ui-monospace, Menlo, monospace;
  cursor: pointer;
}

.hsr-btn:hover {
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(125, 211, 252, 0.1);
}

.hsr-readout {
  font: 700 0.78rem/1 ui-monospace, Menlo, monospace;
  color: #a78bfa;
  min-width: 5.5rem;
  text-align: right;
  padding: 0 4px;
}

.hsr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 600 0.68rem/1 system-ui, sans-serif;
  color: var(--muted, #8b949e);
  cursor: pointer;
  user-select: none;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.hsr-toggle:hover {
  border-color: rgba(125, 211, 252, 0.25);
  color: inherit;
}

.hsr-toggle input {
  accent-color: #34d399;
}

.hsr-strip {
  position: relative;
  height: 108px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0a0b0d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: grab;
  touch-action: none;
}

.hsr-strip:active {
  cursor: grabbing;
}

.hsr-canvas {
  display: block;
  width: 100%;
  height: 108px;
}

.hsr-hover {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font: 600 0.62rem/1.2 ui-monospace, Menlo, monospace;
  color: #22d3ee;
  background: rgba(5, 8, 16, 0.88);
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.hsr-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  font-size: 0.72rem;
  opacity: 0.8;
}

.hsr-range {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem;
}

.hsr-sel {
  opacity: 0.9;
}

/* Iris deep dive */
.hsr-iris {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: end;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hsr-iris-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: 700 0.65rem/1 system-ui;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint, #8b949e);
  grid-column: 1;
}

.hsr-iris-label input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line, #30363d);
  background: var(--bg, #0d1117);
  color: var(--ink, #e6edf3);
  font: 500 0.9rem/1.2 system-ui;
  text-transform: none;
  letter-spacing: 0;
  width: 100%;
}

.hsr-iris-go {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.hsr-iris .docs-kicker {
  grid-column: 1 / -1;
  margin: 0;
}

.hsr-iris-results {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  max-height: 11rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.hsr-iris-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line, #30363d);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-decoration: none;
  font-size: 0.78rem;
  line-height: 1.3;
}

.hsr-iris-hit:hover {
  border-color: rgba(125, 211, 252, 0.4);
  background: rgba(125, 211, 252, 0.08);
}

.hsr-iris-hit .src {
  font: 700 0.62rem/1 ui-monospace, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #22d3ee;
  opacity: 0.9;
}

.hsr-iris-hit .t {
  font-weight: 650;
}

.hsr-iris-hit .sn {
  font-size: 0.7rem;
  opacity: 0.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 700px) {
  .hsr-iris {
    grid-template-columns: 1fr;
  }
  .hsr-iris-go {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }
  .hsr-strip {
    height: 96px;
  }
}

/* ── Universal History harness chrome (site-wide, under header) ──
   Same content column + gutters as .header-inner / .app-shell / docs-main. */
.kbatch-history-harness {
  position: sticky;
  top: 0;
  z-index: var(--kbatch-history-z, 45);
  border-bottom: 1px solid var(--line, #30363d);
  background: color-mix(in srgb, var(--panel, #161b22) 92%, #000 8%);
  backdrop-filter: blur(8px);
  width: 100%;
  box-sizing: border-box;
  /* Full-bleed bar background; inner column is constrained below */
  padding-inline: 0;
}

.kbatch-hsr-bar,
.kbatch-hsr-body {
  max-width: var(--kbatch-content-max, 1100px);
  margin-inline: auto;
  padding-inline: max(var(--kbatch-gutter, 16px), env(safe-area-inset-left, 0px))
    max(var(--kbatch-gutter, 16px), env(safe-area-inset-right, 0px));
  width: 100%;
  box-sizing: border-box;
}

.kbatch-hsr-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding-top: 8px;
  padding-bottom: 8px;
  row-gap: 8px;
}

.kbatch-hsr-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font: 600 0.78rem/1.2 system-ui, sans-serif;
  padding: 4px 0;
  flex-wrap: wrap;
  min-width: 0;
}

.kbatch-hsr-toggle strong {
  letter-spacing: 0.02em;
}

.kbatch-hsr-hint {
  color: var(--muted, #8b949e);
  font-weight: 500;
  font-size: 0.72rem;
}

.kbatch-hsr-year {
  font: 700 0.72rem/1 ui-monospace, Menlo, monospace;
  color: #a78bfa;
  min-width: 4.5rem;
}

.kbatch-hsr-era {
  font: 650 0.65rem/1 system-ui, sans-serif;
  color: var(--muted, #8b949e);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line, #30363d);
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kbatch-hsr-chev {
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--muted, #8b949e);
}

.kbatch-history-harness.is-collapsed .kbatch-hsr-chev {
  transform: rotate(-90deg);
}
.kbatch-history-harness.is-open .kbatch-hsr-chev {
  transform: rotate(0deg);
}

.kbatch-hsr-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kbatch-hsr-quick button {
  appearance: none;
  border: 1px solid var(--line, #30363d);
  background: transparent;
  color: var(--muted, #8b949e);
  font: 700 0.65rem/1 ui-monospace, Menlo, monospace;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.kbatch-hsr-quick button:hover,
.kbatch-hsr-quick button.is-on {
  border-color: #a78bfa;
  color: #a78bfa;
}

.kbatch-hsr-body {
  padding-top: 0;
  padding-bottom: 12px;
}

.kbatch-hsr-body[hidden] {
  display: none !important;
}

/* Slide rule mount fills the content column; no extra side drift */
.kbatch-hsr-mount {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.kbatch-hsr-mount .hsr-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.kbatch-hsr-mount .hsr-title {
  font-size: 0.95rem;
}
.kbatch-hsr-mount .hsr-sub {
  font-size: 0.72rem;
}
.kbatch-hsr-mount .hsr-canvas {
  height: 96px !important;
  width: 100% !important;
  max-width: 100%;
}
.kbatch-hsr-mount .hsr-strip {
  height: 96px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.kbatch-hsr-scaffold-hint {
  font: 500 0.7rem/1.35 system-ui, sans-serif;
  color: var(--muted, #8b949e);
  padding: 4px 0 0;
}

/* In-page history scaffold blocks — same column feel */
[data-history-scaffold] {
  border: 1px solid var(--line, #30363d);
  border-radius: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel, #161b22) 88%, #a78bfa 4%);
  margin: 0 0 12px;
  max-width: 100%;
  box-sizing: border-box;
}

[data-history-scaffold] .phs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 8px;
}

[data-history-scaffold] .phs-head h2,
[data-history-scaffold] .phs-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

[data-history-scaffold] .phs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font: 600 0.75rem/1.3 ui-monospace, Menlo, monospace;
}

[data-history-scaffold] [data-hs-year] {
  color: #a78bfa;
  font-weight: 800;
}
[data-history-scaffold] [data-hs-era] {
  color: var(--ink, #e6edf3);
}
[data-history-scaffold] [data-hs-band] {
  color: var(--muted, #8b949e);
}

[data-history-scaffold] [data-hs-chips] {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

[data-history-scaffold] [data-hs-chips] button {
  appearance: none;
  border: 1px solid var(--line, #30363d);
  background: transparent;
  color: var(--muted, #8b949e);
  font: 650 0.68rem/1 system-ui, sans-serif;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}

[data-history-scaffold] [data-hs-chips] button:hover,
[data-history-scaffold] [data-hs-chips] button.is-on {
  border-color: #a78bfa;
  color: #a78bfa;
  background: color-mix(in srgb, #a78bfa 10%, transparent);
}

[data-history-scaffold] [data-hs-links] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.78rem;
}

[data-history-scaffold] [data-hs-links] a {
  color: var(--accent, #58a6ff);
}

[data-history-scaffold] .phs-note {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted, #8b949e);
}

@media (max-width: 720px) {
  .kbatch-hsr-hint {
    display: none;
  }
  .kbatch-hsr-era {
    max-width: 6rem;
  }
  .kbatch-hsr-bar {
    gap: 6px 8px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .kbatch-hsr-quick {
    width: 100%;
    justify-content: flex-start;
  }
  .kbatch-hsr-mount .hsr-canvas,
  .kbatch-hsr-mount .hsr-strip {
    height: 88px !important;
  }
  .kbatch-hsr-mount .hsr-strip {
    height: 88px;
  }
}

/* Narrow phones / landscape notch: keep strip readable, not edge-clipped */
@media (max-width: 420px) {
  .kbatch-hsr-year {
    min-width: 3.5rem;
  }
  .kbatch-hsr-quick button {
    padding: 5px 6px;
    font-size: 0.62rem;
  }
}
