/* Объёмная планировка квартиры (plan3d.js): холст three.js, загрузка, 2D-режим, подсказка и кнопки. Подключается на странице квартиры. */
.p3d{position:relative;width:100%;height:100%;overflow:hidden;user-select:none;-webkit-user-select:none}
.p3d__stage{position:absolute;inset:0;z-index:0;cursor:grab;touch-action:none;outline:none;transition:opacity .45s ease, visibility 0s}
.p3d.is-drag .p3d__stage{cursor:grabbing}
.p3d__stage:focus-visible{box-shadow:inset 0 0 0 2px var(--blue)}
.p3d__stage canvas{position:relative;display:block;width:100%;height:100%;opacity:0;transition:opacity .7s ease}
/* ночь: тёмно-синий фон под моделью, плавно */
.p3d__stage::before{content:"";position:absolute;inset:0;background:radial-gradient(110% 90% at 50% 42%,#26306a 0%,#111842 55%,#0a0f2c 100%);
  opacity:0;transition:opacity .5s ease}
.p3d.is-night .p3d__stage::before{opacity:1}
.p3d.is-ready .p3d__stage canvas{opacity:1}

/* загрузка three.js и модели: тихая строка с бегущей точкой по центру */
.p3d__load{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;align-items:center;gap:10px;
  font-size:13px;color:var(--muted);pointer-events:none;opacity:0;transition:opacity .3s ease}
.p3d.is-loading .p3d__load{opacity:1;transition-delay:.25s}
.p3d__load span{width:8px;height:8px;border-radius:50%;background:var(--blue);animation:p3d-pulse 1.1s ease-in-out infinite}
/* вне загрузки точка замирает: бесконечная анимация не держит отрисовку после появления модели */
.p3d:not(.is-loading) .p3d__load span{animation-play-state:paused}
@keyframes p3d-pulse{0%,100%{opacity:.25;transform:scale(.7)}50%{opacity:1;transform:scale(1)}}

.p3d__flat{position:absolute;inset:0;display:block;padding:70px 28px 28px;cursor:zoom-in;opacity:0;visibility:hidden;
  transition:opacity .45s ease, visibility 0s linear .45s}
.p3d__flat img{display:block;width:100%;height:100%;object-fit:contain;mix-blend-mode:multiply}
.p3d.is-2d .p3d__stage,.p3d.is-2d .p3d__load{opacity:0;visibility:hidden;transition:opacity .45s ease, visibility 0s linear .45s}
.p3d.is-2d .p3d__flat,.p3d.is-wait .p3d__flat{opacity:1;visibility:visible;transition:opacity .45s ease, visibility 0s}

.p3d__hint{position:absolute;left:14px;bottom:62px;display:flex;align-items:center;gap:8px;height:36px;padding:0 14px 0 10px;border-radius:999px;
  background:rgba(255,255,255,.92);border:1px solid var(--glass-line);font-size:12px;color:var(--muted);pointer-events:none;transition:opacity .5s ease}
.p3d__hint svg{width:18px;height:18px;fill:none;stroke:var(--blue);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.p3d.is-touched .p3d__hint,.p3d.is-2d .p3d__hint,.p3d:not(.is-ready) .p3d__hint{opacity:0}
.p3d__bar{position:absolute;right:14px;bottom:14px;display:flex;gap:6px;transition:opacity .3s ease}
/* переключатели слева внизу: «День / Ночь», «С мебелью / Без мебели», «С размерами / Без размеров» — одинаковые сегменты */
.p3d__ctrls{position:absolute;left:14px;bottom:14px;display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px}
.p3d__time{display:flex;gap:2px;padding:3px;border-radius:999px;background:#fff;border:1px solid var(--glass-line);
  transition:opacity .3s ease}
.p3d__time-btn{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 13px 0 10px;border-radius:999px;font-size:12.5px;font-weight:800;
  color:var(--muted);transition:background .25s, color .25s}
.p3d__time-btn:hover{color:var(--ink)}
.p3d__time-btn[aria-pressed="true"]{background:var(--blue);color:#fff}
.p3d.is-night .p3d__time-btn[aria-pressed="true"]{background:#141a3c}
.p3d__time-btn:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.p3d__time-btn svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.p3d.is-2d .p3d__time,.p3d:not(.is-ready) .p3d__time{opacity:0;pointer-events:none}
.p3d.is-2d .p3d__bar,.p3d:not(.is-ready) .p3d__bar{opacity:0;pointer-events:none}
/* солнце (has-sun): над переключателями — время суток бегунком и день года; ночью скрыто. Подсказка поднимается над ним */
.p3d__sun{position:absolute;left:14px;bottom:62px;align-items:center;padding:3px 3px 3px 10px}
.p3d.is-night .p3d__sun{opacity:0;pointer-events:none}
.p3d.has-sun .p3d__hint{bottom:110px}
.p3d__sun-icon{display:grid;place-items:center}
.p3d__sun-icon svg{width:16px;height:16px;fill:none;stroke:#e8902a;stroke-width:1.6;stroke-linecap:round}
.p3d__sun-time{min-width:44px;padding-left:6px;font-size:12.5px;font-weight:800;color:var(--ink);font-variant-numeric:tabular-nums}
.p3d__sun-range{-webkit-appearance:none;appearance:none;width:clamp(120px,13vw,190px);height:32px;margin:0 10px 0 4px;background:transparent;cursor:pointer}
.p3d__sun-range::-webkit-slider-runnable-track{height:4px;border-radius:2px;
  background:linear-gradient(90deg,#ffb36e,#ffd27a var(--p,50%),rgba(20,26,60,.14) var(--p,50%))}
.p3d__sun-range::-moz-range-track{height:4px;border-radius:2px;
  background:linear-gradient(90deg,#ffb36e,#ffd27a var(--p,50%),rgba(20,26,60,.14) var(--p,50%))}
.p3d__sun-range::-webkit-slider-thumb{-webkit-appearance:none;width:18px;height:18px;margin-top:-7px;border-radius:50%;background:#fff;
  border:2px solid #f0a33a;box-shadow:0 2px 6px rgba(20,26,60,.2)}
.p3d__sun-range::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:#fff;border:2px solid #f0a33a;box-shadow:0 2px 6px rgba(20,26,60,.2)}
.p3d__sun-range:focus-visible{outline:2px solid var(--blue);outline-offset:2px;border-radius:6px}
.p3d__seasons{display:flex;gap:2px}
.p3d__season{padding:0 12px}
/* компас справа над кнопками: «С» и солнце на круге, поворачивается вместе с моделью (plan3d.js, placeRose) */
.p3d__rose{position:absolute;right:14px;bottom:62px;width:44px;height:44px;border-radius:50%;background:rgba(255,255,255,.92);
  border:1px solid var(--glass-line);pointer-events:none;transition:opacity .3s ease}
.p3d__rose svg{display:block;width:100%;height:100%;overflow:visible}
.p3d__rose-ring{fill:none;stroke:rgba(20,26,60,.12);stroke-width:1}
.p3d__rose-n{fill:var(--blue)}
.p3d__rose-s{fill:rgba(20,26,60,.2)}
.p3d__rose-c{font-size:8.5px;font-weight:800;fill:var(--blue);text-anchor:middle;dominant-baseline:central}
.p3d__rose-sun{fill:#ffb02e;stroke:#fff;stroke-width:1.2}
.p3d.is-night .p3d__rose{background:rgba(32,39,79,.94);border-color:rgba(232,235,249,.12)}
.p3d.is-night :is(.p3d__rose-n, .p3d__rose-c){fill:#9fb1ff}
.p3d.is-night .p3d__rose-sun{display:none}
.p3d.is-2d .p3d__rose,.p3d:not(.is-ready) .p3d__rose{opacity:0}
/* 2D: «Планировка / Размеры» — на месте переключателей 3D, только в 2D */
.p3d__sheet{position:absolute;left:14px;bottom:14px;opacity:0;pointer-events:none}
.p3d.is-2d .p3d__sheet{opacity:1;pointer-events:auto}
.p3d.is-night .p3d__sheet .p3d__time-btn[aria-pressed="true"]{background:var(--blue)}
/* стиль отделки — справа вверху, та же пилюля; у стилей превью-капсула вместо значка. Карточка — под кнопками */
.p3d__styles{position:absolute;right:14px;top:14px;z-index:2}
.p3d__styles .p3d__time-btn:has(.p3d__thumb){padding:0 12px 0 4px}
.p3d__thumb{flex:none;width:38px;height:24px;border-radius:999px;object-fit:cover;background:var(--bg-0, #eef0f5);
  box-shadow:0 0 0 1px rgba(20,26,60,.08)}
.p3d__time-btn[aria-pressed="true"] .p3d__thumb{box-shadow:0 0 0 2px rgba(255,255,255,.9)}
.p3d__peek{position:absolute;right:14px;top:64px;z-index:4;width:min(320px,calc(100% - 28px));padding:6px;border-radius:14px;background:#fff;
  border:1px solid var(--glass-line);box-shadow:0 18px 40px rgba(20,26,60,.16);opacity:0;transform:translateY(-6px);pointer-events:none;
  transition:opacity .25s ease, transform .25s ease}
.p3d__peek.is-on{opacity:1;transform:none}
.p3d.is-2d .p3d__peek,.p3d:not(.is-ready) .p3d__peek{display:none}
.p3d__peek-frame{aspect-ratio:16/10;border-radius:10px;overflow:hidden;background:var(--bg-0, #eef0f5)}
.p3d__peek-frame img{display:block;width:100%;height:100%;object-fit:cover}
.p3d__peek-cap{display:grid;gap:3px;padding:10px 6px 4px;font-size:12.5px;line-height:1.4;color:var(--muted)}
.p3d__peek-cap b{font-size:14px;color:var(--ink)}
.p3d__chord{display:flex;gap:5px;margin-top:6px}
.p3d__chord i{width:18px;height:18px;border-radius:50%;box-shadow:inset 0 0 0 1px rgba(20,26,60,.14)}
.p3d.is-night .p3d__peek{background:rgba(32,39,79,.97);border-color:rgba(232,235,249,.12)}
.p3d.is-night .p3d__peek-cap{color:rgba(232,235,249,.62)}
.p3d.is-night .p3d__peek-cap b{color:#e8ebf9}
/* подписи размеров в 3D: поверх холста, но под кнопками (холст — свой слой z-index:0), ставит plan3d.js (placeDims) */
.p3d__dims{position:absolute;inset:0;z-index:1;pointer-events:none;overflow:hidden}
.p3d:not(.is-dims) .p3d__dims,.p3d.is-2d .p3d__dims{display:none}
.p3d__dim{position:absolute;left:0;top:0;padding:2px 6px;border-radius:6px;background:rgba(255,255,255,.92);border:1px solid var(--glass-line);
  font-size:11.5px;font-weight:800;line-height:1.2;color:#33427d;white-space:nowrap;font-variant-numeric:tabular-nums}
.p3d__dim.is-off{visibility:hidden}
.p3d.is-night .p3d__dim{background:rgba(20,26,60,.88);border-color:rgba(201,212,255,.35);color:#e3e9ff}
.p3d__btn{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#fff;border:1px solid var(--glass-line);color:var(--ink);
  transition:border-color .25s, color .25s}
.p3d__btn:hover{border-color:var(--blue);color:var(--blue)}
.p3d__btn:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.p3d__btn svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
/* на весь экран: фон как у блока планировки; is-cover — поверх страницы там, где нет Fullscreen API (iPhone) */
.p3d.is-full{background:radial-gradient(90% 80% at 50% 45%,#fff 0%,#f3f5fa 62%,#e9ecf5 100%)}
.p3d.is-cover{position:fixed;inset:0;z-index:200;width:auto;height:auto}
html.p3d-cover{overflow:hidden}
.p3d.is-cover .p3d__bar{bottom:max(14px,env(safe-area-inset-bottom))}
.p3d.is-cover .p3d__ctrls{bottom:max(14px,env(safe-area-inset-bottom))}
.p3d.is-cover .p3d__hint{bottom:calc(max(14px,env(safe-area-inset-bottom)) + 48px)}
.p3d.is-cover .p3d__sun,.p3d.is-cover .p3d__rose{bottom:calc(max(14px,env(safe-area-inset-bottom)) + 48px)}
.p3d.is-cover.has-sun .p3d__hint{bottom:calc(max(14px,env(safe-area-inset-bottom)) + 96px)}
.p3d.is-cover.is-night:not(.is-2d) .p3d__rose{background:rgba(32,39,79,.94)}
/* ночью поверх страницы: просмотрщик перенесён в body, ночные правила страницы (flat.css) на него не действуют —
   пилюли приглушены теми же цветами, что на странице */
.p3d.is-cover.is-night:not(.is-2d) :is(.p3d__time,.p3d__btn,.p3d__hint){background:rgba(32,39,79,.94);border-color:rgba(232,235,249,.12);color:#e8ebf9}
.p3d.is-cover.is-night:not(.is-2d) :is(.p3d__time-btn,.p3d__hint){color:rgba(232,235,249,.62)}
.p3d.is-cover.is-night:not(.is-2d) .p3d__time-btn[aria-pressed="true"]{background:#34479e;color:#e8ebf9}
@media (max-width:760px){
  .p3d__flat{padding:62px 16px 16px}
  /* подсказка не заходит на кнопки масштаба справа */
  .p3d__hint{left:12px;bottom:104px;max-width:calc(100% - 24px)}
  /* солнце на телефоне — сверху, под «3D / 2D»: внизу три ряда переключателей */
  .p3d.has-sun .p3d__hint{bottom:104px}
  .p3d__sun,.p3d.is-cover .p3d__sun{left:12px;top:58px;bottom:auto;padding-left:4px}
  .p3d__sun-icon{display:none}
  .p3d__sun-time{min-width:40px;font-size:12px}
  .p3d__sun-range{width:clamp(80px,26vw,140px);margin:0 6px 0 2px}
  .p3d__season{padding:0 9px}
  .p3d__rose{right:12px;bottom:56px;width:40px;height:40px}
  .p3d.is-cover .p3d__rose{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 44px)}
  /* на телефоне переключатели друг под другом, подсказка — над ними */
  .p3d__ctrls{left:12px;bottom:12px;flex-direction:column;align-items:flex-start;gap:6px}
  /* «С мебелью / Без мебели» — только значки (подпись — в aria-label и title), иначе налезает на кнопки масштаба */
  .p3d__furn .p3d__time-btn span,.p3d__dimsw .p3d__time-btn span{display:none}
  .p3d__sheet{left:12px;bottom:12px}
  /* стили — только превью и значок (название — в aria-label и title), иначе не помещаются рядом с «3D / 2D» */
  .p3d__styles{right:12px;top:12px}
  .p3d__styles .p3d__time-btn span{display:none}
  .p3d__styles .p3d__time-btn:has(.p3d__thumb){padding:0 4px}
  .p3d__peek{right:12px;top:60px;width:min(300px,calc(100% - 24px))}
  .p3d.is-cover .p3d__hint{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 92px)}
  .p3d.is-cover.has-sun .p3d__hint{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 92px)}
  /* третий ряд — «С размерами / Без размеров» (есть, когда у модели есть размеры): подсказка выше на ряд */
  .p3d:has(.p3d__dimsw:not([hidden])) .p3d__hint{bottom:150px}
  .p3d.is-cover:has(.p3d__dimsw:not([hidden])) .p3d__hint{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 138px)}
  .p3d__time-btn{padding:0 11px 0 9px}
  .p3d__hint span{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
  .p3d__bar{right:12px;bottom:12px;gap:5px}
  .p3d__btn{width:36px;height:36px}
}
@media (prefers-reduced-motion:reduce){
  .p3d__load span{animation:none}
}
