/* map.css - Bản đồ Cửu Tinh (#/ban-do). Zone marketing.
   9 đại ấn quanh 1 ấn gốc; thắp sáng theo tiến độ đọc; vòng tương sinh Ngũ Hành.
   Glow TĨNH (box-shadow/pseudo cố định) - KHÔNG blur/filter động. Chỉ tương sinh có animation dasharray. */

.map-lead {
  max-width: 56ch;
  color: var(--ink-ash);
  font-family: var(--font-body);
  line-height: 1.7;
  margin: 0.6rem 0 0;
}
.map-lead em {
  color: var(--gold);
  font-style: normal;
}

/* ---- Sân khấu bản đồ: vuông, responsive, max ~560px ---- */
.map-stage {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 2.2rem auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-gold);
  background:
    radial-gradient(circle at 50% 50%, rgba(192, 57, 43, 0.05), transparent 36%),
    radial-gradient(circle at 50% 50%, rgba(194, 161, 77, 0.07), transparent 60%),
    radial-gradient(circle at 50% 118%, rgba(42, 31, 61, 0.22), transparent 60%),
    #100c0b;
  box-shadow: inset 0 0 90px -24px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}
/* Vòng dẫn đồng tâm (đi qua các ấn) + vòng tâm */
.map-stage::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 74%; height: 74%;
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 1px solid rgba(194, 161, 77, 0.09); pointer-events: none;
}
.map-stage::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%;
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 1px dashed rgba(194, 161, 77, 0.07); pointer-events: none;
}

/* ---- Vòng tương sinh (overlay phía sau các ấn) ---- */
.map-sinh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.sinh-seg {
  animation: ca-flow 9s linear infinite;
}
@keyframes ca-flow {
  to { stroke-dashoffset: -160; }
}

/* ---- Ấn gốc ở tâm ---- */
.map-core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  line-height: 0;
}
.map-core .emblem {
  display: block;
}
.map-core::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130%;
  height: 130%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line-gold), 0 0 22px rgba(224, 192, 99, 0.28);
  pointer-events: none;
}

/* ---- 9 đại ấn ---- */
.map-an {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* hitbox >=44px THỰC */
  min-width: 56px;
  min-height: 56px;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid transparent;
  text-decoration: none;
  line-height: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.map-an .emblem {
  display: block;
  width: 64px;
  height: 64px;
  max-width: 100%;
}

/* Đã đọc: thắp sáng - viền LIỀN + glow tĩnh theo hành */
.map-an.is-read {
  opacity: 1;
  border-style: solid;
  border-color: var(--an-el, var(--gold));
}
.map-an.is-read::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  /* glow TĨNH */
  box-shadow: 0 0 16px -2px var(--an-el, var(--gold));
  opacity: 0.55;
  pointer-events: none;
  z-index: -1;
}

/* Chưa đọc: mờ - viền ĐỨT (marker phi-màu) */
.map-an.is-dim {
  opacity: 0.35;
  filter: grayscale(0.4);
  border-style: dashed;
  border-color: var(--ink-faint);
}

.map-an:hover,
.map-an:focus-visible {
  opacity: 1;
  filter: none;
  transform: translate(-50%, -50%) scale(1.06);
}

/* ---- Legend Ngũ Hành ---- */
.map-legend {
  max-width: var(--maxw);
  margin: 0 auto;
}
.map-legend-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-ash);
  margin: 0 0 0.75rem;
}
.map-legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 24px;
}
@media (min-width: 620px) { .map-legend-list { grid-template-columns: 1fr 1fr; } }
.map-legend-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-ui);
}
.map-legend-el { font-weight: 600; color: var(--ink-bone); font-size: 0.92rem; }
.map-legend-names { color: var(--ink-ash); font-size: 0.82rem; }
.map-legend-swatch { align-self: center; }
.map-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--sw);
  border: 1px solid var(--line);
  display: inline-block;
}
.map-legend-note {
  margin: 0.9rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ---- Glow ngũ hành theo [data-el] (đặt biến --an-el dự phòng nếu inline style thiếu) ---- */
.map-an[data-el="moc"]  { --an-el: var(--el-moc); }
.map-an[data-el="hoa"]  { --an-el: var(--el-hoa); }
.map-an[data-el="tho"]  { --an-el: var(--el-tho); }
.map-an[data-el="kim"]  { --an-el: var(--el-kim); }
.map-an[data-el="thuy"] { --an-el: var(--el-thuy); }

/* ---- Reduced motion: tương sinh đứng yên ---- */
@media (prefers-reduced-motion: reduce) {
  .sinh-seg { animation: none; }
  .map-an { transition: none; }
}

/* Mobile / dữ liệu tiết kiệm: tắt vòng tương sinh chạy mãi (perf pin/GPU) */
@media (hover: none), (pointer: coarse), (prefers-reduced-data: reduce) {
  .sinh-seg { animation: none; }
}

/* ---- Màn nhỏ: thu nhỏ ấn để 9 ấn không chồng nhau ---- */
@media (max-width: 480px) {
  .map-an .emblem { width: 48px; height: 48px; }
  .map-core .emblem { width: 60px; height: 60px; }
}
