/* =========================
   RESET
========================= */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #fff;
  font-family: Arial, sans-serif;
  cursor: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: none !important;
}

/* =========================
   VIEWPORT
========================= */

#map-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: none !important;
}

#map {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate3d(0, 0, 0);
  transform-origin: top left;
}

/* =========================
   MAP IMAGE
========================= */

#map-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 0;
}

/* =========================
   HOTSPOT LAYER
========================= */

#hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: none !important;
}

body:not(.editing) .hotspot {
  background: transparent;
  outline: none;
}

.hotspot-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 3px 5px;
  color: #fff;
  background: var(--hotspot-color, #ff4d6d);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}

body:not(.editing) .hotspot-label {
  display: none;
}

/* =========================
   EDITOR HOTSPOTS
========================= */

body.editing,
body.editing button,
body.editing input,
body.editing textarea {
  cursor: auto !important;
}

body.editing #hotspot-layer {
  pointer-events: auto;
}

body.editing .hotspot {
  background: color-mix(
    in srgb,
    var(--hotspot-color, #ff4d6d) 35%,
    transparent
  );
  outline: 1px solid var(--hotspot-color, #ff4d6d);
  cursor: crosshair !important;
}

body.editing .hotspot.selected {
  outline: 3px solid var(--hotspot-color, #ff4d6d);
  background: color-mix(
    in srgb,
    var(--hotspot-color, #ff4d6d) 50%,
    transparent
  );
}

body.editing .hotspot-label {
  display: block;
}

body.editing #map-viewport {
  cursor: grab !important;
}

body.editing #map-viewport:active {
  cursor: grabbing !important;
}

body.editing.drawing #map-viewport {
  cursor: crosshair !important;
}

body.editing .hotspot.selected::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid var(--hotspot-color, #ff4d6d);
  cursor: nwse-resize !important;
}

/* =========================
   BEAN CURSOR
========================= */

#bean-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 100000;
  pointer-events: none;
}

/*
  중요:
  콩의 위치는 JS에서만 제어.
  CSS 회전 애니메이션은 사용하지 않음.
*/

#bean-cursor .bean {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 60px;
  height: 60px;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
  animation: none !important;
  rotate: none !important;
}

#bean-cursor .bean-3 {
  width: 70px;
  height: 70px;
}

/* 편집 모드에서는 검은콩 커서 숨김 */
body.editing #bean-cursor {
  display: none;
}

/* =========================
   UI
========================= */

#ui-logo {
  display: none;
}

#ui-guide {
  position: fixed;
  right: 30px;
  bottom: 25px;
  z-index: 100;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #111;
  pointer-events: none;
}

#object-info {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(10px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  color: #111;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

#object-info.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================
   MODAL
========================= */

.modal {
  position: fixed;
  inset: 0;

  width: 100%;
  height: 100%;
  height: 100dvh;

  z-index: 2000;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0;
  padding: 0;
  border: 0;

  overflow: hidden !important;
  overscroll-behavior: none;

  background: rgba(255, 255, 255, 0.88);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;

  cursor: none !important;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

/* 모달 내부 시스템 커서 숨기기 */
.modal,
.modal *,
.modal button {
  cursor: none !important;
}

/* 뷰어를 브라우저 화면 전체에 고정 */
.modal-content {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100vh;
  height: 100dvh;

  max-width: none;
  max-height: none;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0;
  padding: 0;

  overflow: hidden !important;
  overscroll-behavior: none;

  gap: 0;
}

/* 일러스트: 가로 최대 1200px, 화면 정중앙 */

#illustration-view {
  position: fixed !important;

  /* 브라우저 화면의 정중앙 */
  left: 50vw !important;
  top: 50vh !important;
  top: 50dvh !important;

  /* 이미지 크기 */
  width: auto;
  height: auto;

  /* 화면에 맞춰 자동 축소 */
  max-width: min(1200px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);

  /* 이미지 비율 유지 */
  object-fit: contain;
  object-position: center;

  /* 이미지 중심점을 화면 중심에 맞춤 */
  transform: translate(-50%, -50%) !important;

  display: block;
  margin: 0 !important;
  padding: 0;

  flex-shrink: 0;
}

/* 일러스트 이름 숨기기 */
#illustration-caption {
  display: none;
}

/* 닫기 버튼 제거 */
.modal-close {
  display: none !important;
}

/* 페이지 스크롤 완전히 차단 */
html,
body {
  width: 100%;
  height: 100%;

  margin: 0;
  padding: 0;

  overflow: hidden !important;
  overscroll-behavior: none;
}

/* 지도 화면 스크롤 차단 */
#map-viewport {
  position: fixed;
  inset: 0;

  overflow: hidden !important;
  overscroll-behavior: none;
}

/* =========================
   EDITOR TOGGLE
========================= */

#editor-toggle {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 3000;
  padding: 10px 14px;
  border: 1px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 12px;
  cursor: pointer !important;
}

body.editing #editor-toggle {
  background: #111;
  color: #fff;
}

/* =========================
   EDITOR PANEL
========================= */

#editor-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 4000;
  width: 340px;
  height: 100vh;
  padding: 20px;
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid #ddd;
  color: #111;
  display: none;
  cursor: auto !important;
}

body.editing #editor-panel {
  display: block;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.editor-header button {
  border: 0;
  background: transparent;
  font-size: 24px;
}

.editor-description,
.editor-note {
  font-size: 11px;
  line-height: 1.6;
  color: #666;
}

.editor-label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 11px;
}

#editor-panel input[type="text"],
#editor-panel input[type="number"],
#editor-panel textarea {
  width: 100%;
  padding: 9px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-size: 12px;
}

#editor-panel input[type="color"] {
  display: block;
  width: 100%;
  height: 35px;
  border: 0;
  padding: 0;
  background: transparent;
}

.editor-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.editor-actions button,
#apply-coordinates {
  flex: 1;
  padding: 9px 6px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  color: #111;
  font-size: 11px;
}

#draw-mode.active {
  background: #111;
  color: #fff;
}

#hotspot-list {
  margin-top: 20px;
  border-top: 1px solid #ddd;
}

.hotspot-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}

.hotspot-list-item button {
  border: 0;
  background: transparent;
  color: #111;
  text-align: left;
}

.hotspot-list-item .select-hotspot {
  flex: 1;
}

.hotspot-list-item.selected {
  background: #f5f5f5;
}

.hotspot-color-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

.editor-coordinate {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  font-size: 12px;
}

.editor-coordinate label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.editor-coordinate input {
  flex: 1;
  min-width: 0;
}

#apply-coordinates {
  width: 100%;
  margin-top: 10px;
}

#hotspot-code {
  display: block;
  width: 100%;
  height: 140px;
  margin-top: 16px;
  resize: vertical;
  font-family: monospace;
  font-size: 10px;
}

/* =========================
   REDUCED MOTION
========================= */

@media (prefers-reduced-motion: reduce) {
  #bean-cursor .bean {
    animation: none !important;
  }
}

/* =========================
   FORCE NO SCROLL
========================= */

html {
  position: fixed !important;
  inset: 0 !important;

  width: 100% !important;
  height: 100% !important;

  margin: 0 !important;
  padding: 0 !important;

  overflow: hidden !important;
  overscroll-behavior: none !important;
  scroll-behavior: auto !important;
}

body {
  position: fixed !important;
  inset: 0 !important;

  width: 100% !important;
  height: 100% !important;

  margin: 0 !important;
  padding: 0 !important;

  overflow: hidden !important;
  overscroll-behavior: none !important;
}

#map-viewport,
.modal,
.modal-content {
  position: fixed !important;
  inset: 0 !important;

  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;

  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

#illustration-view {
  position: fixed !important;

  left: 50vw !important;
  top: 50vh !important;
  top: 50dvh !important;

  width: auto !important;
  height: auto !important;

  max-width: min(1200px, calc(100vw - 40px)) !important;
  max-height: calc(100dvh - 40px) !important;

  transform: translate(-50%, -50%) !important;
}

/* =========================
   MODAL SCROLL LOCK
========================= */

html,
body {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

.modal,
.modal-content {
  position: fixed !important;
  inset: 0 !important;

  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;

  overflow: hidden !important;
  overscroll-behavior: none !important;

  touch-action: none !important;
}

#illustration-view {
  position: fixed !important;

  left: 50vw !important;
  top: 50dvh !important;

  transform: translate(-50%, -50%) !important;

  max-width: min(1200px, calc(100vw - 40px)) !important;
  max-height: calc(100dvh - 40px) !important;

  pointer-events: none !important;
}

