/* ==========================================================================
   map.css: раскладка страницы карты и окно 3D-просмотра
   ========================================================================== */

/* Шапка страницы: заголовок и кнопки в одну строку, под ними — короткая подсказка */
.p-head--map { padding-block: clamp(16px, 2.2vw, 26px) clamp(14px, 1.8vw, 22px); }
.map-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.map-head .eyebrow { margin-bottom: 8px; }
.p-head--map h1 { font-size: clamp(2.1rem, 4.6vw, 3.4rem); }
.map-head__acts { flex: none; padding-bottom: 5px; }
.map-head__lead { max-width: 860px; margin-top: 10px; color: var(--muted); font-size: 1.04rem; }

/* Высоту блока подставляет скрипт: карта заканчивается ровно на нижней границе экрана */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: calc(100vh - var(--header-h) - 182px); min-height: 440px; max-height: 920px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.map-box { position: relative; isolation: isolate; min-width: 0; }
#map { position: absolute; inset: 0; background: #E7E2D6; outline: none; }
.map-tools { position: absolute; z-index: 500; top: 14px; left: 14px; right: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.map-tools > * { pointer-events: auto; }
.seg--map { background: rgba(255, 253, 248, .96); box-shadow: var(--shadow-sm); }
.seg--map button { display: inline-flex; align-items: center; gap: 6px; }
.seg--map .ico { width: 1.05em; height: 1.05em; }
.map-tools__col { display: flex; gap: 8px; }
.map-btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(255, 253, 248, .96); color: var(--ink); font-weight: 600; font-size: .86rem; box-shadow: var(--shadow-sm); transition: background-color var(--t), color var(--t), transform var(--t); }
.map-btn .ico { color: var(--red); }
.map-btn:hover { transform: translateY(-1px); }
.map-btn[aria-pressed="true"] { background: var(--volga); color: #fff; }
.map-btn[aria-pressed="true"] .ico { color: var(--gold-2); }
.map-legend { position: absolute; z-index: 500; left: 14px; top: 64px; max-width: 300px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 253, 248, .96); box-shadow: var(--shadow-sm); font-size: .84rem; }
.map-legend b { display: block; margin-bottom: 6px; font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; }
.map-legend ul { margin: 0; padding-left: 16px; color: var(--ink-2); }
.map-toast { position: absolute; z-index: 500; left: 50%; bottom: 26px; display: inline-flex; align-items: center; gap: 10px; transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: .88rem; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-md); transition: opacity .4s, visibility .4s; }
.map-toast .ico { color: var(--gold-2); }
.map-toast.is-hidden { opacity: 0; visibility: hidden; }

/* Метки */
.marker { background: transparent; border: 0; }
.mk { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 2.5px solid #fff; border-radius: 50% 50% 50% 0; background: var(--c, var(--volga)); box-shadow: 0 5px 14px rgba(0, 0, 0, .38); transform: rotate(-45deg); transition: transform .22s var(--ease), background-color .22s; }
/* номер остановки маршрута: метка повёрнута на −45°, поэтому значок поворачиваем обратно и сдвигаем в правый верхний угол */
.mk__n { position: absolute; left: 100%; top: 50%; min-width: 20px; height: 20px; margin: -10px 0 0 -9px; padding: 0 5px; border-radius: 10px; background: var(--red); border: 2px solid #fff; color: #fff; font: 700 .72rem/16px var(--font-ui); text-align: center; transform: rotate(45deg); }
.mk .ico { width: 19px; height: 19px; color: #fff; transform: rotate(45deg); stroke-width: 2; }
.marker:hover .mk, .marker:focus-visible .mk { transform: rotate(-45deg) scale(1.18); background: var(--red); }
.mk--active { background: var(--red) !important; transform: rotate(-45deg) scale(1.28); z-index: 1000; box-shadow: 0 0 0 6px rgba(181, 52, 31, .28), 0 8px 20px rgba(0, 0, 0, .4); }
.mk--route { width: 30px; height: 30px; border-radius: 50%; transform: none; background: var(--red); color: #fff; font-family: var(--font-display); font-size: 1.05rem; line-height: 1; }
.mk--route:hover .mk { transform: scale(1.2); }
.marker-cluster { background-clip: padding-box; border-radius: 50%; }
.marker-cluster div { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-family: var(--font-ui); font-weight: 700; font-size: .86rem; color: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.marker-cluster-small { background-color: rgba(31, 92, 107, .25); }
.marker-cluster-small div { background-color: var(--cat-museum); }
.marker-cluster-medium { background-color: rgba(23, 63, 79, .25); }
.marker-cluster-medium div { background-color: var(--volga); }
.marker-cluster-large { background-color: rgba(181, 52, 31, .25); }
.marker-cluster-large div { background-color: var(--red); }
.geo-dot { width: 18px; height: 18px; border-radius: 50%; background: #1E88E5; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(30, 136, 229, .22); }

/* Боковая панель */
.map-side { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border-left: 1px solid var(--line); }
.map-side .seg { margin: 14px 16px 0; justify-content: center; display: flex; }
.map-side .seg button { flex: 1; }
.chips--x { flex: none; flex-wrap: nowrap; overflow-x: auto; margin: 12px 0 0; padding: 4px 16px 8px; gap: 8px; scrollbar-width: thin; }
.chips--x .chip { flex: none; }
.chips--x::-webkit-scrollbar { display: none; }
.chips--x { scrollbar-width: none; }
/* Лента типов мест: полоса прокрутки скрыта, справа плашки плавно уходят в фон — видно, что за краем есть ещё.
   Листается колёсиком мыши (класс wheel-x) или свайпом. */
#cat-chips { padding-right: 40px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
.map-side__count { flex: none; padding: 2px 18px 10px; color: var(--muted); font-size: .84rem; border-bottom: 1px solid var(--line); }
.map-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 10px 18px; }
.map-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 14px; background: none; text-align: left; color: var(--ink); transition: background-color var(--t); }
.map-item:hover { background: var(--paper-2); }
.map-item.is-active { background: var(--gold-soft); }
.map-item__ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--paper-2); background: color-mix(in srgb, var(--c) 15%, #fff); color: var(--c); }
.map-item__ic .ico { width: 21px; height: 21px; }
.map-item b { display: block; font-weight: 600; font-size: .93rem; line-height: 1.3; }
.map-item small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.map-item__go { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: .74rem; font-weight: 600; opacity: 0; transform: translateX(6px); transition: opacity var(--t), transform var(--t); }
.map-item:hover .map-item__go, .map-item.is-active .map-item__go, .map-item:focus-visible .map-item__go { opacity: 1; transform: none; }
.map-item__go .ico { width: .95em; height: .95em; }

/* ---------- Окно 3D-просмотра ---------- */
body.pano-open { overflow: hidden; }
.pano { position: fixed; inset: 0; z-index: 1100; display: flex; flex-direction: column; background: var(--volga-ink); color: #fff; opacity: 0; visibility: hidden; transform: scale(.96); transition: opacity .35s, transform .45s var(--ease), visibility .45s; }
.pano.is-open { opacity: 1; visibility: visible; transform: none; }
.pano__stage { position: absolute; inset: 0; z-index: 1; }
.pano__stage iframe, .pano__stage > img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Снимок места: большая копия целиком, в промежутке между панелями — без обрезки и без наезда */
.pano__photo { position: absolute; left: 0; right: 0; top: var(--pt, 74px); bottom: var(--pb, 72px); overflow: hidden; background: radial-gradient(80% 80% at 50% 45%, #1B4456, var(--volga-ink)); }
.pano__photo-img { position: absolute; inset: 0; display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; opacity: 0; transition: opacity .3s; box-shadow: 0 30px 70px rgba(0, 0, 0, .55); }
.pano__photo-img.is-ready { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .pano__photo-img { transition: none; } }
.pano__map { position: absolute; inset: 0; background: #E9E4D8; }
.pano__ext { position: absolute; z-index: 500; left: 14px; top: 106px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(13, 40, 51, .78); color: #fff; font-size: .78rem; font-weight: 600; }
.pano__ext:hover { background: var(--volga-ink); color: #fff; }
.pano__load { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: radial-gradient(60% 60% at 50% 45%, #22556A, var(--volga-ink)); color: rgba(255, 255, 255, .85); font-weight: 500; transition: opacity .5s, visibility .5s; }
.pano__load.is-hidden { opacity: 0; visibility: hidden; }
.spinner { width: 46px; height: 46px; border: 3px solid rgba(255, 255, 255, .18); border-top-color: var(--gold-2); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pano__bar { position: relative; z-index: 4; display: flex; align-items: center; gap: 16px; padding: 12px clamp(12px, 2vw, 24px); background: linear-gradient(180deg, rgba(13, 40, 51, .92), rgba(13, 40, 51, .78)); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.pano__bar--bottom { margin-top: auto; flex-wrap: wrap; align-items: center; justify-content: space-between; background: linear-gradient(0deg, rgba(13, 40, 51, .95), rgba(13, 40, 51, .8)); }
.pano__back { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 9px 14px 9px 10px; border: 1.5px solid rgba(255, 255, 255, .35); border-radius: 999px; background: rgba(255, 255, 255, .08); color: #fff; font-weight: 600; font-size: .9rem; transition: background-color var(--t), border-color var(--t); }
.pano__back:hover { background: rgba(255, 255, 255, .18); border-color: var(--gold-2); color: #fff; }
.pano__t { flex: 1; min-width: 0; }
.pano__t .badge { position: static; box-shadow: none; margin-bottom: 6px; }
.pano__t h2 { overflow: hidden; color: #fff; font-size: clamp(1.5rem, 3vw, 2.3rem); text-overflow: ellipsis; white-space: nowrap; }
.pano__nav { display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.pano__nav button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: #fff; transition: background-color var(--t); }
.pano__nav button:hover { background: rgba(255, 255, 255, .18); }
.pano__nav span { min-width: 48px; text-align: center; font-size: .88rem; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .85); }
.pano__lead { flex: 1 1 380px; margin: 0; max-width: 760px; font-size: .94rem; line-height: 1.5; color: rgba(255, 255, 255, .9); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pano__lead[hidden], .pano__note[hidden] { display: none; }
.pano__note { position: relative; flex: 1 1 380px; margin: 0; max-width: 760px; padding-left: 34px; font-size: .94rem; line-height: 1.5; color: #fff; }
.pano__note .ico { position: absolute; left: 0; top: 3px; width: 22px; height: 22px; color: var(--gold-2); }
.pano .seg button:disabled { opacity: .4; cursor: not-allowed; }
.pano__acts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pano .seg { background: rgba(255, 255, 255, .12); }
.pano .seg button { display: inline-flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, .85); }
.pano .seg button.is-active { background: #fff; color: var(--ink); }
.pano__credit { position: absolute; z-index: 4; right: 14px; top: 106px; max-width: 46%; padding: 4px 10px; border-radius: 8px; background: rgba(13, 40, 51, .55); color: rgba(255, 255, 255, .72); font-size: .7rem; text-align: right; }
.pano__credit a { color: inherit; text-decoration: underline; }

@media (max-width: 1100px) {
  .map-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 900px) {
  /* блок карты больше не фиксированной высоты: список мест должен полностью входить в страницу, а не «выливаться» из неё под нижнюю панель */
  .map-layout { display: block; height: auto; min-height: 0; max-height: none; }
  .map-box { height: min(62vh, 520px); min-height: 360px; }
  .map-side { border-left: 0; border-top: 1px solid var(--line); }
  .map-list { max-height: none; overflow: visible; }
  .map-item__go { opacity: 1; transform: none; }
  .map-btn span { display: none; }
  .map-btn { width: 38px; padding: 0; justify-content: center; }
  .map-legend { max-width: calc(100% - 28px); }
  .map-head__lead { margin-top: 4px; }
}
@media (max-width: 640px) {
  .map-head__acts { width: 100%; padding-bottom: 0; margin-top: 2px; }
  .map-head__acts .btn { flex: 1 1 auto; }
  .map-tools { top: 10px; left: 10px; right: 10px; }
  .seg--map button { padding: 7px 12px; font-size: .8rem; }
  .map-toast { white-space: normal; text-align: center; width: calc(100% - 20px); border-radius: 14px; bottom: 12px; }
  .pano__bar { gap: 10px; padding: 10px; }
  .pano__t h2 { font-size: 1.15rem; line-height: 1.2; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .pano__t .badge { display: none; }
  .pano__back span { display: none; }
  .pano__back { padding: 9px; }
  .pano__nav button { width: 34px; height: 34px; }
  .pano__nav span { min-width: 40px; }
  .pano__lead { flex-basis: 100%; -webkit-line-clamp: 3; }
  .pano__note { flex-basis: 100%; font-size: .88rem; }
  .pano__ext, .pano__credit { top: 64px; }
  .pano__credit { max-width: 62%; font-size: .62rem; }
  .pano__acts { width: 100%; justify-content: space-between; }
  .map-box { height: 58vh; min-height: 340px; }
}
