/* Overlays (lightbox, popover, search) and tool views (map, timeline, print viewer). */

.no-scroll {
  overflow: hidden;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 9, 0.94);
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  color: #f1e9d6;
}
.lb-stage {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 56px 0 10px;
  min-height: 0;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.lb-stage img.cutout {
  background: #f1e9d6;
  padding: 12px;
}
.lb-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  justify-self: center;
}
.lb-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.lb-btn svg {
  width: 22px;
  height: 22px;
}
.lb-prev {
  grid-column: 1;
  grid-row: 1;
}
.lb-next {
  grid-column: 3;
  grid-row: 1;
}
.lb-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
}
.lb-info {
  grid-column: 1 / -1;
  grid-row: 2;
  text-align: center;
  padding: 8px 20px 18px;
  display: grid;
  gap: 2px;
}
.lb-cap-main {
  font-size: 16px;
  font-weight: 500;
}
.lb-cap-alt {
  font-size: 13.5px;
  font-style: italic;
  color: #c9bfa6;
}
.lb-count {
  font-size: 12px;
  color: #a79d86;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
@media (max-width: 640px) {
  .lightbox {
    grid-template-columns: minmax(0, 1fr);
  }
  .lb-stage {
    grid-column: 1;
  }
  .lb-prev,
  .lb-next {
    position: absolute;
    bottom: 96px;
    grid-column: auto;
  }
  .lb-prev {
    left: 12px;
  }
  .lb-next {
    right: 12px;
  }
}

/* ---------- popover ---------- */
.popover {
  position: absolute;
  z-index: 90;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 14px 12px;
  font-size: 13.5px;
  line-height: 1.5;
}
.pop-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

/* ---------- search ---------- */
.search-panel {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 20, 12, 0.6);
  backdrop-filter: blur(3px);
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 8vh 14px 14px;
}
.search-box {
  width: min(720px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.search-input > span {
  display: grid;
  color: var(--ink-faint);
}
.search-input svg {
  width: 20px;
  height: 20px;
}
.search-input input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 0;
  background: none;
  font-size: 18px;
  outline: none;
}
.search-input .icon-btn:hover {
  background: var(--paper-3);
}
.search-results {
  overflow-y: auto;
  padding: 14px 16px 18px;
  display: grid;
  gap: 16px;
}
.search-results h3 {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.sr-titles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.sr-title {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
}
.sr-title:hover,
.sr-hit:hover {
  border-color: var(--green);
}
.sr-title img {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
}
.sr-title span {
  display: grid;
  min-width: 0;
}
.sr-title b {
  font-size: 14.5px;
}
.sr-title small {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-group {
  margin-top: 10px;
}
.sr-group-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--green);
  margin-bottom: 4px;
}
.sr-hit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--card);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- map ---------- */
.map-view {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100vh - var(--bar) - 2px);
  height: calc(100dvh - var(--bar) - 2px);
}
.map-side {
  overflow-y: auto;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.map-side h1 {
  font-size: 26px;
  color: var(--green);
}
.map-side .note {
  margin-top: 6px;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-legend i,
.map-list i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.map-approx {
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}
.map-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}
.map-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
}
.map-list button:hover,
.map-list button.active {
  background: var(--paper-3);
}
.map-list span {
  display: grid;
  min-width: 0;
}
.map-list b {
  font-size: 14px;
  font-weight: 500;
}
.map-list small {
  font-size: 12px;
  color: var(--ink-faint);
}
.map-canvas {
  min-height: 0;
  background: var(--paper-2);
  position: relative;
  z-index: 0;
}
.map-canvas.is-diagram {
  overflow-y: auto;
  padding: 16px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
}
.map-diagram {
  width: min(100%, 760px);
  height: auto;
}
.map-diagram .ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.map-diagram .axis {
  stroke: var(--line);
  stroke-dasharray: 3 5;
}
.map-diagram .ring-label,
.map-diagram .compass {
  font: 11px var(--font-ui);
  fill: var(--ink-faint);
}
.map-diagram .lake {
  fill: var(--blue);
}
.map-diagram .dot {
  stroke: #fff;
  stroke-width: 2;
  cursor: pointer;
}
.map-diagram .dot.on {
  stroke: var(--ink);
  stroke-width: 3;
}
.map-diagram-info {
  width: min(100%, 300px);
}
.map-pop {
  display: grid;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  color: #2b2117;
}
.map-diagram-info .map-pop {
  color: var(--ink);
}
.map-pop img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 4px;
}
.map-pop b {
  font-family: var(--font-display);
  font-size: 17px;
  color: #2f5233;
}
.map-pop-meta {
  font-size: 12px;
  color: #7a6d5b;
}
.map-pop a {
  font-weight: 600;
  color: #a8500f;
}
@media (max-width: 820px) {
  .map-view {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 58%) minmax(0, 42%);
  }
  .map-side {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 12px 14px;
  }
  .map-side h1 {
    font-size: 20px;
  }
}

/* ---------- timeline ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-top: 6px;
}
.tab {
  border: 0;
  background: none;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-soft);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab[aria-selected='true'] {
  color: var(--green);
  border-bottom-color: var(--gold);
}
.tl-plot-scroll {
  margin-top: 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.tl-plot {
  position: relative;
  min-width: 940px;
  margin: 14px 24px 0;
}
.tl-band {
  position: absolute;
  top: 0;
  bottom: 28px;
  border-left: 1px solid var(--line);
  overflow: hidden;
}
.tl-band span {
  display: block;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.tl-band:nth-child(odd) {
  background: color-mix(in srgb, var(--gold) 9%, transparent);
}
.tl-tick {
  position: absolute;
  bottom: 0;
  height: 28px;
  border-left: 1px solid var(--ink-faint);
}
.tl-tick span {
  position: absolute;
  top: 8px;
  left: 5px;
  font-size: 11.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.tl-dot {
  position: absolute;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: #6f675c;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.tl-dot.special {
  background: #d99a00;
}
.tl-dot.national {
  background: #b3261e;
}
.tl-dot.city {
  background: #1d4f8c;
}
.tl-dot.unsure {
  opacity: 0.55;
}
.tl-dot:hover,
.tl-dot:focus-visible {
  transform: scale(1.5);
  opacity: 1;
  z-index: 2;
}
.tl-dot.static {
  position: static;
  display: inline-block;
  margin: 0 2px -2px 0;
}
.tl-key {
  margin-top: 8px;
}
.tl-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}
.tl-era,
.tl-cent {
  margin-top: 34px;
}
.tl-era header {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
}
.tl-era h2,
.tl-cent h2 {
  font-size: 26px;
  color: var(--lacquer);
}
.tl-era header p,
.tl-cent h2 small {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-faint);
  margin-left: 10px;
}
.tl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 0 26px;
}
.tl-list a {
  display: grid;
  grid-template-columns: 62px 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.tl-list a:hover {
  background: var(--paper-2);
}
.tl-year {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--lacquer);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tl-list img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 5px;
}
.tl-item {
  display: grid;
  min-width: 0;
}
.tl-item b {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--green);
}
.tl-item small {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.tl-item .tag {
  margin-left: 6px;
}
.tl-cent h2 {
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
}
.tl-cent ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2 380px;
  column-gap: 34px;
}
.tl-cent li {
  break-inside: avoid;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  line-height: 1.45;
}
.tl-cent li a {
  white-space: nowrap;
  font-size: 13px;
}
@media (max-width: 560px) {
  .tl-list {
    grid-template-columns: 1fr;
  }
  .tl-list a {
    grid-template-columns: 54px 60px minmax(0, 1fr);
  }
  .tl-list .badge {
    display: none;
  }
  .tl-list img {
    width: 60px;
    height: 45px;
  }
}

/* ---------- print viewer ---------- */
.pv {
  height: calc(100vh - var(--bar) - 2px);
  height: calc(100dvh - var(--bar) - 2px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #23201b;
  color: #eee4cf;
}
.pv-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 14px;
  background: #1a1814;
  font-size: 13px;
}
.pv-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pv-select select {
  height: 34px;
  max-width: 260px;
  background: #2c2822;
  color: #eee4cf;
  border-color: rgba(255, 255, 255, 0.2);
}
.pv-label {
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}
.pv-main {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  min-height: 0;
}
.pv-stage {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  container-type: size;
}
.pv-sheet {
  display: flex;
  height: min(100cqh - 24px, (100cqw - 12px) / 1.5455);
  max-width: 100%;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.pv-page {
  height: 100%;
  aspect-ratio: 612 / 792;
  background: #f8f2e4;
  min-width: 0;
}
.pv-page.blank {
  background: transparent;
  box-shadow: none;
}
.pv-page img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}
.pv-page.blank img {
  display: none;
}
.pv-page.left {
  box-shadow: inset -14px 0 18px -14px rgba(0, 0, 0, 0.35);
}
.pv-sheet.single {
  height: min(100cqh - 16px, (100cqw - 8px) / 0.7727);
}
.pv-sheet.zoomed,
.pv-sheet.single.zoomed {
  height: auto;
  width: 190%;
  max-width: none;
  justify-self: start;
  align-self: start;
}
.pv-sheet.zoomed .pv-page {
  height: auto;
  flex: 1;
}
.pv-sheet.single.zoomed {
  width: 180%;
}
.pv-nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  display: grid;
  place-items: center;
  justify-self: center;
}
.pv-nav:hover {
  background: rgba(255, 255, 255, 0.18);
}
.pv-nav svg {
  width: 22px;
  height: 22px;
}
.pv-foot {
  padding: 8px 18px 12px;
  background: #1a1814;
}
.pv-foot input {
  width: 100%;
  accent-color: var(--gold-bright);
}
@media (max-width: 640px) {
  .pv-main {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }
  .pv-nav {
    position: absolute;
    bottom: 10px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.55);
  }
  .pv-nav.prev {
    left: 10px;
  }
  .pv-nav.next {
    right: 10px;
  }
  .pv-select span {
    display: none;
  }
  .pv-select select {
    max-width: 170px;
  }
}
