:root {
  --paper: #f3f1eb;
  --ink: #11110f;
  --muted: rgba(17, 17, 15, 0.47);
  --hairline: rgba(17, 17, 15, 0.16);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: clip;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  max-height: 100svh;
  margin: 0;
  overflow: clip;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
}

button { color: inherit; font: inherit; }

.site-header {
  position: absolute;
  z-index: 60;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  padding:
    calc(16px + env(safe-area-inset-top, 0px))
    calc(18px + env(safe-area-inset-right, 0px))
    16px
    calc(18px + env(safe-area-inset-left, 0px));
  isolation: isolate;
  pointer-events: none;
}

.wordmark,
.filter-stack,
.filters,
.filter,
.color-filters,
.color-filter { pointer-events: auto; }

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.045em;
  cursor: pointer;
}

.wordmark__sub {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.wordmark__logo {
  display: block;
  width: auto;
  height: 18px;
}

.filter-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter {
  padding: 5px 7px 4px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 20px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.045em;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.filter sup {
  margin-left: 2px;
  font-size: 6px;
}

.filter:hover,
.filter.is-active {
  border-color: var(--hairline);
  color: var(--ink);
}

.color-filters {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 14px;
  padding-right: 7px;
}

.color-filter {
  --swatch: transparent;
  position: relative;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 1px solid rgba(17, 17, 15, .20);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: opacity 140ms ease, outline-color 140ms ease, transform 140ms ease;
}

.color-filter:hover { transform: scale(1.14); }

.color-filter.is-active {
  outline: 1px solid rgba(17, 17, 15, .58);
  outline-offset: 2px;
}

.color-filter:disabled {
  opacity: .20;
  cursor: default;
  transform: none;
}

.color-filter--all {
  background: conic-gradient(from 45deg, #20221f, #8f9393, #d8d4ca, #8a6249, #b6433a, #d7a279, #d9ce65, #68784e, #4e7486, #20221f);
}

.viewport {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.viewport.is-dragging { cursor: grabbing; }

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 3100px;
  height: 2980px;
  transform-origin: 0 0;
  will-change: transform;
}

.stage::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background-image: radial-gradient(circle, rgba(17, 17, 15, .31) 0 1.15px, transparent 1.3px);
  background-position: 0 0;
  background-size: 55px 55px;
  pointer-events: none;
}

.reference {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(9px);
  animation: reveal 500ms cubic-bezier(.22,.61,.36,1) forwards;
  transition: left 280ms cubic-bezier(.2,.7,.2,1), top 280ms cubic-bezier(.2,.7,.2,1), opacity 180ms ease, filter 180ms ease;
}

.reference[hidden] { display: none !important; }

.stage.is-reflowing .reference {
  transition: none;
}

.reference__float {
  display: block;
  animation: drift var(--drift-duration, 8s) ease-in-out var(--drift-delay, 0s) infinite alternate;
  animation-play-state: paused;
}

.reference.is-nearby .reference__float { animation-play-state: running; }

.reference__image {
  display: block;
  width: var(--image-width, 180px);
  max-height: 255px;
  object-fit: contain;
  filter: saturate(.93) contrast(.98);
  transition: transform 180ms cubic-bezier(.2,.7,.2,1), filter 180ms ease;
}

.reference__image.is-zoom-source {
  visibility: hidden;
}

.reference:hover .reference__image {
  transform: scale(1.035);
  filter: saturate(1) contrast(1);
}

.reference__number {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  color: var(--muted);
  font-size: 7px;
  letter-spacing: .08em;
  opacity: 0;
  transition: opacity 150ms ease;
}

.reference:hover .reference__number { opacity: 1; }

.hint,
.coordinates {
  position: absolute;
  z-index: 20;
  bottom: calc(15px + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .08em;
}

.hint { left: 18px; }
.coordinates { right: 18px; font-variant-numeric: tabular-nums; }

.viewer {
  position: absolute;
  z-index: 100;
  inset: 0;
  background: rgba(243, 241, 235, .74);
  backdrop-filter: blur(7px);
  visibility: hidden;
  opacity: 0;
  transition: opacity 155ms ease, visibility 0s linear 155ms;
  cursor: zoom-out;
}

.viewer.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity 155ms ease;
}

.viewer__figure {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
}

.viewer__image {
  position: absolute;
  z-index: 2;
  display: block;
  object-fit: contain;
  max-width: none;
  max-height: none;
  box-shadow: 0 18px 60px rgba(17, 17, 15, 0);
  cursor: zoom-out;
  pointer-events: auto;
  transition:
    left 245ms cubic-bezier(.22,.72,.22,1),
    top 245ms cubic-bezier(.22,.72,.22,1),
    width 245ms cubic-bezier(.22,.72,.22,1),
    height 245ms cubic-bezier(.22,.72,.22,1),
    box-shadow 245ms ease;
  will-change: left, top, width, height;
}

.viewer.is-settled .viewer__image {
  box-shadow: 0 18px 60px rgba(17, 17, 15, .10);
}

.viewer__caption {
  position: absolute;
  z-index: 3;
  bottom: 6vh;
  left: 50%;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 14px;
  width: min(70vw, 900px);
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .055em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.viewer.is-settled .viewer__caption { opacity: 1; }

.viewer__title {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer__category { text-align: right; }

.viewer__close {
  position: absolute;
  z-index: 2;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.viewer__close {
  top: 16px;
  right: 18px;
  padding: 6px;
  font-size: 9px;
  letter-spacing: .07em;
}

@keyframes reveal { to { opacity: 1; transform: translateY(0); } }
@keyframes drift { to { transform: translate3d(var(--drift-x, 5px), var(--drift-y, -7px), 0) rotate(var(--drift-r, .35deg)); } }

@media (prefers-reduced-motion: reduce) {
  .reference, .reference__float, .viewer, .viewer__image { animation: none; transition-duration: 0.01ms; }
  .reference { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  /* Keep mobile compositing light enough that iOS never starves touch input. */
  .reference,
  .reference__float {
    animation: none;
  }

  .reference {
    opacity: 1;
    transform: none;
  }

  .reference__image {
    width: calc(var(--image-width, 180px) * .9);
    max-height: 225px;
  }

  .site-header {
    gap: 8px;
    padding:
      calc(10px + env(safe-area-inset-top, 0px))
      calc(11px + env(safe-area-inset-right, 0px))
      10px
      calc(11px + env(safe-area-inset-left, 0px));
  }

  .wordmark {
    flex: 0 0 auto;
    gap: 7px;
  }

  .wordmark__logo { height: 15px; }

  .wordmark__sub {
    display: block;
    font-size: 7px;
    letter-spacing: .07em;
    white-space: nowrap;
  }

  .filter-stack {
    flex: 1 1 auto;
    min-width: 0;
    gap: 5px;
  }

  .filters {
    justify-content: flex-end;
    width: 100%;
    gap: 0;
  }

  .filter {
    padding: 4px 4px 3px;
    font-size: 7px;
    letter-spacing: .025em;
    white-space: nowrap;
  }

  .filter sup {
    display: inline;
    margin-left: 1px;
    font-size: 5px;
  }

  .color-filters {
    justify-content: space-between;
    width: 100%;
    gap: 0;
    min-height: 22px;
    padding: 0 var(--color-filter-end, 0px) 0 var(--color-filter-start, 0px);
  }

  .color-filter {
    width: 16px;
    height: 22px;
    border: 0;
    border-radius: 0;
    background: transparent;
    outline: 0;
  }

  .color-filter.is-active {
    outline: 0;
    outline-offset: 0;
  }

  .color-filter::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 2.9px;
    width: 10.2px;
    height: 10.2px;
    border: 1px solid rgba(17, 17, 15, .20);
    border-radius: 50%;
    background: var(--swatch);
    transform: translateY(-50%);
  }

  .color-filter--all::before {
    background: conic-gradient(from 45deg, #20221f, #8f9393, #d8d4ca, #8a6249, #b6433a, #d7a279, #d9ce65, #68784e, #4e7486, #20221f);
  }

  .color-filter.is-active::before {
    outline: 1px solid rgba(17, 17, 15, .58);
    outline-offset: 2px;
  }

  .color-filter:hover { transform: none; }
  .hint { left: 11px; max-width: 68vw; font-size: 7px; white-space: nowrap; }
  .coordinates { right: 11px; }
  .viewer__caption { bottom: 6vh; width: 86vw; grid-template-columns: auto 1fr; }
  .viewer__category { display: none; }
}

html.is-viewport-normalizing body {
  visibility: hidden;
}

html.is-viewport-normalizing .viewport {
  pointer-events: none;
}

@media (max-width: 390px) {
  .site-header {
    gap: 5px;
    padding-right: calc(8px + env(safe-area-inset-right, 0px));
    padding-left: calc(8px + env(safe-area-inset-left, 0px));
  }

  .wordmark { gap: 5px; }
  .wordmark__logo { height: 13px; }
  .wordmark__sub { font-size: 6px; }
  .filter { padding-inline: 3px; font-size: 6.5px; }
  .filter sup { font-size: 4.5px; }
  .color-filters { gap: 0; }
  .color-filter { width: 16px; height: 22px; }
  .hint { left: 8px; }
  .coordinates { right: 8px; }
}
