/* 3D 뷰어(building3d.js)가 그리는 영역의 모습: 하늘 배경, 배지·힌트·말풍선·오버레이. explore.css 뒤에 읽힌다.
   지도 칸의 크기·모양(둥근 카드, 휴대폰 높이)은 explore.css 가 정하고, 여기서는 그 안쪽만 다룬다.
   토큰에는 폴백을 붙여 둔다 — 이 파일만 따로 읽혀도(미리보기·오류 화면) 색이 빠지지 않게. */

/* ---------- 하늘 ----------
   캔버스는 투명하고 하늘은 CSS 가 그린다 (GPU 비용 0, 페이지 색과 늘 맞는다).
   바탕 = 층 도면 모드의 차분한 하늘. ::before = 건물 모드의 하늘(페리윙클 → 크림 + 오른쪽 위 햇빛)로, 층으로 들어가면 서서히 걷힌다. */
.viewer {
    background: linear-gradient(180deg, #ECEEF9 0%, #F3F1F0 55%, #FAF5EC 100%);
    isolation: isolate;
}
.viewer::before {
    content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(60% 55% at 88% 6%, rgba(255, 214, 170, .55) 0%, rgba(255, 214, 170, 0) 70%),
        radial-gradient(70% 50% at 50% 56%, rgba(255, 255, 255, .7) 0%, rgba(255, 255, 255, 0) 70%),
        linear-gradient(180deg, #DCE4FF 0%, #EEF0FB 52%, #FBF3E8 100%);
    transition: opacity .7s ease;
}
.viewer.is-floor::before { opacity: 0; }
/* 종이 결: 아래쪽에만 옅게 깔리는 점 무늬 (시안 Atelier) */
.viewer::after {
    content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
    background-image: radial-gradient(rgba(60, 45, 20, .10) 1px, transparent 1.3px); background-size: 18px 18px;
    -webkit-mask-image: linear-gradient(180deg, transparent 55%, #000 100%); mask-image: linear-gradient(180deg, transparent 55%, #000 100%);
}
/* 첫 장면이 그려지면 building3d.js 가 .is-ready 를 붙인다 — 빈 캔버스가 번쩍이지 않고 하늘 위로 섬이 떠오른다 */
.viewer canvas { position: relative; z-index: 1; opacity: 0; transition: opacity .45s ease; }
.viewer.is-ready canvas { opacity: 1; }

.viewer-fallback {
    position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; text-align: center; padding: 2rem;
    color: var(--ink-2, #4A463D); font-size: .93rem; line-height: 1.6;
    background: linear-gradient(180deg, #DCE4FF 0%, #EEF0FB 52%, #FBF3E8 100%);
}
.viewer-fallback p { margin: 0; }
.viewer-fallback .muted { color: var(--ink-3, #6F695D); font-size: .86rem; }
.viewer-fallback .btn { margin-top: .7rem; }

/* ---------- 3D 위의 칩 ----------
   유리 칩: 블러는 @supports 안에서만 쓰고, 없을 때는 거의 불투명한 단색으로 읽힌다. */
.viewer-overlay { position: absolute; top: 12px; left: 12px; z-index: 2; display: flex; align-items: center; gap: 6px; }
.viewer-overlay[hidden] { display: none; }
.viewer-overlay a {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 12px; margin: -6px 0;   /* 터치 영역 44px, 보이는 높이는 아래 ::before */
    position: relative; isolation: isolate;
    font-size: 13px; font-weight: 700; letter-spacing: -.01em; color: var(--ink, #1D1B16); text-decoration: none; white-space: nowrap;
    border: 0; background: none; box-shadow: none;
}
.viewer-overlay a::before {
    content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 6px; bottom: 6px; border-radius: 999px;
    background: rgba(255, 254, 251, .96); box-shadow: 0 2px 10px rgba(45, 35, 15, .10), inset 0 0 0 1px rgba(45, 35, 15, .08);
    transition: box-shadow .12s, background-color .12s;
}
.viewer-overlay a:hover { text-decoration: none; color: var(--ink, #1D1B16); border: 0; }
.viewer-overlay a:hover::before { background: #fff; box-shadow: 0 4px 14px rgba(45, 35, 15, .14), inset 0 0 0 1px rgba(45, 35, 15, .16); }
.viewer-overlay a:focus-visible { outline: none; }
.viewer-overlay a:focus-visible::before { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent, #2B3FD6); }
.viewer-overlay a .icon { width: 15px; height: 15px; }
/* 층 이름도 "건물 전체" 와 같은 알약에 담는다 — 맨 글자로 두면 도면이나 나무 위에 얹혀 깨진 것처럼 보인다. 보이는 높이(32px)를 맞춘다. */
.viewer-overlay span {
    display: inline-flex; align-items: center; height: 32px; padding: 0 13px 1px; border-radius: 999px; white-space: nowrap;
    font-family: var(--font-display, "Hahmlet", "Pretendard Variable", Pretendard, sans-serif);
    font-size: 17px; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--ink, #1D1B16);
    background: rgba(255, 254, 251, .96); box-shadow: 0 2px 10px rgba(45, 35, 15, .10), inset 0 0 0 1px rgba(45, 35, 15, .08);
}

/* 힌트는 .map-note 상자에 들어 있지만 자리는 아래 가운데다 (2026-09-22: "추정 모델" 배지는 뺐다). */
.map-note { display: contents; }

.map-note .viewer-hint, .viewer-hint {
    position: absolute; z-index: 2; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; pointer-events: none;
    display: block; max-width: calc(100% - 24px); height: 32px; line-height: 32px; padding: 0 14px; border-radius: 999px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12px; font-weight: 500; letter-spacing: -.01em; color: #fff; background: rgba(29, 27, 22, .84);
    transition: opacity .4s ease;
}
.viewer-hint[hidden] { display: none; }
.viewer-hint.is-idle { opacity: 0; }

@supports ((-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px))) {
    .viewer-overlay a::before, .viewer-overlay span { background: rgba(255, 254, 251, .86); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
    .viewer-hint, .map-note .viewer-hint { background: rgba(29, 27, 22, .74); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}

/* ---------- 말풍선: 마우스를 올린 층·실 옆에 뜨는 흰 카드 ---------- */
.viewer-tip {
    position: absolute; z-index: 5; pointer-events: none; display: flex; align-items: center; gap: 10px;
    padding: 8px 14px 8px 8px; border-radius: 14px; white-space: nowrap;
    color: var(--ink, #1D1B16); background: var(--surface, #FFFEFB);
    box-shadow: 0 12px 32px -8px rgba(45, 35, 15, .28), 0 0 0 1px rgba(45, 35, 15, .06);
}
.viewer-tip[hidden] { display: none; }
.viewer-tip .tip-mark {
    flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
    font-size: 13px; font-weight: 800; letter-spacing: -.02em; color: #fff; background: var(--accent, #2B3FD6);
}
.viewer-tip .tip-mark-room { width: 14px; height: 36px; border-radius: 7px; box-shadow: inset 0 0 0 1.5px currentColor; }
.viewer-tip .tip-body { display: flex; flex-direction: column; line-height: 1.35; }
.viewer-tip strong { font-size: 14px; font-weight: 700; letter-spacing: -.015em; }
.viewer-tip .tip-sub { font-size: 12px; font-weight: 500; color: var(--ink-3, #6F695D); }

@media (min-width: 961px) {
    .viewer-overlay { top: 18px; left: 18px; }
    .map-note .viewer-hint, .viewer-hint { bottom: 20px; height: 34px; line-height: 34px; font-size: 12.5px; padding: 0 16px; }
    .viewer-overlay { gap: 8px; }
    .viewer-overlay span { font-size: 18px; }
}

/* 휴대폰: 탐색 화면에서는 아래 시트가 지도 밑동을 덮는다. 덮이는 높이는 explore.css 가 --map-overlap 으로 알려 줄 수 있다(없으면 28px). */
@media (max-width: 960px) {
    .explore-map .viewer-hint { bottom: calc(var(--map-overlap, 28px) + 10px); }
}

/* 아주 좁은 휴대폰(360px 미만): "건물 전체" + 층 이름 + 배지가 한 줄에 들어가지 않는다. 배지 문구는 줄일 수 없고 둘째 줄로 내리면 작은 지도를 가리므로,
   바로 아래 층 선택과 제목에 이미 있는 층 이름 알약을 감춘다 (320px 에서도 한 줄에 들어간다). */
@media (max-width: 359px) {
    .viewer-overlay span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .viewer::before, .viewer canvas, .viewer-hint { transition: none; }
}

/* ==========================================================================
   빈 시간 도우미 — 주고받는 말풍선. 질문은 날짜 칩으로 고른다 (외부 요청 없음)
   ========================================================================== */
.explore { position: relative; }   /* 도우미를 지도 밖(main 기준)에 띄우기 위한 기준점 */
.helper { position: absolute; right: 32px; bottom: 32px; z-index: 12; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
/* 말풍선 하나짜리 동그란 버튼. 글자는 넣지 않는다 (3D 를 가리지 않게) — 이름은 aria-label·title 이 말한다 */
.helper-fab {
    display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; padding: 0; border: 0;
    border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; box-shadow: var(--sh-accent);
    transition: background-color var(--t-fast), transform var(--t-fast);
}
.helper-fab .icon { width: 24px; height: 24px; stroke-width: 1.9; vertical-align: 0; }
.helper-fab:hover { background: var(--accent-hover); }
.helper-fab:active { transform: scale(.97); }

.helper-panel {
    order: -1; width: min(340px, calc(100vw - 2 * var(--gutter)));
    display: flex; flex-direction: column; max-height: min(64vh, 520px);
    border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-pop); overflow: hidden;
}
.helper-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.helper-who { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sub); font-weight: 700; }
.helper-who .icon { color: var(--accent); vertical-align: 0; }

.helper-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; }
/* 도우미가 하는 말: 왼쪽 종이색 말풍선 (왼쪽 아래 모서리만 각지게 — 말하는 쪽을 가리킨다) */
.msg.bot { align-self: flex-start; padding: 10px 13px; border-radius: 16px 16px 16px 5px; background: var(--paper-2); }
/* 내가 고른 것: 오른쪽 코발트 말풍선 */
.msg.me { align-self: flex-end; padding: 9px 13px; border-radius: 16px 16px 5px 16px; background: var(--accent); color: #fff; }
.msg.asks { align-self: flex-start; max-width: 100%; display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.msg-line { margin: 0; font-size: var(--fs-sub); font-weight: 700; line-height: 1.45; }
.msg.me .msg-line { font-weight: 600; }
.msg-note { margin: 3px 0 0; font-size: var(--fs-caption); color: var(--ink-3); line-height: 1.5; }

.msg-items { list-style: none; margin: 9px 0 0; padding: 0; display: grid; gap: 3px; }
.msg-items a, .msg-items span {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
    padding: 8px 10px; border-radius: var(--r-md); background: var(--surface); color: inherit;
}
.msg-items a { transition: background-color var(--t-fast); }
.msg-items a:hover { background: var(--accent-wash); text-decoration: none; }
.msg-items b { grid-column: 1; font-size: var(--fs-sub); font-weight: 700; min-width: 0; }
.msg-items small { grid-column: 1; font-size: var(--fs-caption); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.msg-items .msg-badge { grid-column: 2; grid-row: 1; font-size: var(--fs-micro); font-weight: 700; color: var(--ink-3); }
.msg-items .icon { grid-column: 2; grid-row: 2; width: 16px; height: 16px; color: var(--ink-4); vertical-align: 0; }

.msg.asks button {
    min-height: 36px; padding: 0 13px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
    background: var(--surface); color: var(--ink-2); font-size: var(--fs-caption); font-weight: 600; cursor: pointer;
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.msg.asks button:hover { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }

.helper-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.helper-foot label { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.helper-foot input {
    flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
    background: var(--paper); color: var(--ink); font-family: inherit; font-size: var(--fs-caption); font-variant-numeric: tabular-nums;
}

@media (max-width: 767px) {
    /* 목록을 내려 보는 동안에도 따라오도록 화면에 고정한다 (탭 바 위) */
    .helper { position: fixed; right: 12px; bottom: calc(12px + var(--tabbar-h)); z-index: 36; }
    .helper-fab { width: 52px; height: 52px; }
    .helper-fab .icon { width: 22px; height: 22px; }
    .helper-panel { width: min(340px, calc(100vw - 24px)); max-height: min(62vh, 460px); }
}
