/* ================================================================
   tlc80 — стили карты, колод и лайтбокса
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: #0a1122;
  color: #dfe6f2;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ---------- карта: контейнер и слои ---------- */

#map {
  position: fixed;
  inset: 0;
  cursor: grab;
}
#map.drag { cursor: grabbing; }

#base,
#over {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#dn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* ---------- карта: география ---------- */

.ocean { fill: #4a74a1; }
.land  { fill: #e9e4d6; }
.land-back {
  fill: #3a4a5c;
  opacity: 0.55;
}
.grat {
  stroke: rgba(255, 255, 255, .12);
  stroke-width: .5;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.route {
  stroke: #ffe6c2;
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 2 3.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1.5px rgba(255, 220, 150, .7));
}

.rdot {
  fill: #0a1122;
  stroke: #ffe6c2;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.glab {
  fill: rgba(255, 255, 255, .4);
  font-size: 6px;
  letter-spacing: .4px;
}

/* Метка галереи: видимая точка + ореол + увеличенная прозрачная область
   попадания. Радиусы задаёт JS в единицах viewBox так, чтобы на экране они
   всегда были одного размера в пикселях — иначе на телефоне, где карта
   вписана целиком, метка была бы в пару пикселей. */
.zone { cursor: pointer; }
.zone-hit { fill: transparent; }
.zone-halo {
  fill: rgba(255, 230, 194, .22);
  pointer-events: none;
}
.zone-dot {
  fill: #ffe6c2;
  stroke: #0a1122;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.sunlab-bg { fill: rgba(30, 34, 44, .92); }
.sunlab-tx { fill: #eef2fa; font-size: 6px; }

/* ---------- шапка и легенда ---------- */

header {
  position: absolute;
  z-index: 6;
  top: 18px;
  left: 24px;
  background: rgba(10, 17, 34, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 16px;
  backdrop-filter: blur(6px);
}

.wordmark {
  color: #ffffff;
  font-size: 22px;
  letter-spacing: .3em;
  text-shadow: 0 0 12px rgba(120, 160, 255, .4);
}

.sub {
  color: #d6e0f5;
  opacity: 1;
  font-size: 14px;
  letter-spacing: .1em;
  margin-left: 12px;
}

.legend {
  position: absolute;
  z-index: 6;
  top: 48px;
  right: 24px;
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: #c2cfe6;
  letter-spacing: .05em;
  align-items: center;
}

.grid-toggle {
  position: absolute;
  z-index: 6;
  top: 18px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #c2cfe6;
  letter-spacing: .05em;
  cursor: pointer;
  user-select: none;
}

/* Скрываем нативный чекбокс, но оставляем его в DOM для доступности и
   для существующей JS-логики (gridToggleEl.checked) — сам тумблер рисуем
   span'ами рядом, переключая их вид через :checked + селектор. */
.grid-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.grid-toggle .switch {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .25);
  transition: background .18s ease;
  flex: none;
}

.grid-toggle .knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cfe0ff;
  transition: transform .18s ease;
}

.grid-toggle input:checked + .switch {
  background: #4c6fd6;
  border-color: #6c8cd6;
}

.grid-toggle input:checked + .switch .knob {
  transform: translateX(16px);
  background: #fff;
}

.grid-toggle input:focus-visible + .switch {
  outline: 2px solid #8fb0ff;
  outline-offset: 2px;
}

.legend i {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -2px;
}

.clock {
  position: absolute;
  z-index: 6;
  bottom: 16px;
  left: 24px;
  color: #9fb4d6;
  font-size: 12px;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.hint {
  position: absolute;
  z-index: 6;
  bottom: 16px;
  right: 24px;
  color: #6c80a4;
  font-size: 11px;
}

/* ---------- колода фотографий при наведении ---------- */

#deck {
  position: absolute;
  z-index: 8;
  /* Размер карточки задаётся здесь, а габариты колоды и центрирующие
     отрицательные поля выводятся из него — тогда на узком экране достаточно
     переопределить две переменные, и всё остальное сойдётся само. */
  --cw: 420px;
  --ch: 315px;
  width: calc(var(--cw) + 40px);
  height: calc(var(--ch) + 65px);
  display: none;
  pointer-events: none;
}

#deck.on { display: block; }

#deck .card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cw);
  height: var(--ch);
  margin: calc(var(--ch) / -2) 0 0 calc(var(--cw) / -2);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .6);
  background: #0a1122;
  transform-origin: center;
  will-change: transform, opacity;
  transition:
  transform .25s cubic-bezier(.22, .61, .36, 1),
  opacity   .25s cubic-bezier(.22, .61, .36, 1);
}

#deck .card img,
#deck .card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#deck .card .playbadge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(10, 17, 34, .55);
  color: #fff;
  font-size: 16px;
  pointer-events: none;
}

#deck .cnt {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(10, 17, 34, .75);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  color: #cfe0ff;
}

/* ---------- лайтбокс (клик по фото — во весь экран) ---------- */

#lb {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 8, 18, .94);
  display: none;
  align-items: center;
  justify-content: center;
}

#lb.on { display: flex; }

#lb img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 8px;
  cursor: zoom-out;
}

#lb video {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 8px;
}

#lb .x {
  position: absolute;
  top: 16px;
  right: 22px;
  color: #dfe6f2;
  font-size: 30px;
  cursor: pointer;
}
/* Карта, колода фото и лайтбокс — интерактивные поверхности, а не текст.
   Без этого протяжка мышью по фотографии начинает обычное выделение: оно
   подсвечивает картинку вместе с крестиком, а жест «нажал-протянул-отпустил»
   по крестику перестаёт давать click, и лайтбокс выглядит зависшим. */
#map, #map *,
#deck, #deck *,
#lb, #lb * {
  -webkit-user-drag: none;
  user-select: none;
}

/* Без этого браузер на тач-экране считает протяжку по карте прокруткой
   страницы или жестом зума и просто не отдаёт нам pointermove. */
#map, #deck, #lb {
  touch-action: none;
}
img {
  -webkit-user-drag: none;
}

/* Солнце за горизонтом Земли — холодный серый вид с полупрозрачностью.
   Класс .behind вешается на сам #sundef (источник в <defs>), а не на
   <use>, — иначе <use> не создаёт реальных DOM-потомков и селекторы
   вида .sunuse.behind circle ничего не находят. */
#sundef.behind circle:nth-child(1),
#sundef.behind circle:nth-child(2),
#sundef.behind circle:nth-child(3) {
  fill: rgba(160, 172, 190, 0.15);
}
#sundef.behind circle:nth-child(4) {
  fill: rgba(200, 208, 220, 0.55);
}
#sundef.behind rect.sunlab-bg {
  fill: rgba(60, 66, 80, 0.35);
}
#sundef.behind text.sunlab-tx {
  fill: rgba(220, 226, 240, 0.55);
}

/* ================================================================
   Адаптив: телефоны и невысокие экраны
   ================================================================ */

/* Узкий экран: легенда и отладочный слайдер убираются, чтобы не налезать
   на шапку и не отъедать место, карточка фото ужимается под ширину экрана,
   а часы с подсказкой уходят вниз по центру в одну колонку. */
@media (max-width: 700px) {
  header {
    top: 10px;
    left: 12px;
    padding: 6px 12px;
  }
  .wordmark { font-size: 17px; letter-spacing: .22em; }
  .sub      { font-size: 11px; margin-left: 8px; }

  .legend, #debugPanel { display: none; }

  .grid-toggle { top: 12px; right: 12px; }

  #deck { --cw: 86vw; --ch: 64.5vw; }

  .clock, .hint {
    left: 12px;
    right: 12px;
    text-align: center;
  }
  .clock { bottom: 30px; font-size: 11px; }
  .hint  { bottom: 12px; font-size: 10px; }

  /* Крестик закрытия должен быть пальцем попадаемым, а не 30px глифом. */
  #lb .x {
    top: 8px;
    right: 8px;
    padding: 8px 14px;
    font-size: 28px;
  }
}

/* Невысокий экран (телефон в ландшафте): вертикального места почти нет —
   колода 380px туда не влезает, слайдер тем более. */
@media (max-height: 520px) {
  #deck { --cw: 46vw; --ch: 34.5vw; }
  #debugPanel { display: none; }
  .clock, .hint { font-size: 10px; }
}
