/* Страница «3D умного дома» (/napravleniya/umnyj-dom/): живая квартира — assets/js/smarthome.js,
   модель — assets/models/apartment.glb (сцена Blender: tools/3d/apartment/apartment.py). Язык — owl.css. */

.dh-hero { padding-bottom: clamp(28px, 3vw, 56px); }
.dh-hero__top { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 22px; }
.dh-hero__crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: var(--o-fs-ui); text-transform: uppercase; color: var(--o-mut); }
.dh-hero__crumbs a:hover { color: var(--o-fg); }

/* ---------- сцена ---------- */
.sh { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: min(88vh, 880px); min-height: 560px; border-block: 1px solid var(--o-line); background: #0d1011; }
.sh__stage { position: relative; overflow: hidden; background: radial-gradient(120% 90% at 55% 40%, #1c2224 0%, #0d1011 70%); touch-action: pan-y; }
.sh__poster, .sh__gl { position: absolute; inset: 0; width: 100%; height: 100%; }
.sh__poster { object-fit: contain; object-position: 50% 52%; padding: 4% 3% 9%; transition: opacity .8s var(--o-ease), filter .8s var(--o-ease); }
.sh__gl { opacity: 0; transition: opacity .9s var(--o-ease); outline: none; }
.sh__stage[data-state="ready"] .sh__gl { opacity: 1; }
.sh__stage[data-state="ready"] .sh__poster { opacity: 0; filter: blur(6px); pointer-events: none; }
.sh__stage[data-state="ready"] .sh__gl { cursor: grab; }
.sh__stage[data-state="ready"] .sh__gl:active { cursor: grabbing; }
.sh__stage.is-hot .sh__gl { cursor: pointer; }

.sh__load { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; padding: 8px 14px; border-radius: 999px; background: rgba(18, 22, 23, .78); font-size: 13px; text-transform: uppercase; color: var(--o-mut); transition: opacity .5s; }
.sh__load b { display: block; width: 90px; height: 2px; background: var(--o-line); overflow: hidden; }
.sh__load b i { display: block; height: 100%; width: var(--p, 0%); background: var(--o-yellow); transition: width .3s; }
.sh__stage[data-state="ready"] .sh__load, .sh__stage[data-state="fallback"] .sh__load { opacity: 0; pointer-events: none; }
.sh__stage[data-state="idle"] .sh__load { opacity: 0; }

/* сценарии и кнопки камеры */
.sh__top { position: absolute; z-index: 3; left: 14px; right: 14px; top: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.sh__top > * { pointer-events: auto; }
.sh__lbl { margin-right: 4px; font-size: 12px; text-transform: uppercase; color: var(--o-mut); }
.sh-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 13px; border: 1.5px solid rgba(237, 233, 232, .38); border-radius: 999px; background: rgba(18, 22, 23, .62); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 14px; text-transform: uppercase; letter-spacing: -.01em; cursor: pointer; transition: background .3s var(--o-ease), color .3s var(--o-ease), border-color .3s var(--o-ease); }
.sh-btn:hover { border-color: var(--o-fg); }
.sh-btn[aria-pressed="true"], .sh-btn.is-on { background: var(--o-yellow); border-color: var(--o-yellow); color: var(--o-ink); }
.sh-btn i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
.sh-btn[aria-pressed="true"] i { opacity: 1; animation: sh-blink 1.2s infinite; }
.sh__cam { position: absolute; z-index: 3; right: 14px; bottom: 14px; display: flex; gap: 6px; }
.sh__cam .sh-btn { width: 38px; justify-content: center; padding: 0; font-size: 18px; }
.sh__cam .sh-btn--wide { width: auto; padding: 0 12px; font-size: 13px; }
.sh__hint { position: absolute; z-index: 2; left: 14px; bottom: 16px; max-width: 46%; font-size: 13px; color: var(--o-mut); text-transform: uppercase; transition: opacity .6s; }
.sh__stage.is-touched .sh__hint { opacity: 0; }

/* метки датчиков */
.sh__pins { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.sh-pin { position: absolute; left: 0; top: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; transition: opacity .3s; }
.sh-pin::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--o-yellow); box-shadow: 0 0 0 2px rgba(18, 22, 23, .7); }
.sh-pin::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid var(--o-yellow); opacity: 0; animation: sh-ring 2.6s var(--o-ease) infinite; animation-delay: var(--d, 0s); }
.sh-pin span { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 4px); white-space: nowrap; padding: 4px 8px; border-radius: 999px; background: var(--o-fg); color: var(--o-ink); font-size: 12px; text-transform: uppercase; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s var(--o-ease); }
.sh-pin:hover span, .sh-pin:focus-visible span, .sh-pin.is-sel span { opacity: 1; transform: translate(-50%, -2px); }
.sh-pin.is-alarm::before { background: #FF5A4E; }
.sh-pin.is-alarm::after { border-color: #FF5A4E; animation-duration: .9s; }
.sh-pin.is-hidden { opacity: 0; pointer-events: none; }
.sh__stage.no-pins .sh-pin { opacity: 0; pointer-events: none; }

/* уведомления как на телефоне */
.sh__toasts { position: absolute; z-index: 4; right: 14px; top: 60px; width: min(320px, calc(100% - 28px)); display: grid; gap: 8px; pointer-events: none; }
.sh-toast { display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; padding: 11px 13px; border-radius: 16px; background: rgba(237, 233, 232, .94); color: var(--o-ink); font-size: 14px; line-height: 1.3; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: sh-toast-in .55s var(--o-ease) both; }
.sh-toast.is-out { animation: sh-toast-out .45s var(--o-ease) both; }
.sh-toast i { grid-row: span 2; width: 28px; height: 28px; border-radius: 9px; background: var(--o-ink); position: relative; }
.sh-toast i::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--o-yellow); }
.sh-toast--alarm i::after { background: #FF5A4E; }
.sh-toast b { font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--o-ink-mut); }

/* панель: карточка устройства и список по комнатам */
.sh__panel { position: relative; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--o-line); background: var(--o-bg); }
.sh__card { padding: 18px 18px 16px; border-bottom: 1px solid var(--o-line); }
.sh__card[hidden] { display: none; }
.sh__room { font-size: 12px; text-transform: uppercase; color: var(--o-mut); }
.sh__name { margin-top: 6px; font-size: 22px; font-weight: 500; text-transform: uppercase; letter-spacing: -.02em; line-height: 1.05; }
.sh__text { margin-top: 10px; font-size: 15px; line-height: 1.4; color: #CFCAC8; }
.sh__state { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.sh__state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9FE0B0; }
.sh__state.is-on::before { background: var(--o-yellow); }
.sh__state.is-alarm::before { background: #FF5A4E; animation: sh-blink .8s infinite; }
.sh__acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.sh__intro { padding: 18px; border-bottom: 1px solid var(--o-line); font-size: 15px; line-height: 1.4; color: #CFCAC8; }
.sh__intro b { color: var(--o-fg); font-weight: 500; }
.sh__list { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 4px 0 14px; scrollbar-width: thin; scrollbar-color: rgba(237, 233, 232, .2) transparent; }
.sh__grp { padding: 12px 18px 4px; font-size: 12px; text-transform: uppercase; color: var(--o-mut); display: flex; justify-content: space-between; }
.sh__item { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; width: 100%; min-height: 40px; padding: 6px 18px; border: 0; background: none; text-align: left; font-size: 15px; cursor: pointer; transition: background .25s; }
.sh__item:hover, .sh__item[aria-current="true"] { background: rgba(237, 233, 232, .07); }
.sh__item i { width: 8px; height: 8px; border-radius: 50%; background: #5d6466; transition: background .3s; }
.sh__item.is-on i { background: var(--o-yellow); }
.sh__item.is-alarm i { background: #FF5A4E; animation: sh-blink .8s infinite; }
.sh__item small { font-size: 12px; color: var(--o-mut); text-transform: uppercase; }

@keyframes sh-ring { 0% { transform: scale(.6); opacity: .9; } 70%, 100% { transform: scale(1.7); opacity: 0; } }
@keyframes sh-blink { 50% { opacity: .25; } }
@keyframes sh-toast-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes sh-toast-out { to { opacity: 0; transform: translateX(30px); } }

@media (max-width: 999px) {
  .sh { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .sh__stage { height: min(78vh, 640px); min-height: 420px; }
  .sh__panel { border-left: 0; border-top: 1px solid var(--o-line); }
  .sh__list { max-height: 360px; }
  .sh__hint { max-width: 60%; }
}
@media (max-width: 559px) {
  .sh__stage { height: 74vh; min-height: 400px; }
  .sh__top { left: 0; right: 0; top: 10px; gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding: 0 10px; scrollbar-width: none; }
  .sh__top::-webkit-scrollbar { display: none; }
  .sh__top .sh-btn { flex: none; }
  .sh__lbl { display: none; }
  .sh-btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
  .sh__toasts { top: auto; bottom: 62px; right: 10px; width: calc(100% - 20px); }
  .sh__hint { display: none; }
  .sh__cam { right: 10px; bottom: 10px; }
}

/* ---------- как это работает ---------- */
.dh-how__head { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(20px, 4vw, 80px); align-items: end; margin-bottom: clamp(30px, 4vw, 70px); }
.dh-how__h { font-size: var(--o-fs-h2); }
.dh-how__p { max-width: 30em; font-size: clamp(17px, 1.4vw, 24px); line-height: 1.38; color: #CFCAC8; }
.dh-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--o-line); }
.dh-step { padding: 22px 22px 26px 0; border-right: 1px solid var(--o-line); }
.dh-step + .dh-step { padding-left: 22px; }
.dh-step:last-child { border-right: 0; }
.dh-step__n { font-size: 12px; color: var(--o-mut); }
.dh-step__t { margin-top: 40px; font-size: clamp(20px, 1.7vw, 30px); font-weight: 500; text-transform: uppercase; letter-spacing: -.02em; line-height: 1.05; }
.dh-step__p { margin-top: 12px; font-size: 16px; line-height: 1.42; color: #CFCAC8; }
@media (max-width: 999px) {
  .dh-how__head { grid-template-columns: 1fr; }
  .dh-steps { grid-template-columns: 1fr 1fr; }
  .dh-step { padding: 20px 16px 22px 0 !important; border-right: 0; border-bottom: 1px solid var(--o-line); }
  .dh-step:nth-child(odd) { border-right: 1px solid var(--o-line); }
  .dh-step:nth-child(even) { padding-left: 16px !important; }
  .dh-step__t { margin-top: 22px; }
}
@media (max-width: 559px) { .dh-steps { grid-template-columns: 1fr; } .dh-step:nth-child(odd) { border-right: 0; } .dh-step:nth-child(even) { padding-left: 0 !important; } }

/* ---------- что в квартире (список для чтения и без JS) ---------- */
.dh-dev { border-top: 1px solid var(--o-line); }
.dh-dev__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 2vw, 32px); margin-top: clamp(26px, 3vw, 50px); }
.dh-dev__room { font-size: var(--o-fs-ui); text-transform: uppercase; padding-bottom: 10px; border-bottom: 1px solid var(--o-line); }
.dh-dev__room small { color: var(--o-mut); font-size: 1em; }
.dh-dev ul { margin-top: 10px; display: grid; gap: 8px; font-size: 16px; line-height: 1.35; color: #CFCAC8; }
.dh-dev li::before { content: "— "; color: var(--o-mut); }
@media (max-width: 999px) { .dh-dev__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 559px) { .dh-dev__grid { grid-template-columns: 1fr; } }

/* ---------- статус и соседние направления ---------- */
.dh-note { margin-top: clamp(26px, 3vw, 46px); max-width: 44em; font-size: 14px; color: var(--o-mut); line-height: 1.45; }
.dh-nav { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--o-line); }
.dh-nav a { display: grid; gap: 8px; padding: clamp(24px, 3vw, 48px) var(--o-pad); transition: background .4s var(--o-ease), color .4s var(--o-ease); }
.dh-nav a + a { border-left: 1px solid var(--o-line); text-align: right; }
.dh-nav a:hover { background: var(--o-fg); color: var(--o-ink); }
.dh-nav small { font-size: var(--o-fs-ui); text-transform: uppercase; color: var(--o-mut); }
.dh-nav a:hover small { color: var(--o-ink-mut); }
.dh-nav span { font-size: clamp(24px, 3vw, 54px); font-weight: 500; text-transform: uppercase; letter-spacing: -.03em; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  .sh-pin::after, .sh-btn[aria-pressed="true"] i, .sh__item.is-alarm i, .sh__state.is-alarm::before { animation: none; }
  .sh-toast, .sh-toast.is-out { animation: none; }
}

/* подсказка: мышь или касание */
.sh__hint .for-touch { display: none; }
.sh__stage.is-touch .sh__hint .for-mouse { display: none; }
.sh__stage.is-touch .sh__hint .for-touch { display: inline; }
@media (max-width: 559px) { .sh__stage.is-touch .sh__hint { display: block; left: 10px; right: 10px; bottom: 56px; max-width: none; font-size: 12px; } }
