/* Ornaments of the Earth — tokens lifted from the SANROK Figma library */
:root {
  --s1: 4px;  --s3: 8px;  --s4: 12px;  --s5: 16px;  --s6: 24px;

  --ink: #293b3c;          /* 100  */
  --bg: #d9d7d2;           /* 300  */
  --surface: #e5e2dd;      /* 400  */
  --surface-lt: #edeae6;   /* 500  */
  --accent: #706ce0;       /* 1000 */
  --blue: #1f59d5;

  --line: rgba(41, 59, 60, 0.15);   /* 100 @ 15% */
  --muted: rgba(41, 59, 60, 0.5);   /* 100 @ 50% */
  --accent-15: rgba(112, 108, 224, 0.15);

  --radius: 4px;
  --card-w: 180px;
  --mono: "Chivo Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Platypi", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 300;
  font-size: 14px;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

img { max-width: 100%; display: block; }

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- stage */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#globe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.stage.is-dragging #globe { cursor: grabbing; }

.leaders,
.pins,
.cards {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.leaders { width: 100%; height: 100%; }
.leaders line {
  stroke: var(--ink);
  stroke-opacity: 0.35;
  stroke-width: 1;
  shape-rendering: geometricPrecision;
}

/* pins ------------------------------------------------------------------ */

.pin {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--blue);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.pin--dim { background: var(--ink); opacity: 0.28; }
.pin:hover,
.pin.is-active { transform: scale(1.9); background: var(--accent); }

/* tooltip ---------------------------------------------------------------- */

/* rides the pointer, so it never covers the dot it is describing */
.tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: max-content;
  max-width: 260px;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(41, 59, 60, 0.12);
  pointer-events: none;
  animation: tip-in 0.12s ease;
}
@keyframes tip-in { from { opacity: 0; } }

.tip-img {
  flex: 0 0 48px;
  width: 48px;
  height: 40px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--surface-lt);
}
.tip-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tip-title {
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink);
  /* two lines is enough for the long museum titles without a wall of text */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tip-sub {
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tip-meta {
  display: flex;
  gap: var(--s3);
  font-size: 10px;
  color: var(--muted);
}
.tip-meta span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tip-meta span:empty { display: none; }

/* cards ----------------------------------------------------------------- */

.card {
  position: absolute;
  width: var(--card-w);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius);
  pointer-events: auto;
  cursor: pointer;
  text-align: left;
  opacity: 0;
  transition: opacity 0.45s ease, left 0.5s ease, top 0.5s ease;
}
.card.is-in { opacity: 1; }
.card:hover { background: var(--surface-lt); }

.card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 300 / 200;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-lt);
}
.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-title { color: var(--ink); }
.card-sub { color: var(--muted); }
.card-title,
.card-sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: -0.01em;
  color: var(--muted);
}

/* stage chrome ---------------------------------------------------------- */

.stage-readout {
  position: absolute;
  bottom: var(--s4);
  left: var(--s4);
  max-width: calc(100% - 32px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--muted);
  z-index: 2;
}

/* ----------------------------------------------------------- bottom bar */

.bar {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.bar-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 8px;
  border-bottom: 1px solid var(--line);
}
.bumper-r { width: 8px; height: 100%; border-right: 1px solid var(--line); }
.bumper-l { width: 8px; height: 100%; border-left: 1px solid var(--line); }

.bar-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.bumper { flex: 0 0 8px; }

.cell {
  display: flex;
  align-items: center;
  padding: var(--s5) var(--s6);
}
.cell--grow { flex: 1 1 0; min-width: 0; }
.cell--l { border-left: 1px solid var(--line); }
.cell--r { border-right: 1px solid var(--line); }
.logo { border-right: 1px solid var(--line); }
.bar-row--top .cell--grow { border-right: 1px solid var(--line); }

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.22px;
  white-space: nowrap;
}
.wordmark-a { display: block; }
.wordmark-b {
  font-weight: 400;
  font-size: 14.19px;
  letter-spacing: 0.88px;
}
.wordmark-a:last-child { display: inline; }

/* slider ---------------------------------------------------------------- */

.slider { width: 100%; display: flex; flex-direction: column; gap: var(--s1); }
.slider-label { display: flex; align-items: flex-end; gap: var(--s3); }
.slider-key { font-size: 14px; white-space: nowrap; }
.slider-range { flex: 1 1 0; text-align: right; font-size: 12px; color: var(--muted); }

.slider-track {
  position: relative;
  height: 22px;
  border-radius: var(--radius);
  background: var(--surface-lt);
  cursor: ew-resize;
}
.slider-fill {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 8px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(to right, var(--line), var(--accent-15));
}
.slider-value {
  position: absolute;
  top: 4px;
  right: var(--s3);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
  pointer-events: none;
}
.slider-grip {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  display: flex;
  gap: 1px;
}
.slider-grip i { width: 1px; height: 16px; background: var(--surface-lt); }

/* search ---------------------------------------------------------------- */

.search {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 40px;
  padding: 0 var(--s4);
  background: var(--surface-lt);
  border-top: 1px solid var(--line);
  border-radius: var(--radius);
}
.search-icon { flex: 0 0 16px; width: 16px; height: 16px; opacity: 0.55; }
.search input {
  flex: 1 1 0;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: none;
  border: 0;
  outline: none;
  padding: 0;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.keycap--search { flex: 0 0 auto; border-color: var(--line); }

/* the field sits at the foot of the page, so results rise from it */
.search-flyout {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + var(--s3));
  z-index: 25;
  max-height: min(52vh, 460px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(41, 59, 60, 0.14);
  animation: flyout-in 0.14s ease;
}
@keyframes flyout-in { from { transform: translateY(6px); opacity: 0; } }

.search-count {
  flex: 0 0 auto;
  margin: 0;
  padding: var(--s3) var(--s4);
  font-size: 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.search-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hit {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  padding: var(--s3) var(--s4);
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.search-list li:last-child .hit { border-bottom: 0; }
.hit:hover,
.hit.is-active { background: var(--surface-lt); }

.hit-img {
  flex: 0 0 48px;
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--surface-lt);
}
.hit-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.hit-title,
.hit-sub {
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hit-sub { color: var(--muted); }
.hit-year { flex: 0 0 auto; font-size: 10px; color: var(--muted); }

.search-more {
  flex: 0 0 auto;
  padding: var(--s3) var(--s4);
  font-size: 12px;
  color: var(--accent);
  text-align: left;
  border-top: 1px solid var(--line);
  background: var(--surface-lt);
}
.search-more:hover { text-decoration: underline; }

.link {
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(41, 59, 60, 0.35);
  white-space: nowrap;
}
.link:hover { text-decoration-color: var(--accent); color: var(--accent); }

/* switches -------------------------------------------------------------- */

.switch { display: flex; align-items: center; gap: var(--s3); }
.switch-track {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 40px;
  height: 22px;
  padding: var(--s1);
  border-radius: var(--radius);
  background: var(--line);
  transition: background 0.18s ease;
}
.switch.is-on .switch-track { justify-content: flex-end; background: var(--accent); }
.switch-knob {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--surface-lt);
}
.switch-knob i {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 12px;
  transform: translateY(-50%);
  background: var(--bg);
}
.switch-knob i:nth-child(1) { right: 4px; }
.switch-knob i:nth-child(2) { right: 7px; }
.switch-text { font-size: 14px; white-space: nowrap; }

.control { gap: var(--s6); padding-block: var(--s3); }

.disclaimer { flex: 0 0 500px; width: 500px; max-width: 500px; padding: var(--s3); }
.disclaimer p {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--muted);
}

/* ---------------------------------------------------------------- detail */

/* a centred lightbox over a blurred scrim, per the newflyout design */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;   /* above the index, which can open it */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px;
  background: var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: lightbox-in 0.18s ease;
}
@keyframes lightbox-in { from { opacity: 0; } }

.lightbox-panel {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.lightbox-media {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 48px;
  background: var(--bg);
}
.lightbox-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
}

/* the caption pins the close to the top and the record to the bottom */
.lightbox-caption {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s6);
  min-width: 0;
  max-width: 400px;
  overflow-y: auto;
  padding: var(--s6);
}

.detail-close {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--ink);
}
.keycap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  padding: 0 2px;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid rgba(41, 59, 60, 0.35);
  border-radius: 2px;
}
.detail-close:hover .keycap,
.index-close:hover .keycap { color: var(--ink); border-color: var(--ink); }

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  margin-top: auto;
}
.detail-section { display: flex; flex-direction: column; gap: var(--s5); width: 100%; }
.detail-section--download { gap: var(--s3); }

/* label plus a rule that runs out to the edge */
.bump { display: flex; align-items: center; gap: var(--s1); width: 100%; }
.bump span {
  font-size: 10px;
  letter-spacing: -0.01em;
  color: var(--muted);
}
.bump i { flex: 1 1 0; height: 1px; background: var(--line); }

.detail-title-sub { display: flex; flex-direction: column; gap: var(--s1); }
.detail-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.detail-sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.kv {
  margin: 0;
  font-size: 12px;
  background: var(--surface-lt);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.kv-row {
  display: flex;
  gap: var(--s5);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}
.kv-row:last-child { border-bottom: 0; }
.kv dt {
  flex: 0 0 130px;
  width: 130px;
  margin: 0;
  color: var(--muted);
}
.kv dd {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.kv a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--line);
}
.kv a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* -------------------------------------------------------------- download */

.dl-row { display: flex; align-items: center; gap: var(--s5); width: 100%; }

.btn-plain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 var(--s4) 0 11px;
  font-size: 14px;
  color: var(--ink);
  border-radius: var(--radius);
}
.btn-plain:hover { background: var(--surface-lt); }
.btn-plain[aria-busy="true"] { color: var(--muted); }
.btn-plain img { width: 16px; height: 16px; }

.dl-meta {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  color: var(--muted);
}
.dl-meta span { display: block; }

/* ----------------------------------------------------------------- index */

.index {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.index-bar {
  display: flex;
  align-items: center;
  gap: var(--s6);
  flex-wrap: wrap;
  padding: var(--s4) var(--s6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.index-title { margin: 0; }
.index-filters { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.index-count { margin: 0 0 0 auto; font-size: 14px; color: var(--muted); }
.index-close {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink);
}

.field { display: flex; align-items: center; gap: var(--s3); font-size: 14px; color: var(--muted); }
.field select,
.field input {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 5px var(--s3);
  background: var(--surface-lt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field--search input { width: 200px; }

.index-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: var(--s5);
  padding: var(--s6);
  align-content: start;
}
.index-grid .card {
  position: static;
  width: auto;
  opacity: 1;
  transition: background 0.15s ease;
}

.index-empty {
  grid-column: 1 / -1;
  padding: var(--s6) 0;
  color: var(--muted);
}

/* --------------------------------------------------------------- loading */

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  transition: opacity 0.3s ease;
}
.loading.is-out { opacity: 0; pointer-events: none; }

.loading-msg {
  max-width: 460px;
  padding: var(--s6);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.loading-msg p { margin: 0 0 var(--s4); }
.loading-msg p:last-child { margin-bottom: 0; }
.loading-msg pre {
  margin: 0 0 var(--s4);
  padding: var(--s4);
  overflow-x: auto;
  font: inherit;
  background: var(--surface-lt);
  border-radius: var(--radius);
}
.loading-msg a { color: var(--accent); }

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

@media (max-width: 900px) {
  /* no room for the card columns, so the globe carries the stage alone */
  .cards,
  .leaders,
  .bar-rule,
  .bumper { display: none; }

  /* the bar stacks into full-width bands instead of wrapping mid-row */
  .bar-row { flex-direction: column; align-items: stretch; }
  .cell {
    padding: var(--s4) var(--s5);
    border-left: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .bar-row--top .cell--grow,
  .logo { border-right: 0; }
  .cell--grow { flex: 0 0 auto; }
  .control { flex-wrap: wrap; gap: var(--s4) var(--s5); }
  .disclaimer { flex: 1 1 auto; width: auto; max-width: none; border-bottom: 0; }
  .control { flex-wrap: wrap; gap: var(--s4); }
  .search { flex: 1 1 100%; }
  .disclaimer p { font-size: 9px; }
  .wordmark { font-size: 16px; }
  .stage-readout { font-size: 10px; }
  .field--search input { width: 100%; }
  .index-bar { gap: var(--s4); }
  .index-filters { width: 100%; }
  .index-count { margin-left: 0; }
  .index-grid { padding: var(--s5); gap: var(--s4); }
  .kv dt { flex-basis: 92px; width: 92px; }

  /* the lightbox stacks: image on top, record below */
  .lightbox { padding: var(--s5); }
  .lightbox-panel { flex-direction: column; overflow-y: auto; }
  .lightbox-media { flex: 0 0 auto; max-height: 45vh; padding: var(--s5); }
  .lightbox-caption { max-width: none; overflow: visible; }
  .detail-stack { margin-top: 0; }
}
