/* Атлас Луны поверх общих стилей 3D-страниц (style.css): поиск, панель «Луна сейчас», карточка образования,
   инструменты, календарь фаз, глобус и подписи образований. Подписи на Луне — светлые в любой теме. */

#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#overlay .eyepiece { fill: none; stroke: #ffb06b; stroke-width: 1.5; stroke-dasharray: 6 5; opacity: 0.85; }
#overlay .eyepiece-label { fill: #ffb06b; font: 11px var(--mono); text-anchor: middle; }
#overlay .measure-label { fill: #ffd27a; font: 600 13px var(--mono); text-anchor: middle; paint-order: stroke; stroke: rgba(0, 0, 0, 0.75); stroke-width: 3px; }

/* ── поиск образований: как поиск на карте неба ── */
#search-box { position: relative; width: 300px; }
.search-i { position: absolute; z-index: 1; left: 13px; top: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
#search {
  width: 100%; height: 42px; padding: 0 14px 0 38px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--fg); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#search::placeholder { color: var(--muted); }
#search-results {
  top: calc(100% + 6px); left: 0; width: min(340px, calc(100vw - 32px)); z-index: 30;
  list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow: auto; border-radius: 16px; background: var(--surface-solid);
}
#search-results button {
  width: 100%; display: grid; gap: 1px; text-align: left; background: none; border: 0; border-radius: 10px; padding: 7px 10px; color: var(--fg);
}
#search-results button:hover, #search-results button.active { background: var(--surface-2); }
#search-results b { font-weight: 700; }
#search-results span { font-size: 12.5px; color: var(--muted); }
#search-results .none { padding: 8px 10px; color: var(--muted); }

/* ── всплывающие панели атласа ── */
#viewpop, #layers, #tools, #calendar, #about {
  right: calc(var(--edge-r) + 52px); top: var(--top); width: min(330px, calc(100% - var(--edge) - var(--edge-r) - 52px));
  max-height: calc(100% - var(--top) - var(--above-dock)); overflow: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 4px;
}
#about { width: min(420px, calc(100% - var(--edge) - var(--edge-r) - 52px)); display: block; }
#viewpop .seg, .light-seg { align-self: flex-start; }
#viewpop .seg button, .light-seg button { padding: 7px 12px; font-size: 13px; }
#viewpop .link { margin-top: 4px; }
#tools input { padding: 8px 9px; border-radius: 10px; }

/* ── инструменты ── */
#measure-btn { align-self: flex-start; }
#measure-btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.measure-km { font: 500 26px/1.2 var(--mono); color: #ffd27a; margin-top: 4px; }
#measure-out .hint { margin: 2px 0 6px; }
.profile { width: 100%; height: 90px; display: block; background: rgba(0, 0, 0, .28); border-radius: 10px; }
.profile .line { fill: none; stroke: #ffd27a; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.profile .fill { fill: rgba(255, 210, 122, 0.14); stroke: none; }
.prof-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.fov-row { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.fov-row input { width: 84px; font-family: var(--mono); }
.fov-row span { color: var(--muted); font-size: 13.5px; }
.fov-presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.fov-presets .chip { padding: 6px 11px; font-size: 12.5px; }

/* ── календарь фаз ── */
#calendar { width: min(340px, calc(100% - var(--edge) - var(--edge-r) - 52px)); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head .icon-btn { width: 34px; height: 34px; font-size: 18px; }
#cal-title { font: 800 19px/1.2 var(--display); }
#cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 6px; }
#cal-grid .dow { text-align: center; font: 800 10.5px/1 var(--body); color: var(--faint); letter-spacing: .06em; padding-bottom: 3px; }
#cal-grid button {
  display: grid; justify-items: center; gap: 1px; padding: 4px 0 2px; border: 1px solid transparent; border-radius: 10px;
  background: none; font: 11px var(--mono); color: var(--muted);
}
#cal-grid button:hover { background: var(--surface-2); color: var(--fg); }
#cal-grid button.today span { color: var(--accent); font-weight: 600; }
#cal-grid button.cur { border-color: var(--accent); color: var(--fg); }
#cal-phases { list-style: none; margin: 6px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 4px; font-size: 13.5px; }
#cal-phases li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; }
#cal-phases .link { padding: 0; font-size: 12.5px; }

/* пиктограмма фазы: светлая часть — Луна, тёмная — нейтральная */
.phase .dark { fill: #2b2c31; stroke: rgba(255, 255, 255, 0.22); stroke-width: 0.8; }
.phase .lit { fill: #eee6cf; }

/* ── панель «Луна сейчас»: слева, под поиском ── */
#ephem {
  left: var(--edge); top: calc(var(--top) + 52px); width: 290px;
  max-height: calc(100% - var(--top) - 52px - var(--above-dock)); display: flex; flex-direction: column; overflow: hidden;
}
#ephem.collapsed { width: auto; }
#ephem.collapsed #ephem-body { display: none; }
#ephem-body { padding: 0 14px 12px; overflow: auto; overscroll-behavior: contain; }
.phase-row { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.phase-row b { display: block; font: 800 19px/1.15 var(--display); }
#phase-pct { font-size: 12px; color: var(--muted); }
#ephem-list { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
#ephem-list dt { color: var(--muted); cursor: help; }
#ephem-list dd { margin: 0; text-align: right; font: 500 12px/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.pop-h.sub { padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--line); }
#events-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 1px; }
#events-list button {
  width: 100%; display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; color: var(--fg);
  background: none; border: 0; border-radius: 10px; padding: 5px 6px; text-align: left; font-size: 13px;
}
#events-list button:hover { background: var(--surface-2); }
#events-list b { font-weight: 700; }
#events-list small { display: block; font-size: 11.5px; color: var(--muted); }
#events-list .mono { font-size: 11.5px; color: var(--muted); }
.apsis { display: inline-grid; place-items: center; width: 18px; height: 18px; color: var(--accent); font-size: 13px; }

/* ── у терминатора ── */
#term-list { list-style: none; margin: 6px 0 8px; padding: 0; display: grid; gap: 1px; }
#term-list button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: var(--fg);
  background: none; border: 0; border-radius: 10px; padding: 4px 6px; text-align: left; font-size: 13px;
}
#term-list button:hover { background: var(--surface-2); color: var(--accent); }
#term-list b { font-weight: 700; }
#term-list .mono { font-size: 11px; color: var(--muted); white-space: nowrap; }
#term-list .none { font-size: 12.5px; color: var(--muted); padding: 2px 6px; }

/* ── карточка образования ── */
#info-latin { font: italic 600 14px/1.3 var(--body); color: var(--muted); margin: -4px 0 10px; }
#info-latin:empty { display: none; }
#info dd { white-space: normal; }
#info-facts dd { font: 600 12.5px/1.35 var(--body); }
#info-facts dd:first-of-type { font: 500 12px/1.35 var(--mono); }
#info-live dd { font: 600 12.5px/1.35 var(--body); }
#info-origin { margin: 0; padding: 10px 0 2px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
#info-origin .eyebrow { display: block; margin-bottom: 3px; }
#info-actions { display: flex; gap: 14px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 8px; }
#info-actions .link { padding: 0; }

/* ── глобус: над доком ── */
#globe-bar {
  left: 50%; transform: translateX(-50%); bottom: var(--above-dock);
  display: flex; gap: 10px; align-items: center; padding: 6px 8px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100% - 32px); border-radius: 22px;
}
#globe-bar .views { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
#globe-bar .chip { padding: 6px 11px; font-size: 12.5px; }
#globe-bar .seg button { padding: 6px 11px; font-size: 12.5px; }
#spin-btn.on { background: var(--accent); border-color: transparent; color: var(--accent-ink); }

/* ── строка под курсором и подгрузка карт ── */
#cursor, #detail-note {
  position: absolute; z-index: 4; left: var(--edge); bottom: var(--above-dock); font-size: 11.5px; color: rgba(236, 239, 245, .82);
  text-shadow: 0 0 4px #000; pointer-events: none;
}
#detail-note { bottom: calc(var(--above-dock) + 18px); color: rgba(236, 239, 245, .6); }

#loader .moon-spin {
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d9d3c3, #8f8a80 55%, #3a3a40 75%);
  box-shadow: inset -18px -6px 0 rgba(5, 7, 12, 0.92); animation: wax 3.2s ease-in-out infinite alternate;
}
@keyframes wax { from { box-shadow: inset -40px -6px 0 rgba(5, 7, 12, 0.94); } to { box-shadow: inset 0 0 0 rgba(5, 7, 12, 0.94); } }

/* ── подписи образований: шрифт сайта, моря — курсивом ── */
.ml {
  position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: auto; cursor: pointer; will-change: transform;
  font-family: var(--body); line-height: 1.1; color: rgba(236, 239, 245, 0.92); text-shadow: 0 0 3px #000, 0 0 7px rgba(0, 0, 0, 0.85);
  user-select: none;
}
.ml:hover { color: #fff; }
.l-mare { font-style: italic; font-weight: 700; letter-spacing: 0.04em; color: rgba(232, 226, 214, 0.86); }
.l-mare.ocean { letter-spacing: 0.08em; }
.l-crater { font-weight: 600; }
.l-sat { color: rgba(214, 214, 218, 0.74); }
.l-relief { font-style: italic; color: rgba(236, 222, 200, 0.86); }
.l-site { color: #ffb06b; font-weight: 700; padding-left: 11px; }
.l-site::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: #ffb06b; box-shadow: 0 0 6px #ffb06b;
}
.ml.night { opacity: 0.55; }
.ml.sel { color: #ffb06b; opacity: 1; }
body.globe .ml.night { opacity: 0.7; }

/* ── узкие экраны ── */
@media (max-width: 1100px) {
  #cursor, #detail-note, .tm-utc { display: none; }
}
@media (max-width: 760px) {
  #search-box { flex: 1 1 100%; width: auto; min-width: 0; }
  #viewpop, #layers, #tools, #calendar, #about { left: var(--edge); right: calc(var(--edge-r) + 52px); width: auto; }
  #ephem { top: calc(var(--top) + 104px); width: 250px; max-height: calc(100% - var(--top) - 104px - var(--above-dock)); }
  #globe-bar { gap: 6px; padding: 5px; }
  #globe-bar .light-seg { display: none; }
  #globe-bar .chip, #globe-bar .seg button { padding: 5px 9px; font-size: 12px; }
  .hide-xs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #loader .moon-spin { animation: none; }
}
