:root {
  --bg: #F2ECE4;
  --bg-map: #F2ECE4;
  --text: #1C1C1C;
  --text-muted: #5A534C;
  --accent: #9E2A2B;
  --sidebar-width: clamp(300px, 28vw, 420px);
  --page-padding: 2vh;
  --frame-border: 1px;
  /* Inline 16×16 red-dot map cursor; falls back to move. */
  --cursor-map: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOElEQVR4nGNgGAW0BfO0tP+DMD41TPg0Y2MTZcA8LBpwGcLEQCFgwiaYdO0qIzFiVAnEUcBAOQAAcr4TtZ/TmbsAAAAASUVORK5CYII=") 8 8, move;
}

.red-frame {
  border: var(--frame-border) solid var(--accent);
  border-radius: 2px;
  box-sizing: border-box;
  background-color: var(--bg-map);
}

body,
html {
  background-size: cover;
  background-color: var(--bg);
  background-repeat: no-repeat;
  position: absolute;
  background-position: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  color: var(--text);
}

.wrapper {
  height: 100vh;
  height: 100dvh;
  padding: var(--page-padding);
  box-sizing: border-box;
}

.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100%;
  gap: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: var(--frame-border) solid var(--accent);
  min-height: 0;
}

.sidebar-contact {
  flex-shrink: 1;
  flex-grow: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  max-height: min(var(--sidebar-width), 30dvh);
  min-height: 0;
  border-bottom: var(--frame-border) solid var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 21px;
  letter-spacing: 0.04em;
  background-color: var(--bg-map);
}

.contact-corner-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.contact-trigger {
  position: relative;
  z-index: 1;
}

.sidebar-contact a,
.contact-trigger {
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 0;
}

.sidebar-exhibitions {
  flex: 1 1 auto;
  min-height: min(36vh, 340px);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.exhibitions-trigger {
  display: none;
}

.exhibitions-list-wrap {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.sidebar-feature {
  flex-shrink: 1;
  flex-grow: 0;
  position: relative;
  border: none;
  border-top: var(--frame-border) solid var(--accent);
  width: 100%;
  aspect-ratio: 1;
  max-height: min(var(--sidebar-width), 30dvh);
  min-height: 0;
  overflow: hidden;
  background-color: var(--bg-map);
  padding: 0;
  cursor: pointer;
  display: block;
}

.sidebar-feature img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1);
  transform-origin: center center;
  transition: transform 0.35s ease;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .sidebar-feature:hover img {
    transform: scale(1.12);
  }
}

.grid-container2 {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr) 2.75rem;
  column-gap: 0.75em;
  align-content: start;
  height: 100%;
  overflow-y: auto;
  padding: 1.5vh 1rem 2vh;
  font-family: 'Inter', sans-serif;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.grid-container2::-webkit-scrollbar {
  display: none;
}

.map-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
}

.scroll-arrow {
  position: absolute;
  right: 0.5rem;
  width: 30px;
  height: 30px;
  cursor: pointer;
  z-index: 51;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .scroll-arrow:hover {
    opacity: 1;
  }
}

.scroll-arrow svg {
  width: 100%;
  height: 100%;
}

.scroll-arrow svg polygon {
  fill: var(--accent);
}

.scroll-arrow-up {
  top: 0.5rem;
  bottom: auto;
}

.scroll-arrow-down {
  bottom: 0.5rem;
}

.grid-row {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: baseline;
  padding: 0.55em 0 0;
  color: var(--text);
  text-decoration: none;
}

.grid-row:not(:last-child)::after {
  content: '';
  grid-column: 1 / -1;
  display: block;
  width: 75%;
  margin: 0.55em auto 0;
  border-top: 1px solid var(--accent);
}

.grid-row .grid-item,
.grid-row .grid-item2 {
  cursor: default;
}

.grid-item {
  font-family: 'Inter', sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-item2 {
  font-size: 14px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  white-space: nowrap;
  text-align: right;
}

a {
  color: var(--text);
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: color 0.2s ease;
}

a:visited {
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--accent);
  }
}

.map-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  overflow: hidden;
  cursor: var(--cursor-map);
  touch-action: none;
}

.map-viewport:active {
  cursor: var(--cursor-map);
}

.map-viewport.dragging,
.map-viewport.gliding {
  user-select: none;
  cursor: var(--cursor-map);
}

/* While panning, islands must not receive hover/hit-testing:
   hover scale effects mid-drag force style recalc + repaint of the world layer. */
.map-viewport.dragging .islands-layer,
.map-viewport.gliding .islands-layer {
  pointer-events: none;
}

.map-world {
  position: absolute;
  width: 200%;
  height: 200%;
  top: 0;
  left: 0;
  touch-action: none;
  --island-scale: 1;
  overflow: visible;
  transform: translate3d(0, 0, 0);
}

.map-viewport.dragging .map-world,
.map-viewport.gliding .map-world {
  will-change: transform;
}

.islands-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  overflow: visible;
}

.pathway-svg,
.arrow-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pathway-svg {
  z-index: 2;
}

.arrow-svg {
  z-index: 3;
}

#pathway-group .pathway-line {
  stroke-width: 1.25;
  stroke-linecap: round;
}

.island {
  position: absolute;
  width: 240px;
  height: 240px;
  --island-frame-size: 67%;
  --island-photo-inset: 30%;
  --island-photo-scale: 1;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(var(--island-scale, 1));
  transform-origin: center center;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .island {
    transition: transform 0.15s ease;
  }

  .map-viewport.dragging .island {
    transition: none;
  }

  .map-viewport.gliding .island {
    transition: none;
  }
}

@media (max-width: 950px) {
  .island {
    transition: none;
  }
}

/* No will-change here: keeping the hover layer un-promoted lets the browser
   re-rasterize the frame at the enlarged scale, which avoids a faint dark
   square (stale-texture edge) around the frame while hovered. */
@media (hover: hover) and (pointer: fine) {
  .island:hover {
    transform: scale(calc(var(--island-scale, 1) * 1.3));
    z-index: 10;
  }
}

.island-photo {
  width: var(--island-frame-size);
  height: var(--island-frame-size);
  position: relative;
  z-index: 1;
  pointer-events: auto;
  cursor: pointer;
  flex-shrink: 0;
  transform-origin: center center;
  background-color: var(--bg-map);
}

.island-photo-fill {
  position: absolute;
  inset: var(--island-photo-inset);
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.island-photo-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(var(--island-photo-scale));
  transform-origin: center center;
}

.island-frame {
  position: absolute;
  inset: 0;
  background-image: none;
  background-color: transparent;
  pointer-events: none;
  z-index: 2;
}

.frame-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--accent);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.frame-dot--tl {
  left: calc(var(--island-photo-inset) - 6%);
  top: calc(var(--island-photo-inset) - 6%);
}

.frame-dot--tr {
  left: calc(100% - var(--island-photo-inset) + 6%);
  top: calc(var(--island-photo-inset) - 6%);
}

.frame-dot--bl {
  left: calc(var(--island-photo-inset) - 6%);
  top: calc(100% - var(--island-photo-inset) + 6%);
}

.frame-dot--br {
  left: calc(100% - var(--island-photo-inset) + 6%);
  top: calc(100% - var(--island-photo-inset) + 6%);
}

.frame-edge {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

/* Perpendicular ticks: half the photo edge length, fade in/out. */
.frame-edge--t,
.frame-edge--b {
  left: 50%;
  width: 2px;
  height: calc((100% - 2 * var(--island-photo-inset)) * 0.5);
  transform: translate(-50%, -50%);
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--accent) 50%,
    transparent 100%
  );
}

.frame-edge--t {
  top: calc(var(--island-photo-inset) - 8%);
}

.frame-edge--b {
  top: calc(100% - var(--island-photo-inset) + 8%);
}

.frame-edge--l,
.frame-edge--r {
  top: 50%;
  height: 2px;
  width: calc((100% - 2 * var(--island-photo-inset)) * 0.5);
  transform: translate(-50%, -50%);
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--accent) 50%,
    transparent 100%
  );
}

.frame-edge--l {
  left: calc(var(--island-photo-inset) - 8%);
}

.frame-edge--r {
  left: calc(100% - var(--island-photo-inset) + 8%);
}

@media (hover: hover) and (pointer: fine) {
  .island:hover .frame-dot {
    filter: brightness(1.08);
  }
}

.island-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}

@keyframes flatSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.island-photo.spinning {
  animation: flatSpin 0.6s ease-in-out;
}

@keyframes scramblePop {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  40% {
    transform: scale(0.45) rotate(-40deg);
    opacity: 0.25;
  }
  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

.island-photo.scrambling {
  animation: scramblePop 0.75s ease-in-out;
}

.photo-lightbox {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(30, 25, 20, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.photo-lightbox.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-frame {
  position: relative;
  padding: 40px;
  display: inline-block;
  line-height: 0;
  z-index: 1;
}

.lightbox-image {
  position: relative;
  z-index: 1;
  max-width: calc(90vw - 80px);
  max-height: calc(90vh - 80px);
  object-fit: contain;
  animation: fadeIn 0.3s ease;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 3vh;
  right: 4vw;
  font-size: 60px;
  color: var(--bg);
  cursor: pointer;
  z-index: 1001;
  font-weight: 400;
  transition: color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .lightbox-close:hover {
    color: var(--accent);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.contact-panel {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(30, 25, 20, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.contact-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.contact-panel-frame {
  position: relative;
  width: min(90vw, var(--sidebar-width));
  aspect-ratio: 1;
  display: flex;
  padding: 2rem 2rem 1.5rem;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
  animation: fadeIn 0.3s ease;
  user-select: text;
  border: var(--frame-border) solid var(--accent);
  background-color: var(--bg-map);
}

.contact-panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: 0.5rem;
}

.contact-panel-info {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
  text-align: center;
}

.contact-panel-art {
  width: auto;
  max-width: 55%;
  max-height: 38%;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.contact-panel-info p {
  margin: 0;
}

.contact-panel-close {
  position: absolute;
  top: 3vh;
  right: 4vw;
  font-size: 60px;
  color: var(--bg);
  cursor: pointer;
  z-index: 1001;
  font-weight: 400;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.exhibitions-panel {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(30, 25, 20, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.exhibitions-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.exhibitions-panel-frame {
  position: relative;
  width: calc(100% - 2vh);
  height: calc(100dvh - 2vh);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 3.5rem 1rem 1.25rem;
  font-family: 'Inter', sans-serif;
  animation: fadeIn 0.3s ease;
  border: var(--frame-border) solid var(--accent);
  background-color: var(--bg-map);
}

.exhibitions-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.exhibitions-panel-scroll .grid-container2 {
  height: 100%;
  max-height: none;
  padding: 1rem 0.5rem 1.5rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.35fr) 3rem;
}

.exhibitions-panel-close {
  position: absolute;
  top: max(1vh, env(safe-area-inset-top));
  right: max(3vw, env(safe-area-inset-right));
  font-size: 44px;
  color: var(--bg);
  cursor: pointer;
  z-index: 1001;
  font-weight: 400;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .contact-trigger:hover,
  .sidebar-contact a:hover {
    color: var(--accent);
  }

  .contact-panel-close:hover,
  .exhibitions-panel-close:hover {
    color: var(--accent);
  }

  .exhibitions-trigger:hover {
    color: var(--accent);
  }
}

@media (hover: none) {
  .contact-trigger:active,
  .exhibitions-trigger:active {
    color: var(--accent);
  }
}

@media (max-width: 950px) {
  :root {
    --page-padding: 1vh;
    --mobile-square: clamp(112px, 31vw, 168px);
  }

  .wrapper {
    padding:
      max(var(--page-padding), env(safe-area-inset-top))
      max(var(--page-padding), env(safe-area-inset-right))
      max(var(--page-padding), env(safe-area-inset-bottom))
      max(var(--page-padding), env(safe-area-inset-left));
  }

  .page-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
  }

  .map-panel {
    order: 1;
    min-height: 0;
  }

  .sidebar {
    order: 2;
    flex-direction: row;
    align-items: stretch;
    height: var(--mobile-square);
    min-height: var(--mobile-square);
    border-right: none;
    border-top: var(--frame-border) solid var(--accent);
  }

  .sidebar-contact {
    flex: 1 1 0;
    width: auto;
    height: 100%;
    aspect-ratio: auto;
    max-height: none;
    min-height: 0;
    font-size: clamp(13px, 3.6vw, 17px);
    border-bottom: none;
    border-right: var(--frame-border) solid var(--accent);
  }

  .sidebar-exhibitions {
    flex: 1 1 0;
    width: auto;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    border-right: var(--frame-border) solid var(--accent);
  }

  .exhibitions-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text);
    background: none;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: clamp(12px, 3.4vw, 16px);
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
  }

  .exhibitions-list-wrap {
    display: none;
  }

  .sidebar-feature {
    flex: 1 1 0;
    width: auto;
    height: 100%;
    aspect-ratio: auto;
    max-height: none;
    min-height: 0;
    border-top: none;
    border-left: none;
  }

  .scroll-arrow {
    display: none;
  }

  .island {
    width: clamp(120px, 28vw, 180px);
    height: clamp(120px, 28vw, 180px);
  }

  .island-label {
    font-size: 9px;
    bottom: -12px;
  }

  .lightbox-frame {
    padding: 20px;
  }

  .lightbox-image {
    max-width: calc(100vw - 40px);
    max-height: calc(100dvh - 40px);
  }

  .lightbox-close,
  .contact-panel-close {
    font-size: 44px;
    top: max(1vh, env(safe-area-inset-top));
    right: max(3vw, env(safe-area-inset-right));
  }

  .contact-panel-frame {
    width: min(92vw, 360px);
    padding: 1.5rem 1.25rem 1rem;
  }

  .contact-panel-info {
    font-size: clamp(14px, 3.8vw, 17px);
    line-height: 1.65;
  }

  .contact-panel-art {
    max-width: 62%;
    max-height: 36%;
  }

  .exhibitions-panel-scroll .grid-container2 {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 3rem;
  }

  .exhibitions-panel-scroll .grid-item {
    font-size: clamp(14px, 3.8vw, 17px);
  }

  .exhibitions-panel-scroll .grid-item2 {
    font-size: clamp(13px, 3.4vw, 15px);
  }
}

@media (max-width: 650px) {
  :root {
    --mobile-square: clamp(100px, 29vw, 148px);
  }

  .island {
    width: clamp(100px, 26vw, 150px);
    height: clamp(100px, 26vw, 150px);
  }
}

@media (max-width: 380px) {
  :root {
    --mobile-square: clamp(92px, 27vw, 128px);
  }

  .sidebar-contact {
    font-size: 11px;
  }

  .exhibitions-trigger {
    font-size: 11px;
  }

  .island {
    width: 92px;
    height: 92px;
  }
}
