/* ============================================================
 * 홈 첫 화면 그림 영역 (#hero-visual) — 설계서 7-1장 "전국 네트워크" 움직이는 지도
 * 이 블록은 통째로 바꿔 끼울 수 있게 스타일·스크립트를 따로 둔다.
 *   마크업: index.html 의 <div class="hero-visual" id="hero-visual">
 *   스크립트: assets/hero-visual.js (지도 SVG 를 그린다)
 * 기본 스타일 = 완성된 정지 화면. 움직임은 prefers-reduced-motion: no-preference 에서만 붙인다.
 * ============================================================ */
.hero-visual {
  --cycle: 9.6s; /* hero-visual.js 의 CYCLE 과 같아야 한다 */
  --mx: 0; --my: 0; /* 마우스 위치 -1 ~ 1 (hero-visual.js 가 바꾼다) */
  position: relative; width: 100%; max-width: 580px; margin-left: auto;
  aspect-ratio: 496 / 540;
}

/* 뒤 바탕: 종이 위 따뜻한 빛 */
.hero-visual .hv-glow { position: absolute; inset: -6% -8%; z-index: 0; pointer-events: none; }
.hero-visual .hv-glow::before,
.hero-visual .hv-glow::after { content: ""; position: absolute; border-radius: 50%; }
.hero-visual .hv-glow::before {
  left: 8%; top: 4%; width: 84%; height: 92%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(255, 255, 255, .45) 55%, transparent);
}
.hero-visual .hv-glow::after {
  left: 30%; top: 22%; width: 40%; height: 36%;
  background: radial-gradient(closest-side, rgba(251, 233, 222, .9), rgba(251, 233, 222, 0));
}

.hero-visual .hv-map { position: absolute; inset: 0; z-index: 1; }
.hero-visual .hv-svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* 지도 */
.hv-prov { fill: #e3efec; stroke: #fff; stroke-width: 1.1; stroke-linejoin: round; }
.hv-prov.is-cb { fill: #dcebe6; }
.hv-inset { fill: none; stroke: #b9cbc6; stroke-width: 1; stroke-dasharray: 3 3; }
.hv-isle { fill: #e3efec; stroke: #9fb8b2; stroke-width: 1; }
.hv-cb { fill: #fbe1cf; fill-opacity: .92; stroke: #e2703a; stroke-width: 1.4; stroke-linejoin: round; }

/* 충북: 실선 · 진한 점 */
.hv-cb-line { fill: none; stroke: #0f4c45; stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.hv-cb-dot { fill: #0f4c45; stroke: #fff; stroke-width: 2.4; }

/* 전국: 점선 · 옅은 점 */
.hv-nat-line { fill: none; stroke: #1d6b61; stroke-opacity: .55; stroke-width: 1.7; stroke-linecap: round; stroke-dasharray: 1.5 5; }
.hv-reveal { fill: none; stroke: #fff; stroke-width: 6; stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.hv-nat-dot { fill: #fff; stroke: #1d6b61; stroke-opacity: .6; stroke-width: 1.8; }

/* 청주 */
.hv-cj-dot { fill: #e2703a; stroke: #fff; stroke-width: 2.6; }
.hv-cj-core { fill: #fff; }
.hv-ripple { fill: none; stroke: #e2703a; stroke-width: 1.6; opacity: 0; }

.hv-label {
  font-family: var(--font); font-weight: 800; font-size: 15px; letter-spacing: -.02em;
  fill: #0f4c45; paint-order: stroke; stroke: #faf6ec; stroke-width: 5px; stroke-linejoin: round;
}
.hv-label.is-cj { text-anchor: end; fill: #a84e1d; }
.hv-label.is-cb { font-size: 14px; }

.hv-cb-dot, .hv-nat-dot, .hv-cj-dot, .hv-ripple { transform-box: fill-box; transform-origin: center; }

/* 둘레에 떠 있는 조각 그림 (없어도 자리만 남는다) */
.hero-visual .hv-piece { position: absolute; z-index: 2; width: clamp(72px, 20%, 118px); aspect-ratio: 1; pointer-events: none; }
.hero-visual .hv-piece .art { width: 100%; height: 100%; }
.hero-visual .hv-piece .art::before { inset: 14%; }
.hero-visual .hv-piece.is-1 { left: -4%; top: 2%; }
.hero-visual .hv-piece.is-2 { left: -2%; bottom: 12%; }
.hero-visual .hv-piece.is-3 { right: 0; top: 42%; }

/* 손글씨 곁말 */
.hero-visual .hv-note { position: absolute; right: 2%; bottom: 2%; z-index: 3; text-align: right; }
.hero-visual .hv-note .hand { font-size: 18px; transform: rotate(-4deg); }

/* ---------- 움직임 (9.6초 한 주기) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero-visual .a-cj      { animation: hvCj var(--cycle) var(--ease) infinite both; }
  .hero-visual .a-ripple  { animation: hvRipple 2.4s cubic-bezier(.2, .6, .3, 1) infinite; }
  .hero-visual .a-labcj   { animation: hvLabCj var(--cycle) ease infinite both; }
  .hero-visual .a-cbline  { animation: hvCbLine var(--cycle) cubic-bezier(.45, 0, .2, 1) infinite both; animation-delay: calc(var(--i) * .35s); }
  .hero-visual .a-cbdot   { animation: hvCbDot var(--cycle) var(--ease) infinite both; animation-delay: calc(var(--i) * .35s); }
  .hero-visual .a-cb      { animation: hvCb var(--cycle) ease infinite both; }
  .hero-visual .a-labcb   { animation: hvLabCb var(--cycle) ease infinite both; }
  .hero-visual .a-nat     { animation: hvNat var(--cycle) cubic-bezier(.45, 0, .2, 1) infinite both; animation-delay: calc(var(--i) * .1s); }
  .hero-visual .a-natdot  { animation: hvNatDot var(--cycle) var(--ease) infinite both; animation-delay: calc(var(--i) * .1s); }
  .hero-visual .hv-piece  { animation: hvFloat 6s ease-in-out infinite; }
  .hero-visual .hv-piece.is-2 { animation-delay: -2s; animation-duration: 7s; }
  .hero-visual .hv-piece.is-3 { animation-delay: -4s; animation-duration: 6.5s; }
  .hero-visual.is-paused *, .hero-visual.is-paused { animation-play-state: paused !important; }
  html.motion .hero-visual .hv-map { animation: hvIn .9s var(--ease) both .1s; }
}

/* ① 청주 */
@keyframes hvCj {
  0% { transform: scale(0); opacity: 0; }
  5% { transform: scale(1.25); opacity: 1; }
  9%, 92% { transform: scale(1); opacity: 1; }
  98%, 100% { transform: scale(.4); opacity: 0; }
}
@keyframes hvRipple {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(3.4); opacity: 0; }
}
@keyframes hvLabCj {
  0%, 4% { opacity: 0; }
  10%, 92% { opacity: 1; }
  98%, 100% { opacity: 0; }
}
/* ② 충북 */
@keyframes hvCbLine {
  0%, 12% { stroke-dashoffset: 1; opacity: 1; }
  24%, 90% { stroke-dashoffset: 0; opacity: 1; }
  97% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 1; opacity: 0; }
}
@keyframes hvCbDot {
  0%, 22% { transform: scale(0); opacity: 0; }
  26% { transform: scale(1.3); opacity: 1; }
  29%, 90% { transform: scale(1); opacity: 1; }
  97%, 100% { transform: scale(.5); opacity: 0; }
}
@keyframes hvCb {
  0%, 16% { opacity: 0; }
  32%, 88% { opacity: 1; }
  96%, 100% { opacity: 0; }
}
@keyframes hvLabCb {
  0%, 26% { opacity: 0; }
  33%, 90% { opacity: 1; }
  96%, 100% { opacity: 0; }
}
/* ③ 전국 */
@keyframes hvNat {
  0%, 34% { stroke-dashoffset: 1; opacity: 1; }
  46%, 84% { stroke-dashoffset: 0; opacity: 1; }
  91% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 1; opacity: 0; }
}
@keyframes hvNatDot {
  0%, 44% { transform: scale(0); opacity: 0; }
  48% { transform: scale(1.35); opacity: 1; }
  51%, 84% { transform: scale(1); opacity: 1; }
  91%, 100% { transform: scale(.4); opacity: 0; }
}
@keyframes hvFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes hvIn { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* 마우스 시차: 지도는 천천히, 조각 그림은 더 크게 (translate 속성이라 다른 transform 애니메이션과 겹치지 않음) */
.hero-visual .hv-map { translate: calc(var(--mx) * 8px) calc(var(--my) * 8px); transition: translate .7s cubic-bezier(.22, .8, .24, 1); }
.hero-visual .hv-piece { transition: translate .7s cubic-bezier(.22, .8, .24, 1); }
.hero-visual .hv-piece.is-1 { translate: calc(var(--mx) * -22px) calc(var(--my) * -18px); }
.hero-visual .hv-piece.is-2 { translate: calc(var(--mx) * -30px) calc(var(--my) * -24px); }
.hero-visual .hv-piece.is-3 { translate: calc(var(--mx) * -16px) calc(var(--my) * -14px); }

/* 지도를 못 불러온 경우·JS 가 꺼진 경우: 곁말·조각 그림을 숨기고 사람들 그림으로 대신 */
.hero-visual.is-failed .hv-piece, .hero-visual.is-failed .hv-note,
html:not(.js) .hero-visual .hv-piece, html:not(.js) .hero-visual .hv-note { display: none; }
.hero-visual .hv-fallback { width: 100%; height: 100%; }
.hero-visual .hv-fallback img { transform: scale(1.15); }

@media (max-width: 980px) {
  .hero-visual { max-width: 460px; margin: 8px auto 0; }
}
@media (max-width: 760px) {
  .hero-visual { max-width: 340px; }
  .hero-visual .hv-note .hand { font-size: 15px; }
  .hero-visual .hv-piece { width: 68px; }
  .hv-label { font-size: 17px; }
}
