/* 歷史地圖元件：獨立維護，避免影響首頁其他視覺效果。 */

/* 故事內容與展覽資訊 */
.story {
  min-height: 200vh;
}
.story,
.exhibition-info-inline {
  scroll-margin-top: 6rem;
}
.story-content {
  position: relative;
  z-index: 5;
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  max-width: 1100px;
  justify-self: center;
  align-self: start;
  margin-top: clamp(2.5rem, 4vw, 4rem);
  padding: 0;
  display: grid;
  gap: clamp(2.25rem, 3.5vw, 3.5rem);
}
.overview-card {
  width: 100%;
  max-width: 1100px;
}
.story-content .exhibition-info-inline {
  min-height: 0;
  margin-top: 200px;
  padding: 0;
  display: block;
}
.exhibition-info-content {
  width: 100%;
  max-width: 1100px;
  margin-inline: 0;
  color: var(--title-ink);
}
.exhibition-date {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin: 0 0 clamp(2rem, 4vw, 3.25rem);
  line-height: 1.45 !important;
}
.exhibition-date span {
  color: var(--mountain-dark);
  font-size: 0.875rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.exhibition-date strong {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  letter-spacing: 0.08em;
}
.exhibition-info-groups {
  display: block;
}
.exhibition-info-group {
  margin-top: clamp(1.75rem, 3.5vw, 2.75rem);
  padding-top: 1rem;
  border-top: 1px solid rgba(55, 37, 15, 0.28);
}
.exhibition-info-group h3 {
  margin: 0 0 0.55rem;
  color: var(--title-ink);
  font-size: 1rem;
  letter-spacing: 0.14em;
}
.exhibition-info-group p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.85;
}
.exhibition-info-group .info-note {
  color: var(--mountain-dark);
  font-size: 0.875rem;
  font-weight: 800;
}
.organizer-line {
  padding-bottom: 0.5rem;
}
.overview-card p + p {
  margin-top: 0.8em;
}
.story-content h2 {
  margin: 0 0 12px;
  color: var(--title-ink);
  font-size: clamp(2.375rem, 4vw, 3.375rem);
  letter-spacing: 0.12em;
}
.story-content p {
  font-size: 1.0625rem;
  line-height: 2;
}

/* 藝術家名單與作品連結 */
.artist-list-wrap {
  position: static;
  z-index: 5;
  top: auto;
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  min-width: 0;
}
.artist-order-note {
  margin: 0 0 0.9rem;
  color: var(--mountain-dark);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.06em;
}
.artist-list {
  position: static;
  top: auto;
  max-height: none;
  overflow: visible;
  margin-block: 0;
  list-style: none;
}
.artist-list .artwork-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 4px 0 0;
  color: var(--mountain-dark);
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.55;
}
.artist-list .artwork-links a {
  color: var(--mountain-dark);
  font-size: 0.9375rem;
  font-weight: 900;
  text-decoration: none;
}
.artist-list .artwork-links a:hover,
.artist-list .artwork-links a:focus-visible {
  color: var(--artist-pin);
  text-shadow: 0 0 12px rgba(236, 101, 45, 0.32);
}
.exhibition-info-group .artist-order-note {
  margin-top: 0.45rem;
  color: var(--mountain-dark);
  font-size: 0.75rem;
  line-height: 1.6;
}

/* 地圖圖層與共用標記 */
.location-layer {
  position: relative;
  width: 100%;
  min-height: 0;
  scroll-margin-top: clamp(7.5rem, 10vw, 9rem);
  z-index: 8;
  border-radius: 6px;
  background-color: rgb(239, 247, 236);
  box-shadow: inset 0 0 0 1px rgba(55, 37, 15, 0.16);
  isolation: isolate;
  pointer-events: none;
}
.location-map-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
  filter: saturate(0.76) contrast(0.93) brightness(1.04);
  opacity: 0.72;
  pointer-events: none;
}
.location-map-scroll {
  width: 100%;
  overflow: visible;
  /* 保留地圖邊緣標記與標籤的顯示空間。 */
  padding-top: 4rem;
  padding-bottom: 4.5rem;
}
.location-map-card {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  justify-self: center;
  width: 100%;
  max-width: 1100px;
  min-width: 0;
  margin-top: clamp(1.5rem, 3vw, 3rem);
  border: 1px solid rgba(17, 17, 15, 0.13);
  border-radius: 10px;
  background-color: var(--panel);
  box-shadow: 0 24px 58px rgba(47, 110, 96, 0.17);
  backdrop-filter: blur(10px);
}
.location-map-caption {
  margin: 0.85rem 0 0;
  color: var(--mountain-dark);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.04em;
  text-align: right;
}
.pin {
  position: absolute;
  z-index: 1;
  left: var(--pin-x);
  top: var(--pin-y);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4c83a0;
  border: 0;
  box-shadow:
    0 0 0 7px rgba(76, 131, 160, 0.32),
    0 3px 9px rgba(36, 76, 97, 0.28);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  transition:
    opacity 0.75s ease,
    transform 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: var(--pin-delay, 0ms);
  will-change: opacity, transform;
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
}
.pin.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.pin::after {
  content: attr(data-label);
  position: absolute;
  z-index: 3;
  left: calc(100% + var(--label-gap, 0.55rem));
  top: var(--label-y, -10px);
  white-space: nowrap;
  padding: 7px 12px;
  border: 1px solid rgba(120, 92, 40, 0.38);
  border-radius: 6px;
  color: #37250f;
  background: #ecb77d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(126, 97, 43, 0.18),
    0 3px 0 rgba(126, 97, 43, 0.34),
    0 8px 16px rgba(55, 37, 15, 0.22);
  transform: perspective(28rem) rotateX(2deg);
  transform-origin: center bottom;
  font:
    900 0.8125rem/1.3 "Noto Serif TC",
    "Microsoft JhengHei",
    serif;
  transition:
    opacity 160ms ease,
    visibility 160ms ease,
    color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}
.artist-pin,
.context-pin,
.landmark-pin {
  width: 12px;
  height: 12px;
}

.artist-pin::after,
.context-pin::after,
.landmark-pin::after {
  left: calc(100% + var(--label-gap, 0.55rem));
  top: var(--label-y, -10px);
}
.artist-pin::after {
  color: var(--ink);
  opacity: 0;
  transform: perspective(28rem) translateY(0.75rem) rotateX(2deg);
  transition:
    opacity 0.9s ease,
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: var(--pin-delay, 0ms);
}
.artist-pin.is-visible::after {
  opacity: 1;
  transform: perspective(28rem) translateY(0) rotateX(2deg);
}
.pin:hover::after,
.pin:focus-visible::after {
  border-color: rgba(47, 110, 96, 0.72);
  color: #37250f;
  background: #ecb77d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(126, 97, 43, 0.2),
    0 5px 0 rgba(126, 97, 43, 0.4),
    0 14px 26px rgba(47, 110, 96, 0.28);
  transform: perspective(28rem) translateY(-3px) rotateX(5deg) scale(1.02);
}
.artist-pin:hover::after,
.artist-pin:focus-visible::after {
  color: #37250f;
}
.context-pin::after,
.landmark-pin::after {
  color: #37250f;
}
.context-pin:hover::after,
.context-pin:focus-visible::after,
.landmark-pin:hover::after,
.landmark-pin:focus-visible::after {
  color: #37250f;
}
.pin-align-left::after {
  right: calc(100% + var(--label-gap, 0.55rem));
  left: auto;
}

.pin:focus {
  outline: none;
}
.pin:hover,
.pin:focus-visible {
  z-index: 20;
  background: #35677f;
  box-shadow:
    0 0 0 8px rgba(76, 131, 160, 0.42),
    0 4px 12px rgba(36, 76, 97, 0.36);
}
/*
 * 標記座標：依附件 PDF 的 15 處圈選位置與道路交叉點，重新配準至目前
 * 實際使用的 736 × 857 map.jpg。以下百分比以圈選中心換算，並固定於
 * 同一個 location-layer，因此 RWD 縮放與手機橫向捲動時仍會和地圖同步。
 */
.pin-01 {
  --pin-x: 38.7843%;
  --pin-y: 39.5624%;
}
.pin-02 {
  --pin-x: 61.7863%;
  --pin-y: 72.9152%;
  --label-y: 5px;
}
.pin-03 {
  --pin-x: 60.2077%;
  --pin-y: 27.5049%;
}
.pin-04 {
  --pin-x: 71.3704%;
  --pin-y: 19.823%;
  --label-y: -22px;
}
.pin-05 {
  --pin-x: 56.7123%;
  --pin-y: 10.8771%;
  --label-y: 4px;
}
.pin-06 {
  --pin-x: 35.5144%;
  --pin-y: 76.4158%;
  --label-y: 8px;
}
.pin-07 {
  --pin-x: 47.2409%;
  --pin-y: 32.7557%;
}
.pin-08 {
  --pin-x: 63.3648%;
  --pin-y: 55.9957%;
  --label-y: 4px;
}
.pin-09 {
  /* 依使用者圈選圖的街廓配準：底圖座標約 (453, 849)，名稱放在圖外下方。 */
  --pin-x: 61.5489%;
  --pin-y: 99.0665%;
  --label-y: 28px;
}
.pin-10 {
  --pin-x: 62.0118%;
  --pin-y: 51.4255%;
}
.pin-11 {
  --pin-x: 63.7031%;
  --pin-y: 68.4422%;
  --label-y: -18px;
}
.pin-12 {
  --pin-x: 28.8619%;
  --pin-y: 62.3162%;
}
.pin-13 {
  --pin-x: 32.47%;
  --pin-y: 21.5733%;
}
.pin-14 {
  --pin-x: 45.6623%;
  --pin-y: 8.6406%;
  --label-y: -28px;
  --label-gap: 1rem;
}
.pin-15 {
  --pin-x: 48.1429%;
  --pin-y: 47.3415%;
  --label-y: -24px;
}

/* 響應式：平板改為直向內容流，保留可視地圖區域 */
@media (max-width: 1100px) {
  .story {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: auto;
  }
  .artist-list-wrap {
    position: static;
    order: 1;
    width: 100%;
  }
  .artist-list-wrap > .artist-order-note {
    width: min(calc(100% - 2rem), 46rem);
    margin-right: auto;
    margin-left: auto;
  }
  .artist-list {
    order: initial;
    margin-bottom: 0;
  }
  .story-content {
    order: 2;
    gap: 0;
    margin-top: 6.5rem;
    padding: 0;
  }
  .story-content .exhibition-info-inline {
    margin-top: 6.5rem;
  }
  .location-map-card {
    order: 3;
    width: 100%;
    margin-top: 0.75rem;
  }
  .location-layer {
    position: relative;
    inset: auto;
    width: 100%;
    min-height: 0;
    margin-top: 0;
  }
  .story-content h2 {
    font-size: clamp(2rem, 7vw, 2.3rem);
  }
  .story-content p {
    font-size: 1rem;
    line-height: 1.78;
  }
  .pin::after {
    font-size: 0.8125rem;
    padding: 0.25rem 0.45rem;
  }

  .artist-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(7, auto);
    grid-auto-flow: column;
    gap: 0 clamp(0.75rem, 4vw, 2rem);
    width: min(calc(100% - 2rem), 46rem);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
    border-left: 0;
  }
  .artist-list .dot {
    display: block;
    min-width: 0;
    width: min(100%, 16rem);
    justify-self: center;
    margin: 0;
    padding: 0 0 clamp(1.25rem, 3vw, 1.8rem) 1.75rem;
  }
  .artist-list .dot::before {
    left: 0;
    top: 0.45rem;
  }
  .artist-list .dot::after {
    content: "";
    position: absolute;
    left: 0.4rem;
    top: 1.45rem;
    bottom: 0;
    border-left: 2px dashed var(--mountain-dark);
    opacity: 0.78;
  }
  .artist-list .dot:nth-child(7)::after,
  .artist-list .dot:last-child::after {
    display: none;
  }
  .artist-list .artwork-links {
    align-self: start;
    margin-top: 0.2rem;
  }
  .artist-list .artwork-links a {
    display: inline-flex;
    align-items: center;
    min-height: 3rem;
    padding: 0.25rem 0;
    touch-action: manipulation;
  }
}

/* 響應式：手機保留原圖比例與精確座標，窄螢幕可水平查看完整地圖。 */
@media (max-width: 640px) {
  .location-map-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 4rem;
    padding-bottom: 4.5rem;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }
  .location-layer {
    display: block;
    width: 43rem;
    max-width: none;
    min-height: 0;
    margin-top: 0;
    scroll-margin-top: 6.5rem;
    padding: 0;
  }
  .location-layer .pin {
    position: absolute;
    left: var(--pin-x);
    top: var(--pin-y);
    display: block;
    width: 12px;
    height: 12px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  .location-layer .pin.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  .location-layer .pin::after {
    position: absolute;
    display: block;
    min-height: 0;
    max-width: none;
    padding: 0.35rem 0.55rem;
    white-space: nowrap;
    font-size: 0.8125rem;
    line-height: 1.3;
  }

  .story-content h2 {
    font-size: 2rem;
  }
  .exhibition-date {
    margin-bottom: 1.75rem;
  }
  .exhibition-info-group {
    margin-top: 1.4rem;
    padding-top: 0.8rem;
  }
  .exhibition-info-group p {
    line-height: 1.75;
  }
}

/* 響應式：窄手機的藝術家名單寬度 */
@media (max-width: 480px) {
  .artist-list .dot {
    width: min(100%, 8.5rem);
    justify-self: end;
  }
}

/* 無障礙：停用標記進場動畫 */
@media (prefers-reduced-motion: reduce) {
  .pin,
  .artist-pin::after {
    transition: none;
    transition-delay: 0ms;
  }
}
