/* LALALAY Residences — Trang mô hình 3D tương tác (tổng mặt bằng & tầng điển hình LALA1) */
:root {
  --navy: #07101e;
  --glass: rgba(9, 18, 33, 0.72);
  --glass-strong: rgba(10, 20, 37, 0.9);
  --gold: #d8b36a;
  --gold-light: #f3dba4;
  --gold-line: rgba(216, 179, 106, 0.32);
  --terracotta: #b85d43;
  --ivory: #faf5ec;
  --muted: #c9bfa9;
  --display: 'Cormorant Garamond', Georgia, serif;
  --ui: 'Be Vietnam Pro', system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--navy); color: var(--ivory); font-family: var(--ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

#p3-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#p3-canvas:active { cursor: grabbing; }
.p3-vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 62%, rgba(5, 11, 22, 0.42) 100%); }

.p3-glass {
  background: var(--glass);
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

/* Màn chờ */
.p3-veil { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #16243d, #050b16 70%); transition: opacity 1.1s var(--ease), visibility 1.1s; }
.p3-veil.is-done { opacity: 0; visibility: hidden; }
.p3-veil-card { text-align: center; width: min(440px, calc(100% - 32px)); }
.p3-crest { letter-spacing: 0.32em; text-transform: uppercase; font-size: 11px; color: var(--gold); }
.p3-veil h1 { font-family: var(--display); font-weight: 600; font-size: clamp(34px, 6vw, 52px); margin: 10px 0 22px; }
.p3-veil h1 em { color: var(--gold-light); }
.p3-bar { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.p3-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--terracotta), var(--gold-light)); transition: width 0.6s var(--ease); }
.p3-veil p { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* Thanh trên */
.p3-top { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 10; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; pointer-events: none; }
.p3-top > * { pointer-events: auto; }
.p3-brand { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; text-align: left; }
.p3-mono { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display); font-size: 20px; font-weight: 700; background: linear-gradient(135deg, var(--terracotta), #7e3a29); color: var(--gold-light); }
.p3-brand small { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.p3-brand strong { font-family: var(--display); font-size: 18px; font-weight: 600; }
.p3-tabs { display: flex; padding: 4px; gap: 4px; }
.p3-tabs button { padding: 9px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--muted); transition: all 0.35s var(--ease); white-space: nowrap; }
.p3-tabs button.is-active { background: linear-gradient(135deg, var(--gold), #b8894a); color: #1c1306; box-shadow: 0 6px 18px rgba(216, 179, 106, 0.35); }
.p3-actions { display: flex; align-items: center; gap: 2px; padding: 4px; flex-wrap: wrap; }
.p3-hud { padding: 8px 11px; border-radius: 10px; font-size: 12px; font-weight: 500; color: var(--muted); transition: background 0.3s, color 0.3s; white-space: nowrap; }
.p3-hud:hover { color: var(--ivory); background: rgba(255, 255, 255, 0.07); }
.p3-hud.is-active { color: var(--gold-light); background: rgba(216, 179, 106, 0.16); }
.p3-sep { width: 1px; height: 20px; background: var(--gold-line); margin: 0 4px; }

/* Bảng thông tin */
.p3-info { position: fixed; left: 16px; bottom: 16px; z-index: 10; width: min(360px, calc(100% - 32px)); padding: 18px 20px; animation: p3-rise 0.8s var(--ease); }
.p3-kicker { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.p3-info h2, .p3-unit-card h3 { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1.1; margin: 6px 0 8px; }
.p3-info p { font-size: 13px; line-height: 1.55; color: var(--muted); }
.p3-specs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 12px; }
.p3-specs div { padding: 9px 11px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(216, 179, 106, 0.14); }
.p3-specs span { display: block; font-size: 10.5px; color: var(--muted); }
.p3-specs strong { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 600; color: var(--ivory); }
.p3-note { display: block; font-size: 10.5px; line-height: 1.5; color: rgba(201, 191, 169, 0.75); margin-top: 6px; }
.p3-btn { padding: 9px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--gold-line); margin-bottom: 8px; }
.p3-btn.is-gold { background: linear-gradient(135deg, var(--gold), #b8894a); color: #1c1306; border-color: transparent; }
.p3-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Bộ lọc loại căn & thẻ căn */
.p3-legend { position: fixed; right: 16px; bottom: 16px; z-index: 10; padding: 14px 16px; display: none; }
body[data-view="floor"] .p3-legend { display: block; animation: p3-rise 0.8s var(--ease); }
.p3-chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.p3-chip { display: flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid rgba(216, 179, 106, 0.2); transition: all 0.3s var(--ease); }
.p3-chip i { width: 12px; height: 12px; border-radius: 4px; }
.p3-chip b { font-weight: 700; color: var(--gold-light); }
.p3-chip.is-active { background: rgba(216, 179, 106, 0.22); border-color: var(--gold); }
.p3-unit-card { position: fixed; right: 16px; top: 50%; z-index: 11; width: min(320px, calc(100% - 32px)); padding: 18px 20px; transform: translate(calc(100% + 40px), -50%); transition: transform 0.6s var(--ease); }
.p3-unit-card.is-open { transform: translate(0, -50%); }
.p3-unit-card h3 em { font-style: normal; font-family: var(--ui); font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--terracotta); vertical-align: middle; margin-left: 6px; }
.p3-close { position: absolute; right: 12px; top: 10px; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); }

/* Nhãn 3D */
.p3-label-layer { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.p3-label { position: absolute; left: 0; top: 0; will-change: transform; transition: opacity 0.35s; }
.p3-label.is-off { opacity: 0; }
.p3-label.is-behind { opacity: 0.14; }
.p3-tower-tag { display: flex; flex-direction: column; align-items: center; padding: 7px 13px 8px; border-radius: 12px; background: linear-gradient(135deg, rgba(184, 93, 67, 0.95), rgba(126, 58, 41, 0.95)); border: 1px solid rgba(243, 219, 164, 0.5); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35); transition: transform 0.3s var(--ease), box-shadow 0.3s; }
.p3-tower-tag::after { content: ''; position: absolute; bottom: -7px; left: 50%; width: 12px; height: 12px; background: #8e4330; transform: translateX(-50%) rotate(45deg); border-right: 1px solid rgba(243, 219, 164, 0.5); border-bottom: 1px solid rgba(243, 219, 164, 0.5); }
.p3-tower-tag strong { font-family: var(--display); font-size: 20px; letter-spacing: 0.06em; }
.p3-tower-tag { pointer-events: auto; cursor: pointer; }
.p3-tower-tag.is-active { box-shadow: 0 0 0 2px var(--gold-light), 0 12px 34px rgba(216, 179, 106, 0.55); }

/* Popup tòa: hiện ngay trên mặt đứng tòa vừa bấm, mở mặt bằng 3D căn hộ của tòa đó */
.p3-tower-pop { pointer-events: auto; width: 250px; padding: 14px 16px 14px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--gold-line); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); backdrop-filter: blur(14px); animation: p3-pop-in 0.45s var(--ease); z-index: 4; }
.p3-tower-pop.is-hidden { display: none !important; }
.p3-tower-pop::after { content: ''; position: absolute; bottom: -8px; left: 50%; width: 14px; height: 14px; background: var(--glass-strong); transform: translateX(-50%) rotate(45deg); border-right: 1px solid var(--gold-line); border-bottom: 1px solid var(--gold-line); }
.p3-tower-pop .p3-close { right: 8px; top: 6px; }
.p3-tower-pop h4 { font-family: var(--display); font-size: 30px; font-weight: 600; line-height: 1; margin: 4px 0 4px; color: var(--ivory); }
.p3-tower-pop p { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.p3-tower-pop .p3-btn { width: 100%; margin-bottom: 0; }
.p3-tower-pop .p3-btn.is-soon { opacity: 0.55; cursor: not-allowed; }
.p3-tower-pop small { display: block; margin-top: 7px; font-size: 11px; color: var(--gold); text-align: center; }
@keyframes p3-pop-in { from { opacity: 0; margin-top: 10px; } to { opacity: 1; margin-top: 0; } }
.p3-tower-tag span { font-size: 10.5px; color: #fbe6c8; white-space: nowrap; }
.p3-tower-tag.is-hot { box-shadow: 0 0 0 2px var(--gold-light), 0 12px 34px rgba(216, 179, 106, 0.45); }
.p3-pin span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; font-weight: 700; border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); animation: p3-pulse 2.8s ease-in-out infinite; }
.p3-pin.is-red span { background: #c9573e; }
.p3-pin.is-blue span { background: #7fc3dc; color: #0c2430; }
.p3-pin.is-gold span { background: var(--gold); color: #1c1306; width: 26px; height: 26px; }
/* Điểm tiện ích: rê chuột hoặc chọn ở bảng chú thích để hiện tên ngay trên điểm */
.p3-pin { pointer-events: auto; cursor: pointer; display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.p3-pin em { font-style: normal; font-size: 11.5px; font-weight: 600; white-space: nowrap; padding: 4px 9px; border-radius: 999px; background: rgba(9, 18, 33, 0.88); border: 1px solid var(--gold-line); opacity: 0; transform: translateY(4px); transition: all 0.3s var(--ease); pointer-events: none; }
.p3-pin:hover em, .p3-pin.is-picked em { opacity: 1; transform: none; }
.p3-label.p3-pin.is-picked { opacity: 1; z-index: 2; }
.p3-pin.is-picked span { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(243, 219, 164, 0.55), 0 6px 16px rgba(0, 0, 0, 0.4); }
.p3-label.p3-pin.is-faded { opacity: 0.3; }

/* Bảng chú thích tiện ích (chỉ ở tổng mặt bằng) */
.p3-amenities { position: fixed; right: 16px; top: 84px; z-index: 10; width: 300px; max-height: calc(100% - 120px); overflow-y: auto; padding: 16px 16px 12px; transform: translateX(calc(100% + 40px)); transition: transform 0.55s var(--ease); }
.p3-amenities.is-open { transform: none; }
body[data-view="floor"] .p3-amenities, body[data-view="floor"] .p3-only-master { display: none; }
.p3-am-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--gold-line); }
.p3-am-head h3 { font-family: var(--display); font-size: 26px; font-weight: 600; line-height: 1.1; margin-top: 4px; }
.p3-am-head .p3-close { position: static; flex-shrink: 0; }
.p3-am-group { font-family: var(--display); font-size: 17px; font-weight: 600; color: var(--gold-light); margin: 12px 2px 6px; }
.p3-am-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 10px; text-align: left; font-size: 13px; transition: background 0.25s; }
.p3-am-item i { flex-shrink: 0; display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 700; border: 2px solid rgba(255, 255, 255, 0.8); }
.p3-am-item i.is-red { background: #c9573e; }
.p3-am-item i.is-blue { background: #d6eef7; color: #0c2430; }
.p3-am-item i.is-gold { background: #cfa36a; color: #1c1306; }
.p3-am-item span { flex: 1; }
.p3-am-item small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.p3-am-item:hover, .p3-am-item.is-hot { background: rgba(255, 255, 255, 0.06); }
.p3-am-item.is-active { background: rgba(216, 179, 106, 0.2); box-shadow: inset 0 0 0 1px var(--gold-line); }
/* Thẻ ảnh phối cảnh của tiện ích đang chọn, đặt cạnh bảng chú thích */
.p3-am-card { position: fixed; right: 332px; top: 84px; z-index: 10; width: 380px; padding: 14px; opacity: 0; transform: translateY(-10px); pointer-events: none; transition: opacity 0.4s var(--ease), transform 0.4s var(--ease), right 0.55s var(--ease); }
.p3-am-card.is-open { opacity: 1; transform: none; pointer-events: auto; }
.p3-amenities:not(.is-open) ~ .p3-am-card { right: 16px; }
body[data-view="floor"] .p3-am-card { display: none; }
.p3-am-card .p3-close { right: 10px; top: 10px; }
.p3-am-card-head { display: flex; align-items: center; gap: 10px; padding-right: 30px; margin-bottom: 12px; }
.p3-am-card-head i { flex-shrink: 0; display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 999px; font-style: normal; font-size: 13px; font-weight: 700; border: 2px solid rgba(255, 255, 255, 0.85); }
.p3-am-card-head i.is-red { background: #c9573e; }
.p3-am-card-head i.is-blue { background: #d6eef7; color: #0c2430; }
.p3-am-card-head i.is-gold { background: #cfa36a; color: #1c1306; }
.p3-am-card-head h4 { font-family: var(--display); font-size: 24px; font-weight: 600; line-height: 1.1; margin-top: 2px; }
.p3-am-photo { position: relative; display: block; width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--gold-line); cursor: zoom-in; }
.p3-am-photo img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; transition: transform 0.8s var(--ease); }
.p3-am-photo:hover img { transform: scale(1.05); }
.p3-am-photo span { position: absolute; right: 8px; bottom: 8px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: rgba(9, 18, 33, 0.78); color: var(--gold-light); }
.p3-am-nophoto { display: grid; place-items: center; aspect-ratio: 16 / 10; border-radius: 12px; border: 1px dashed var(--gold-line); font-size: 12.5px; color: var(--muted); text-align: center; padding: 12px; }
.p3-am-note { margin-top: 8px; font-size: 10.5px; font-style: italic; color: var(--muted); }
.p3-lightbox { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; padding: 24px; background: rgba(4, 9, 18, 0.88); backdrop-filter: blur(10px); cursor: zoom-out; }
.p3-lightbox.is-open { display: grid; animation: p3-rise 0.4s var(--ease); }
.p3-lightbox figure { width: min(1400px, 100%); }
/* Ảnh giãn vừa khung (kể cả ảnh gốc nhỏ); drop-shadow bám theo phần ảnh thật, không theo vùng trống của contain. */
.p3-lightbox img { display: block; width: 100%; height: min(calc(100vh - 120px), 820px); object-fit: contain; filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.6)); }
.p3-lightbox figcaption { margin-top: 12px; text-align: center; font-family: var(--display); font-size: 22px; color: var(--ivory); }
.p3-lightbox figcaption b { color: var(--gold-light); margin-right: 6px; }
.p3-lightbox figcaption small { display: block; font-family: var(--ui); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.p3-unit-tag { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 4px; border-radius: 999px; background: rgba(9, 18, 33, 0.82); border: 1px solid var(--gold-line); font-size: 11px; white-space: nowrap; transition: opacity 0.35s, transform 0.3s var(--ease), background 0.3s; }
.p3-unit-tag b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--terracotta); font-size: 10.5px; }
.p3-unit-tag span { color: var(--ivory); }
.p3-unit-tag i { font-style: normal; }
/* Màn dọc hẹp: nhãn đặt giữa căn nên chỉ giữ số căn và loại căn, diện tích xem ở thẻ chi tiết khi chạm. */
@media (max-aspect-ratio: 4/5) {
  .p3-unit-tag i { display: none; }
  .p3-entry-tag span { max-width: 76px; white-space: normal; text-align: center; line-height: 1.25; }
}
.p3-unit-tag.is-dim { opacity: 0.28; }
.p3-unit-tag.is-active { background: linear-gradient(135deg, var(--gold), #b8894a); color: #1c1306; }
.p3-unit-tag.is-active span { color: #1c1306; }
.p3-entry-tag { display: flex; flex-direction: column; align-items: center; font-size: 11px; font-weight: 600; color: var(--gold-light); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.p3-entry-tag i { font-style: normal; font-size: 20px; animation: p3-bob 1.6s ease-in-out infinite; }

.p3-hint { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9; font-size: 11.5px; color: var(--muted); padding: 7px 14px; border-radius: 999px; background: rgba(9, 18, 33, 0.6); transition: opacity 0.8s; white-space: nowrap; }
body.has-interacted .p3-hint { opacity: 0; }
.p3-toast { position: fixed; left: 50%; top: 84px; transform: translate(-50%, -12px); z-index: 30; padding: 10px 16px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--gold-line); font-size: 13px; opacity: 0; transition: all 0.4s var(--ease); pointer-events: none; }
.p3-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

body.is-capture .p3-top, body.is-capture .p3-info, body.is-capture .p3-legend,
body.is-capture .p3-hint, body.is-capture .p3-unit-card, body.is-capture .p3-veil, body.is-capture .p3-amenities,
body.is-capture .p3-am-card { display: none !important; }

@keyframes p3-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes p3-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45); } 50% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); } }
@keyframes p3-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

@media (max-width: 860px) {
  .p3-amenities { top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 56%; z-index: 12; transform: translateY(calc(100% + 30px)); }
  /* Thẻ ảnh nằm ngay dưới thanh công cụ (3 hàng), bảng chú thích dạng sheet thu thấp lại để không bị che. */
  .p3-am-card, .p3-amenities:not(.is-open) ~ .p3-am-card { top: 168px; left: 10px; right: 10px; width: auto; z-index: 13; padding: 12px; }
  .p3-am-card-head { margin-bottom: 10px; }
  .p3-am-card-head h4 { font-size: 20px; }
  .p3-am-photo img, .p3-am-nophoto { aspect-ratio: 2 / 1; }
  .p3-am-note { display: none; }
  body.has-am-card .p3-amenities { max-height: max(160px, calc(100% - 430px)); }
  .p3-top { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .p3-brand small { display: none; }
  .p3-tabs { order: 3; width: 100%; overflow-x: auto; }
  .p3-tabs button { flex: 1; padding: 8px 10px; font-size: 12px; }
  .p3-actions { order: 2; max-width: calc(100% - 64px); overflow-x: auto; flex-wrap: nowrap; }
  .p3-sep, .p3-hint { display: none; }
  .p3-info { left: 10px; bottom: 10px; width: calc(100% - 20px); padding: 14px 16px; }
  .p3-info h2 { font-size: 22px; }
  .p3-info p, .p3-note { display: none; }
  .p3-specs { margin: 10px 0 4px; }
  body[data-view="floor"] .p3-info { display: none; }
  .p3-legend { right: 10px; bottom: 10px; left: 10px; }
  .p3-unit-card { top: auto; bottom: 96px; right: 10px; transform: translateY(calc(100% + 140px)); }
  .p3-unit-card.is-open { transform: none; }
  .p3-tower-tag span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .p3-pin span, .p3-entry-tag i { animation: none; }
}
