.era-compare {
  margin: 1.25rem 0;
  min-width: 0;
}

.era-stage {
  --era-split: 50%;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: var(--era-ratio, 16 / 9);
  overflow: hidden;
  background: #151613;
}

.era-compare .era-stage > :is(.era-before, .era-after) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  display: block;
  object-fit: var(--era-fit, cover);
  object-position: var(--era-position, center);
  user-select: none;
  -webkit-user-drag: none;
}

.era-stage > .era-after { z-index: 0; }
.era-stage > .era-before {
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--era-split)) 0 0);
}

.era-divider {
  position: absolute;
  z-index: 2;
  inset-block: 0;
  left: var(--era-split);
  width: 2px;
  transform: translateX(-50%);
  background: #fafaf5;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .23);
  pointer-events: none;
}

.era-range { display: none; }
.era-compare.is-enhanced .era-stage {
  cursor: ew-resize;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.era-compare.is-enhanced .era-range {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.era-compare.is-enhanced .era-divider::after {
  content: "‹ ›";
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  transform: translate(-50%, -50%);
  border: 1px solid rgb(255 255 255 / .8);
  border-radius: 50%;
  color: #fff;
  background: rgb(22 24 22 / .78);
  font: 600 1rem/1 system-ui, sans-serif;
  white-space: pre;
}

.era-stage:has(.era-range:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.era-legend {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin-top: .55rem;
  color: inherit;
  font-size: .82rem;
  line-height: 1.35;
}

.era-legend > :last-child { text-align: end; }
.era-compare figcaption { margin: .65rem 0 0; color: var(--study-muted, currentColor); font-size: .92rem; line-height: 1.5; }

.chapter-group { margin-block: 1.25rem; min-width: 0; }
.chapter-group > [data-chapter-panel] + [data-chapter-panel] { margin-block-start: 2rem; }
.chapter-group.is-enhanced > [data-chapter-panel] { margin-block-start: 0; }
.chapter-group > [data-chapter-panel][hidden], .chapter-tabs[hidden] { display: none !important; }
.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0 clamp(.85rem, 1.6vw, 1.7rem);
  margin: 0 0 1.2rem;
  border-bottom: 1px solid var(--study-rule, currentColor);
}

.chapter-tabs button {
  min-height: 2.75rem;
  max-width: 100%;
  padding: .5rem 0 .45rem;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: inherit;
  background: transparent;
  text-align: start;
  font: inherit;
  font-size: .92rem;
  line-height: 1.2;
  cursor: pointer;
}

.chapter-tabs button[aria-selected="true"] { border-bottom-color: currentColor; font-weight: 650; }
.chapter-tabs button:hover { text-decoration: underline; text-underline-offset: .2em; }
.chapter-tabs button:focus-visible, [data-chapter-panel]:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

@media (forced-colors: active) {
  .era-divider { background: CanvasText; }
  .era-compare.is-enhanced .era-divider::after { border-color: ButtonText; color: ButtonText; background: ButtonFace; }
}

@media (prefers-reduced-motion: reduce) {
  .era-stage, .era-stage > *, .chapter-tabs button, [data-chapter-panel] {
    animation: none;
    transition: none;
  }
}
