/* Сцена может ужиматься до 75 % от Full HD (за вычетом рамок браузера: 1860 × 920).
   На ещё меньшем экране страница прокручивается, а схема дальше не уменьшается. */
:root {
  --stage-min-w: calc(1860px * 0.75);
  --stage-min-h: calc(920px * 0.75);
}

html,
body {
  margin: 0;
  background: #0a1430;
}

body {
  position: relative;
  width: max(100%, var(--stage-min-w));
  min-height: max(100svh, var(--stage-min-h));
}

#airfield {
  display: block;
  width: 100%;
  height: max(100svh, var(--stage-min-h));
  shape-rendering: crispEdges;
}

/* Временная сетка-подсказка (SHOW_GRID в scene.js) */
.debug-grid__cell {
  fill: none;
  stroke: rgb(160 185 255 / 0.035);
  stroke-width: 1;
}

.debug-grid__label {
  fill: rgb(170 190 240 / 0.55);
  font: bold 16px ui-monospace, Menlo, monospace;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgb(0 0 0 / 0.55);
  stroke-width: 2px;
  pointer-events: none;
}

/* Объекты рисуются гладко: тонкие контуры и линзы иначе рассыпаются */
.object {
  shape-rendering: geometricPrecision;
}

/* Выключенный свет: луч пропадает, линза гаснет */
.lights .off[data-lit="beam"] {
  display: none;
}

.lights .off[data-lit="lens"] {
  /* прозрачность, а не filter: Safari не применяет CSS-фильтры к элементам внутри SVG */
  opacity: 0.12;
}

.object,
.lights [data-owner] {
  cursor: pointer;
}

/* ---------- Панель огней ---------- */
.panel {
  position: absolute; /* прокручивается вместе со сценой */
  top: 16px;
  left: 16px;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid rgb(140 170 255 / 0.16);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgb(70 100 200 / 0.16), rgb(10 18 45 / 0) 60%),
    rgb(9 16 40 / 0.62);
  box-shadow:
    0 20px 50px rgb(0 0 0 / 0.45),
    inset 0 1px 0 rgb(255 255 255 / 0.06);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  color: #e6ecff;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.panel__head {
  margin-bottom: 10px;
  padding: 2px 4px 0;
}

.panel__eyebrow {
  display: block;
  margin-bottom: 2px;
  color: #7f95d6;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.panel__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel__list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel__row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgb(255 255 255 / 0.03);
  transition: background 0.2s;
}

.panel__row:hover {
  background: rgb(255 255 255 / 0.06);
}

.panel__swatch {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c1) 50%, var(--c2) 50%);
  box-shadow: 0 0 10px var(--c1), 0 0 0 2px rgb(255 255 255 / 0.08);
}

.panel__text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.panel__name {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
}

.panel__note {
  color: #8a9bcc;
  font-size: 10.5px;
  line-height: 1.3;
}

/* переключатель */
.switch {
  position: relative;
  flex: none;
  width: 30px;
  height: 17px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
  cursor: pointer;
  transition: background 0.25s;
}

.switch::after {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c9d3f5;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
  content: "";
  transition: transform 0.25s, background 0.25s;
}

.switch[aria-checked="true"] {
  background: linear-gradient(90deg, #3b6cff, #6a8dff);
  box-shadow: 0 0 14px rgb(80 120 255 / 0.55);
}

.switch[aria-checked="true"]::after {
  background: #ffffff;
  transform: translateX(13px);
}

.switch:focus-visible {
  outline: 2px solid #6a8dff;
  outline-offset: 2px;
}

/* Проблесковые огни (REIL): короткая вспышка 2 раза в секунду, все синхронно.
   Луч виден только во время вспышки, линза между вспышками тускнеет. */
@keyframes flash-beam {
  0%,
  18% {
    visibility: visible;
  }
  20%,
  100% {
    visibility: hidden;
  }
}

@keyframes flash-lens {
  0%,
  18% {
    opacity: 1;
  }
  20%,
  100% {
    opacity: 0.3;
  }
}

.lights [data-flash][data-lit="beam"]:not(.off) {
  animation: flash-beam 0.5s step-end infinite;
}

.lights [data-flash][data-lit="lens"]:not(.off) {
  animation: flash-lens 0.5s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
  .lights [data-flash]:not(.off) {
    animation-duration: 2s;
  }
}

/* «Кролик» (SFL): каждый огонь вспыхивает коротко один раз за цикл,
   задержка и длительность цикла задаются из scene.js по порядку огня. */
@keyframes seq-beam {
  0%,
  9% {
    visibility: visible;
  }
  10%,
  100% {
    visibility: hidden;
  }
}

@keyframes seq-lens {
  0%,
  9% {
    opacity: 1;
  }
  10%,
  100% {
    opacity: 0.25;
  }
}

.lights [data-seq][data-lit="beam"]:not(.off) {
  animation-name: seq-beam;
  animation-iteration-count: infinite;
  animation-timing-function: step-end;
}

.lights [data-seq][data-lit="lens"]:not(.off) {
  animation-name: seq-lens;
  animation-iteration-count: infinite;
  animation-timing-function: step-end;
}

@media (prefers-reduced-motion: reduce) {
  .lights [data-seq]:not(.off) {
    animation-play-state: paused;
  }
}

/* Заголовок панели с общим тумблером */
.panel__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.panel__all {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #8a9bcc;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Заградительный огонь средней интенсивности: красный, ~40 вспышек в минуту */
.lights [data-blink][data-lit="beam"]:not(.off) {
  animation: flash-beam 1.5s step-end infinite;
}

.lights [data-blink][data-lit="lens"]:not(.off) {
  animation: flash-lens 1.5s step-end infinite;
}

.ambient {
  pointer-events: none;
}


/* «Powered by» справа внизу, поверх моря: только надпись и логотип-ссылка, без плашки */
.credit {
  position: absolute;
  right: 20px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #8a9bcc;
  font: 500 11px/1 Inter, system-ui, -apple-system, sans-serif;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color 0.2s;
}

.credit img {
  display: block;
  height: 14px;
  width: auto;
  margin-left: 3px;
}

.credit:hover {
  color: #c9d5ff;
}

.credit:focus-visible {
  outline: 2px solid #6a8dff;
  outline-offset: 2px;
}

/* ---------- Значок (i) и попап с описанием ---------- */
.info-btn {
  display: inline-grid;
  width: 12px;
  height: 12px;
  margin-left: 5px;
  padding: 0;
  place-items: center;
  border: 1px solid rgb(140 170 255 / 0.4);
  border-radius: 50%;
  background: transparent;
  color: #9fb2ea;
  font: italic 600 8.5px/1 Georgia, serif;
  position: relative;
  top: -1px; /* по центру заглавных букв, а не строки */
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.info-btn:hover {
  border-color: #6a8dff;
  background: #3b6cff;
  color: #ffffff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgb(4 9 26 / 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none;
}

.modal__card {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px 24px 20px;
  border: 1px solid rgb(140 170 255 / 0.18);
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgb(70 100 200 / 0.16), rgb(10 18 45 / 0) 60%),
    rgb(9 16 40 / 0.88);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.06);
  color: #dfe6ff;
  font: 400 13px/1.55 Inter, system-ui, -apple-system, sans-serif;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.05);
  color: #9fb2ea;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: rgb(255 255 255 / 0.12);
  color: #ffffff;
}

.modal__head h2 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal__subtitle {
  margin: 2px 0 14px;
  color: #8a9bcc;
  font-size: 13px;
}

.modal__section {
  margin-top: 14px;
}

.modal h3 {
  margin: 0 0 4px;
  color: #7f95d6;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.modal p {
  margin: 0;
}

.modal ul {
  margin: 0;
  padding-left: 18px;
}

.modal li + li {
  margin-top: 3px;
}

.modal__note {
  margin-top: 6px !important;
  color: #8a9bcc;
  font-size: 12px;
}

.signals {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.25);
}

.signal {
  display: flex;
  align-items: center;
  gap: 14px;
}

.signal__lights {
  display: inline-flex;
  gap: 6px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot--white {
  background: #fff4d6;
  box-shadow: 0 0 8px rgb(255 244 214 / 0.8);
}

.dot--red {
  background: #ff3b2f;
  box-shadow: 0 0 8px rgb(255 59 47 / 0.8);
}

.modal__refs {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgb(140 170 255 / 0.12);
  color: #8a9bcc;
  font-size: 12px;
}

/* блок требований внизу попапа */
.modal__requirements {
  margin-top: 16px;
  padding: 2px 14px 12px;
  border: 1px solid rgb(255 210 58 / 0.25);
  border-radius: 10px;
  background: rgb(255 210 58 / 0.05);
}

.modal__requirements h3 {
  color: #ffd23a;
}

/* Демо: тумблеры в заголовке и подсветка текущей группы */
.panel__toggles {
  display: flex;
  gap: 14px;
}

.switch--demo[aria-checked="true"] {
  background: linear-gradient(90deg, #ffb020, #ffd23a);
  box-shadow: 0 0 14px rgb(255 190 40 / 0.55);
}

.panel__row--demo {
  background: rgb(255 210 58 / 0.1);
  box-shadow: inset 0 0 0 1px rgb(255 210 58 / 0.35);
}
