/* Gói hoàn thiện Không gian Trụ sở Hội: mô tả công trình, Khu Vinh danh,
   phản hồi tương tác và chuyển động cảnh quan nhẹ. */

:root {
  --completion-gold: #efd477;
  --completion-green: #17442d;
  --completion-paper: rgba(255, 249, 224, 0.98);
}

/* Khu Vinh danh phải luôn nhìn thấy, không bị dải dưới che. */
.hotspot-honor {
  left: 50.5% !important;
  top: 71.5% !important;
  z-index: 8 !important;
}

.hotspot-honor span::before {
  content: '★ ';
  color: #fff3b2;
}

/* Phản hồi rõ hơn nhưng không làm rối cảnh quan. */
.hotspot {
  transform-origin: center bottom;
}

.hotspot span {
  position: relative;
  overflow: visible !important;
}

.hotspot:hover span,
.hotspot:focus-visible span {
  transform: translateY(-4px) scale(1.055) !important;
  filter: brightness(1.13) saturate(1.08) !important;
  box-shadow:
    0 13px 30px rgba(10, 34, 20, 0.48),
    0 0 0 5px rgba(239, 212, 119, 0.18),
    0 0 22px rgba(255, 229, 133, 0.52) !important;
}

.hotspot.is-pressed span {
  animation: building-press 420ms ease;
}

.hotspot.is-pressed::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 231, 145, 0.9);
  border-radius: 50%;
  transform: translate(-50%, 50%);
  animation: building-ripple 520ms ease-out forwards;
  pointer-events: none;
}

@keyframes building-press {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(1px) scale(0.96); }
  100% { transform: translateY(-3px) scale(1.03); }
}

@keyframes building-ripple {
  from { opacity: 0.88; transform: translate(-50%, 50%) scale(0.4); }
  to { opacity: 0; transform: translate(-50%, 50%) scale(2.25); }
}

/* Mô tả ngắn khi rê chuột hoặc dùng bàn phím. */
.building-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 13px);
  width: max-content;
  max-width: 245px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid rgba(239, 212, 119, 0.78);
  border-radius: 9px;
  color: #f9edbd;
  background: rgba(17, 54, 35, 0.96);
  box-shadow: 0 10px 28px rgba(11, 33, 20, 0.38);
  opacity: 0;
  transform: translate(-50%, -5px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
}

.building-tooltip::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -6px;
  width: 10px;
  height: 10px;
  border-left: 1px solid rgba(239, 212, 119, 0.78);
  border-top: 1px solid rgba(239, 212, 119, 0.78);
  background: rgba(17, 54, 35, 0.96);
  transform: translateX(-50%) rotate(45deg);
}

.building-tooltip b {
  font-size: 15px;
  text-align: center;
}

.building-tooltip small {
  display: block;
  font-size: 8px;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
}

.hotspot:hover .building-tooltip,
.hotspot:focus-visible .building-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Các công trình sát đáy hiển thị mô tả lên trên để không bị cắt. */
.hotspot-data .building-tooltip,
.hotspot-collective .building-tooltip,
.hotspot-honor .building-tooltip {
  top: auto;
  bottom: calc(100% + 13px);
}

.hotspot-data .building-tooltip::before,
.hotspot-collective .building-tooltip::before,
.hotspot-honor .building-tooltip::before {
  top: auto;
  bottom: -6px;
  border: 0;
  border-right: 1px solid rgba(239, 212, 119, 0.78);
  border-bottom: 1px solid rgba(239, 212, 119, 0.78);
}

/* Cửa sổ công trình đầy nội dung hơn. */
.modal-window.is-building-detail {
  width: min(920px, calc(100vw - 56px));
  max-height: min(760px, calc(100vh - 46px));
  overflow: auto;
}

.modal-building-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 5px;
}

.modal-building-summary span {
  min-height: 48px;
  display: grid;
  align-content: center;
  padding: 8px 10px;
  border: 1px solid rgba(160, 119, 37, 0.2);
  border-radius: 9px;
  background: rgba(238, 225, 177, 0.32);
}

.modal-building-summary small,
.modal-building-summary strong {
  display: block;
}

.modal-building-summary small {
  color: #786a45;
  font-size: 7px;
}

.modal-building-summary strong {
  margin-top: 2px;
  color: #244a32;
  font-size: 10px;
}

.modal-grid.enhanced-building-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.building-module-card {
  min-height: 82px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(126, 99, 38, 0.22);
  border-radius: 11px;
  color: #2c4130;
  background: rgba(255, 252, 235, 0.86);
  box-shadow: 0 7px 18px rgba(42, 56, 34, 0.09);
  text-decoration: none;
}

button.building-module-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.building-module-card:hover,
.building-module-card:focus-visible {
  border-color: rgba(196, 151, 48, 0.62);
  background: #fff8d9;
  transform: translateY(-2px);
}

.building-module-card > b:first-child {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffe9a4;
  background: linear-gradient(180deg, #377954, #17412b);
  font-size: 16px;
}

.building-module-card strong,
.building-module-card small {
  display: block;
}

.building-module-card strong {
  color: #234b31;
  font-family: 'Literata', Georgia, serif;
  font-size: 10px;
}

.building-module-card small {
  margin-top: 3px;
  color: #687064;
  font-size: 7.5px;
  line-height: 1.45;
}

.module-state {
  padding: 4px 6px;
  border-radius: 999px;
  color: #376045;
  background: #e6efcf;
  font-size: 6.5px;
  font-weight: 700;
  white-space: nowrap;
}

.module-state.pending {
  color: #7e6230;
  background: #f2e4b7;
}

/* Chuyển động cảnh quan nhỏ, ưu tiên máy cấu hình thấp. */
.headquarters-ambient-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.ambient-bird {
  position: absolute;
  left: -4%;
  color: rgba(36, 53, 35, 0.46);
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.28);
  animation: bird-cross 34s linear infinite;
}

.ambient-bird:nth-child(1) { top: 13%; animation-delay: -4s; }
.ambient-bird:nth-child(2) { top: 20%; animation-delay: -18s; animation-duration: 43s; font-size: 8px; }
.ambient-bird:nth-child(3) { top: 9%; animation-delay: -28s; animation-duration: 51s; }

@keyframes bird-cross {
  0% { transform: translateX(0) translateY(0) scale(0.8); opacity: 0; }
  8% { opacity: 0.42; }
  48% { transform: translateX(52vw) translateY(-15px) scale(1); }
  92% { opacity: 0.38; }
  100% { transform: translateX(108vw) translateY(10px) scale(0.86); opacity: 0; }
}

.ambient-light {
  position: absolute;
  left: 43%;
  top: 35%;
  width: 26%;
  height: 36%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 238, 156, 0.14), transparent 70%);
  animation: warm-light 9s ease-in-out infinite alternate;
}

@keyframes warm-light {
  from { opacity: 0.32; transform: scale(0.94); }
  to { opacity: 0.62; transform: scale(1.08); }
}

.ambient-water-glint {
  position: absolute;
  left: 0;
  top: 46%;
  width: 12%;
  height: 43%;
  opacity: 0.3;
  background: repeating-linear-gradient(165deg, transparent 0 15px, rgba(255, 248, 191, 0.22) 16px 18px, transparent 19px 33px);
  animation: water-glint 12s linear infinite;
}

@keyframes water-glint {
  from { background-position: 0 0; }
  to { background-position: 0 70px; }
}

html[data-ambient-motion='off'] .headquarters-ambient-layer,
html[data-ambient-motion='off'] .ambient-cloud,
html[data-ambient-motion='off'] .boat,
html[data-ambient-motion='off'] .water-shimmer {
  display: none !important;
}

html[data-ambient-motion='low'] .ambient-bird:nth-child(n+2),
html[data-ambient-motion='low'] .ambient-water-glint {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .headquarters-ambient-layer,
  .hotspot.is-pressed::before {
    display: none !important;
  }

  .hotspot span,
  .building-tooltip,
  .building-module-card {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-height: 760px) {
  .hotspot-honor { top: 67.5% !important; }
  .building-tooltip { display: none; }
  .modal-building-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
