/* ============================================================
   달려라 달려 로보트야 — GPS Art Running
   Design system
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');

:root {
  --coral: #FF5A3C;
  --coral-dark: #E63E22;
  --teal: #14B8A6;
  --teal-dark: #0E8C7E;
  --sun: #FFC23C;
  --ink: #16161D;
  --ink-soft: #3C3C46;
  --muted: #8A8A96;
  --line: #ECE7DF;
  --paper: #FBF8F3;
  --paper-2: #FFFFFF;
  --shadow: 0 10px 30px -12px rgba(22, 22, 29, 0.25);
  --shadow-sm: 0 4px 14px -8px rgba(22, 22, 29, 0.3);
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 1180px;
  --header-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: 72px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--coral); margin-bottom: 8px;
}
h1, h2, h3 { line-height: 1.18; letter-spacing: -0.02em; font-weight: 800; }
h2.title { font-size: clamp(26px, 3.4vw, 38px); }
.sub { color: var(--ink-soft); font-size: 16px; max-width: 56ch; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  height: var(--header-h);
  background: rgba(251, 248, 243, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { height: 100%; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--coral), var(--sun));
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 15px; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(22,22,29,.05); color: var(--ink); }
.nav a.active { color: var(--ink); background: rgba(255,90,60,.12); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 15px;
  transition: transform .12s ease, box-shadow .12s ease, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 8px 20px -8px rgba(255,90,60,.7); }
.btn-primary:hover { background: var(--coral-dark); }
.btn-ghost { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 64px 0 80px; }
.hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(900px 420px at 88% -8%, rgba(255,194,60,.28), transparent 60%),
    radial-gradient(700px 520px at -5% 110%, rgba(20,184,166,.20), transparent 55%);
  z-index: 0;
}
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(34px, 5.2vw, 60px); letter-spacing: -0.035em; }
.hero h1 .hl { color: var(--coral); }
.hero p.lead { font-size: 18px; color: var(--ink-soft); margin: 20px 0 30px; max-width: 46ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 28px; margin-top: 36px; }
.hero-stats .stat .n { font-size: 26px; font-weight: 800; }
.hero-stats .stat .l { font-size: 13px; color: var(--muted); font-weight: 600; }

.hero-art {
  aspect-ratio: 1/1; border-radius: 28px; background: var(--paper-2);
  border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden;
  background-image:
    linear-gradient(rgba(236,231,223,.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236,231,223,.7) 1px, transparent 1px);
  background-size: 34px 34px;
}
.hero-art .pin { position: absolute; font-size: 22px; }
.hero-art svg { position: absolute; inset: 8%; width: 84%; height: 84%; }
.hero-art .route-path { fill: none; stroke: var(--coral); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 3.2s ease forwards .3s; }
.hero-art .ghost-path { fill: none; stroke: var(--teal); stroke-width: 2.5; stroke-dasharray: 6 8; opacity: .6; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Cards / grids ---------- */
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.shape-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.shape-card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: transform .14s, box-shadow .14s, border-color .14s;
  display: flex; flex-direction: column; gap: 12px;
}
.shape-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--coral); }
.shape-card .thumb {
  aspect-ratio: 1/1; border-radius: var(--radius-sm); background: var(--paper);
  display: grid; place-items: center; position: relative;
}
.shape-card .thumb svg { width: 70%; height: 70%; }
.shape-card .thumb svg path, .shape-card .thumb svg polygon { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.shape-card .meta { display: flex; align-items: center; justify-content: space-between; }
.shape-card .name { font-weight: 700; font-size: 16px; }
.shape-card .cat { font-size: 12px; color: var(--muted); font-weight: 600; }
.shape-card.collected .thumb::after {
  content: '✓'; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px;
  background: var(--teal); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-diff-easy { background: rgba(20,184,166,.14); color: var(--teal-dark); }
.badge-diff-normal { background: rgba(255,194,60,.18); color: #B07A00; }
.badge-diff-hard { background: rgba(255,90,60,.14); color: var(--coral-dark); }

/* ---------- Category filter ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2);
  font-weight: 600; font-size: 14px; color: var(--ink-soft); transition: all .14s;
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Feature row ---------- */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature { padding: 26px; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line); }
.feature .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.feature h3 { font-size: 19px; margin-bottom: 8px; }
.feature p { color: var(--ink-soft); font-size: 15px; }

/* ---------- Progress ---------- */
.progress-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.progress-card { padding: 22px; }
.progress-card h3 { font-size: 16px; margin-bottom: 4px; }
.progress-card .frac { font-size: 30px; font-weight: 800; }
.progress-card .frac span { font-size: 16px; color: var(--muted); font-weight: 600; }
.bar { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--coral), var(--sun)); }

/* ============================================================
   Editor
   ============================================================ */
.editor-layout {
  display: grid; grid-template-columns: 1fr 360px;
  height: calc(100vh - var(--header-h));
}
#map { width: 100%; height: 100%; background: #e8e6e1; }
.editor-panel {
  border-left: 1px solid var(--line); background: var(--paper-2);
  display: flex; flex-direction: column; overflow-y: auto;
}
.panel-sec { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 14px; }

.shape-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape-pick {
  aspect-ratio: 1/1; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper);
  display: grid; place-items: center; transition: all .12s;
}
.shape-pick svg { width: 64%; height: 64%; }
.shape-pick svg path, .shape-pick svg polygon { fill: none; stroke: var(--ink-soft); stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; }
.shape-pick:hover { border-color: var(--coral); }
.shape-pick.active { border-color: var(--coral); background: rgba(255,90,60,.08); }
.shape-pick.active svg path, .shape-pick.active svg polygon { stroke: var(--coral); }

.ctrl { margin-bottom: 16px; }
.ctrl:last-child { margin-bottom: 0; }
.ctrl label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ctrl label .val { color: var(--coral); font-variant-numeric: tabular-nums; }
.ctrl input[type=range] { width: 100%; accent-color: var(--coral); }
.dist-row { display: flex; align-items: center; gap: 8px; }
.dist-row input[type=number] { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; font-family: inherit; outline: none; color: var(--ink); }
.dist-row input[type=number]:focus { border-color: var(--coral); }
.dist-row .unit { font-size: 13px; color: var(--muted); font-weight: 600; }
.dist-hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* 조건 만족 경로 후보 목록 */
.cand-list { display: flex; flex-direction: column; gap: 8px; }
.cand-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2);
  cursor: pointer; transition: border-color .12s, background .12s; }
.cand-item:hover { border-color: #6366F1; }
.cand-item.active { border-color: var(--coral); background: rgba(255,90,60,.06); }
.cand-rank { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: #6366F1;
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.cand-item.active .cand-rank { background: var(--coral); }
.cand-main { flex: 1; }
.cand-score { font-weight: 700; font-size: 15px; }
.cand-sub { font-size: 12px; color: var(--muted); }
.cand-empty { font-size: 13px; color: var(--muted); }
.cand-badge { width: 26px; height: 26px; border-radius: 50%; background: #6366F1; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer; transform: translate(-50%, -50%); }
.cand-badge.sel { background: var(--coral); }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--paper); border-radius: var(--radius-sm); padding: 12px 14px; }
.metric .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric .v small { font-size: 13px; color: var(--muted); font-weight: 600; }

.score-ring { display: flex; align-items: center; gap: 14px; }
.score-ring .ring { width: 64px; height: 64px; flex: 0 0 auto; }
.score-ring .ring circle { fill: none; stroke-width: 8; }
.score-ring .ring .bg { stroke: var(--line); }
.score-ring .ring .fg { stroke: var(--teal); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s ease; }
.score-ring .txt .big { font-size: 24px; font-weight: 800; }
.score-ring .txt .lbl { font-size: 12px; color: var(--muted); }

.hint { font-size: 13px; color: var(--ink-soft); background: rgba(255,194,60,.14); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.hint.warn { background: rgba(255,90,60,.12); color: var(--coral-dark); }
.actions { display: flex; flex-direction: column; gap: 10px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s; z-index: 3000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.map-loader {
  position: absolute; inset: 0; background: rgba(251,248,243,.78); backdrop-filter: blur(2px);
  display: none; z-index: 800;
}
.map-loader.show { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.map-loader .ldr-text { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* 지역 검색 (지도 위 오버레이) */
.map-search { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 900; width: min(400px, 74%); }
.map-search .sbox { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.map-search .sbox:focus-within { border-color: var(--coral); }
.map-search input { flex: 1; padding: 12px 0; border: none; background: none; font-size: 14px; font-family: inherit; outline: none; color: var(--ink); }
.map-search .sbtn { padding: 7px 14px; border-radius: 999px; background: var(--coral); color: #fff; font-weight: 700; font-size: 13px; margin: 5px 0; }
.search-results { margin-top: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; display: none; max-height: 280px; overflow-y: auto; }
.search-results.show { display: block; }
.search-results button { display: block; width: 100%; text-align: left; padding: 11px 15px; font-size: 14px;
  border: none; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.search-results button:last-child { border-bottom: none; }
.search-results button:hover { background: var(--paper); }
.search-results .sr-name { font-weight: 600; }
.search-results .sr-sub { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-empty { padding: 12px 15px; font-size: 13px; color: var(--muted); }
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* leaflet tweaks */
.leaflet-container { font-family: inherit; }
.editor-map-wrap { position: relative; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 40px 0; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: var(--ink-soft); }

/* ---------- 공유 카드 모달 ---------- */
.card-modal { position: fixed; inset: 0; background: rgba(22,22,29,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 4000; padding: 20px; }
.card-modal-inner { background: var(--paper-2); border-radius: 20px; padding: 16px;
  max-width: min(430px, 92vw); box-shadow: var(--shadow); animation: cardpop .18s ease; }
.card-modal-inner img { width: 100%; border-radius: 12px; display: block; }
.card-modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.card-modal-actions .btn { flex: 1; }
@keyframes cardpop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty .big { font-size: 48px; margin-bottom: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-art { max-width: 420px; }
  .features { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 56vh; }
  .editor-panel { border-left: none; border-top: 1px solid var(--line); }
  .nav { gap: 0; }
  .nav a { padding: 8px 10px; font-size: 14px; }
  .brand span.full { display: none; }
}
