/* ============================================================================
   spideyPizza · 레이아웃
   ----------------------------------------------------------------------------
   여기는 '배치'만 다룹니다. 색·글꼴·모서리·그림자는 전부 theme.css 의 변수를
   가져다 쓰므로, 디자인만 바꾸고 싶으면 theme.css 를 고치세요.
   ========================================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: var(--font-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
}

/* 코믹 망점 무늬 — 공용 유틸 */
.halftone::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.9) 1px, transparent 1.1px);
  background-size: var(--halftone-size) var(--halftone-size);
  opacity: var(--halftone-opacity);
}

/* ------------------------------------------------------------ 상단 바 */
.bar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 1000;
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: var(--c-surface);
  border-bottom: var(--border-w) solid var(--border-c);
  box-shadow: 0 3px 0 rgba(0,0,0,.5);
  overflow: hidden;
}

/* 헤더 우상단 거미줄 무늬 — 진하기는 theme.css 의 --web-opacity (0이면 꺼짐) */
.web-deco {
  position: absolute; top: 0; right: 0; width: 260px; height: 100%;
  pointer-events: none; opacity: var(--web-opacity);
  background:
    /* 동심원 줄 */
    radial-gradient(circle at 100% 0, transparent 44px, var(--c-line) 44px, var(--c-line) 45px, transparent 45px),
    radial-gradient(circle at 100% 0, transparent 88px, var(--c-line) 88px, var(--c-line) 89px, transparent 89px),
    radial-gradient(circle at 100% 0, transparent 132px, var(--c-line) 132px, var(--c-line) 133px, transparent 133px),
    radial-gradient(circle at 100% 0, transparent 176px, var(--c-line) 176px, var(--c-line) 177px, transparent 177px),
    /* 방사형 줄 */
    conic-gradient(from 180deg at 100% 0,
      transparent 0deg, transparent 14deg, var(--c-line) 14deg, var(--c-line) 14.4deg,
      transparent 14.4deg, transparent 31deg, var(--c-line) 31deg, var(--c-line) 31.4deg,
      transparent 31.4deg, transparent 48deg, var(--c-line) 48deg, var(--c-line) 48.4deg,
      transparent 48.4deg, transparent 65deg, var(--c-line) 65deg, var(--c-line) 65.4deg,
      transparent 65.4deg, transparent 90deg);
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(to left, #000 55%, transparent 100%);
          mask-image: linear-gradient(to left, #000 55%, transparent 100%);
}

.brand { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.brand-mark { filter: drop-shadow(1px 1px 0 rgba(0,0,0,.6)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  font-size: 19px;
  letter-spacing: var(--head-tracking);
  text-transform: var(--head-upper);
  transform: skewX(var(--head-skew));
  transform-origin: left center;
  color: var(--c-text);
  white-space: nowrap;
}
.brand-sub { font-size: 11px; color: var(--c-text-dim); letter-spacing: .02em; white-space: nowrap; }

.controls { display: flex; gap: 8px; flex: 1; min-width: 0; position: relative; z-index: 1; }
.controls input, .controls select {
  height: 36px;
  background: var(--c-surface-2);
  color: var(--c-text);
  border: var(--border-w) solid var(--border-c);
  border-radius: var(--radius);
  padding: 0 10px; font-size: 13px; font-family: inherit;
}
.controls input { flex: 1; min-width: 90px; max-width: 280px; }
.controls input::placeholder { color: var(--c-text-dim); }
.controls input:focus, .controls select:focus {
  outline: none; border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(225,29,46,.25);
}

.status { text-align: right; position: relative; z-index: 1; }
#count { display: block; font-size: 12.5px; color: var(--c-text-dim); white-space: nowrap; }
#count b { color: var(--c-cheese); font-weight: 800; font-size: 14px; }
.sync { display: block; font-size: 10.5px; color: var(--c-text-dim); opacity: .65; white-space: nowrap; }

/* ------------------------------------------------------------ 지도 */
#map { position: fixed; inset: var(--bar-h) 0 0 0; background: var(--c-bg); }
.leaflet-container { font-family: var(--font-body); background: var(--c-bg); }

/* 타일 색 보정 (theme.css 의 --tile-filter-* 값) */
.leaflet-tile-pane .tiles-osm    { filter: var(--tile-filter-osm); }
.leaflet-tile-pane .tiles-vworld { filter: var(--tile-filter-vworld); }

.leaflet-control-zoom a {
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  border: var(--border-w) solid var(--border-c) !important;
}
.leaflet-control-attribution {
  background: rgba(10,13,20,.75) !important;
  color: var(--c-text-dim) !important;
}
.leaflet-control-attribution a { color: var(--c-text-dim) !important; }

/* 클러스터(묶음) 원 */
.cl {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--cluster-bg);
  color: var(--cluster-text);
  font-weight: 900; letter-spacing: -.02em;
  border: var(--border-w) solid var(--border-c);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  transition: transform .12s ease;
}
.cl:hover { transform: scale(1.09); }
.cl.mid { background: var(--cluster-bg-mid); }
.cl.big { background: var(--cluster-bg-big); }
.cl > span { position: relative; z-index: 1; }

/* 내 위치 */
.me {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--me-color); border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,.7), 0 0 14px var(--me-color);
  animation: mePulse 1.8s ease-out infinite;
}
@keyframes mePulse {
  0%   { box-shadow: 0 0 0 2px rgba(0,0,0,.7), 0 0 0 0 rgba(53,196,240,.55); }
  70%  { box-shadow: 0 0 0 2px rgba(0,0,0,.7), 0 0 0 18px rgba(53,196,240,0); }
  100% { box-shadow: 0 0 0 2px rgba(0,0,0,.7), 0 0 0 0 rgba(53,196,240,0); }
}

/* 팝업 */
.leaflet-popup-content-wrapper {
  background: var(--c-surface);
  color: var(--c-text);
  border: var(--border-w) solid var(--border-c);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
}
.leaflet-popup-tip { background: var(--c-surface); border: var(--border-w) solid var(--border-c); }
.leaflet-popup-close-button { color: var(--c-text-dim) !important; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.55; }
.pop h3 {
  margin: 2px 0 4px; font-size: 15px; font-weight: 800;
  letter-spacing: var(--head-tracking);
}
.pop-brand {
  display: inline-block; font-size: 10.5px; font-weight: 800; color: #fff;
  background: var(--c-blue); border: 1.5px solid var(--border-c);
  border-radius: 4px; padding: 1.5px 7px;
  text-transform: var(--head-upper);
}
.pop-addr { color: var(--c-text-dim); }
.pop-serve {
  margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--c-cheese);
}
.pop-links { margin-top: 9px; display: flex; gap: 8px; }
.pop-links a {
  font-size: 11.5px; font-weight: 700; text-decoration: none;
  color: var(--c-text); background: var(--c-surface-2);
  border: 1.5px solid var(--border-c); border-radius: 6px; padding: 4px 9px;
}
.pop-links a:hover { background: var(--c-red); color: #fff; }

/* ------------------------------------------------------------ 내 위치 버튼 */
.fab {
  position: fixed; right: 18px; bottom: 26px; z-index: 1000;
  display: flex; align-items: center; gap: 7px;
  height: 46px; padding: 0 18px 0 14px;
  background: var(--c-red); color: #fff;
  border: var(--border-w) solid var(--border-c);
  border-radius: 999px;
  font-size: 13.5px; font-weight: 800; font-family: var(--font-head);
  letter-spacing: var(--head-tracking);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
}
.fab:hover { background: var(--c-red-dark); }
.fab:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0,0,0,.85); }
.fab.on { background: var(--c-blue); }

/* ------------------------------------------------------------ 주변 목록 */
.panel {
  position: fixed; right: 18px; bottom: 84px; z-index: 1000;
  width: 330px; max-height: 46vh; display: flex; flex-direction: column;
  background: var(--c-surface);
  border: var(--border-w) solid var(--border-c);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard), var(--shadow-soft);
  overflow: hidden;
}
.panel[hidden] { display: none; }   /* [hidden] 이 display:flex 에 밀리는 것 방지 */
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-size: 13px; font-weight: 800;
  text-transform: var(--head-upper); letter-spacing: var(--head-tracking);
  background: var(--c-red); color: #fff;
  border-bottom: var(--border-w) solid var(--border-c);
}
.panel-head button {
  border: 0; background: none; font-size: 15px; color: #fff; cursor: pointer;
  padding: 2px 4px; opacity: .85;
}
.panel ul { margin: 0; padding: 0; list-style: none; overflow-y: auto; }
.panel li {
  padding: 10px 14px; border-bottom: 1px solid var(--c-line);
  cursor: pointer; font-size: 13px;
}
.panel li:last-child { border-bottom: 0; }
.panel li:hover { background: var(--c-surface-2); }
.panel .nm { font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.panel .dist { color: var(--c-cheese); font-size: 12px; font-weight: 800; white-space: nowrap; }
.panel .ad { color: var(--c-text-dim); font-size: 12px; margin-top: 2px; }
.panel .empty { padding: 18px 14px; color: var(--c-text-dim); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------ 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 1200;
  background: var(--c-surface); color: var(--c-text);
  border: var(--border-w) solid var(--border-c); border-radius: 999px;
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-hard);
}

/* ------------------------------------------------------------ 모바일 */
@media (max-width: 700px) {
  :root { --bar-h: 104px; }
  .bar { flex-wrap: wrap; align-content: center; padding: 8px 12px; gap: 8px; }
  .brand { width: 100%; }
  .controls { width: 100%; flex-wrap: wrap; }
  .controls input { max-width: none; flex: 1 1 100%; }
  .controls select { flex: 1 1 0; min-width: 0; }
  .status { position: absolute; right: 12px; top: 10px; }
  .sync { display: none; }
  .panel { left: 12px; right: 12px; width: auto; bottom: 82px; max-height: 40vh; }
  .fab span { display: none; }
  .fab { padding: 0; width: 46px; justify-content: center; }
}
