/* Radar & sonar screen simulator — xscript.net */

:root {
  --bg: #070b0a;
  --panel: #0c1311;
  --panel-head: #111a17;
  --line: #1f2b27;
  --line-bright: #34443e;
  --text: #e9f2ee;
  --muted: #84948d;
  --dim: #56635e;
  --red: #ff3b30;
  --red-bg: rgba(255, 59, 48, 0.16);
  --acc: #3dff7a;
  --acc-soft: rgba(61, 255, 122, 0.14);
  --friendly: #5ab8ff;
  --unknown: #ffd23f;
  --hostile: #ff3b30;
  --font-data: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-label: 'Barlow Condensed', 'Arial Narrow', var(--font-data);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--bg); }

body {
  font-family: var(--font-data);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

button, select { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.radar {
  height: 100vh;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.radar:fullscreen { height: 100vh; width: 100vw; min-height: 0; }
.radar:-webkit-full-screen { height: 100vh; width: 100vw; min-height: 0; }

.radar.mode-air { --acc: #3dff7a; --acc-soft: rgba(61, 255, 122, 0.14); }
.radar.mode-sonar { --acc: #2fd4ff; --acc-soft: rgba(47, 212, 255, 0.14); }
.radar.mode-weather { --acc: #ffd23f; --acc-soft: rgba(255, 210, 63, 0.14); }

/* ---------- Header ---------- */
.rh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: var(--panel-head);
  border-bottom: 2px solid var(--acc);
  flex: 0 0 auto;
}
.radar.is-alert .rh { border-bottom-color: var(--red); }
.rh-left, .rh-right { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.rh-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.rh-logo {
  position: relative;
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border: 2px solid var(--acc);
  border-radius: 50%;
  overflow: hidden;
}
.rh-logo::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 50%; height: 2px;
  margin-top: -1px;
  background: var(--acc);
  transform-origin: 0 50%;
  animation: logoSweep 4s linear infinite;
}
.rh-logo::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--acc);
}
@keyframes logoSweep { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }

.rh-name { display: flex; flex-direction: column; line-height: 1.05; }
.rh-title {
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.2em;
  color: var(--text);
}
.rh-sub { font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 0.24em; color: var(--muted); white-space: nowrap; }

.rh-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-label);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--bg);
  background: var(--acc);
  padding: 3px 10px;
  white-space: nowrap;
}
.rh-status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
.rh-status.is-alert { background: var(--red); color: #fff; }
.rh-status.is-paused { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--muted); }
.rh-status.is-paused .dot { animation: none; }

.rh-sim {
  font-family: var(--font-label);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  border: 1px dashed var(--line-bright);
  padding: 3px 7px;
  white-space: nowrap;
}

.rh-center { display: flex; flex-direction: column; align-items: center; line-height: 1; flex: 0 0 auto; }
.rh-clock { font-size: 1.7rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text); white-space: nowrap; }
.rh-clock-sub { margin-top: 4px; font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.2em; color: var(--muted); white-space: nowrap; }

.rh-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.rh-pick select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 5px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.rbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.rbtn:hover, .rbtn:focus-visible { background: rgba(255, 255, 255, 0.08); border-color: var(--acc); }
.rbtn[aria-pressed="true"] { color: var(--acc); border-color: var(--acc); }
.rbtn.is-red { border-color: var(--red); color: var(--red); }
.rbtn.is-red:hover, .rbtn.is-red:focus-visible { background: var(--red-bg); border-color: var(--red); }
.rbtn.is-red[aria-pressed="true"] { background: var(--red); color: #fff; }
.rbtn-sm { padding: 2px 7px; font-size: 0.6rem; }

:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- Main grid ---------- */
.rgrid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 8px;
  padding: 8px 10px;
}
.radar.no-side .rgrid { grid-template-columns: minmax(0, 1fr); }
.radar.no-side .col-side { display: none; }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.ph {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
}
.ph-title { font-family: var(--font-label); font-size: 0.92rem; font-weight: 700; letter-spacing: 0.18em; color: var(--text); }
.ph-note { margin-left: auto; font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.pb { flex: 1 1 auto; min-height: 0; overflow: hidden; position: relative; }

.p-scope { flex: 1 1 auto; background: #020504; }
.p-tracks { flex: 1 1 auto; min-height: 180px; }
.p-sensor { flex: 0 0 auto; }
.p-log { flex: 0 0 30%; min-height: 110px; }

/* ---------- Scope ---------- */
.scope-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

.alert-banner {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  background: rgba(40, 4, 2, 0.88);
  border: 2px solid var(--red);
  color: #fff;
}
.ab-word {
  font-family: var(--font-label);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1;
  color: var(--red);
  white-space: nowrap;
  animation: slowPulse 2s ease-in-out infinite;
}
.ab-text { min-width: 0; font-size: 0.74rem; font-weight: 600; line-height: 1.35; letter-spacing: 0.04em; }
.ab-eta { font-size: 0.86rem; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; color: var(--red); }
.alert-banner.is-clearing { border-color: var(--unknown); background: rgba(30, 24, 2, 0.88); }
.alert-banner.is-clearing .ab-word, .alert-banner.is-clearing .ab-eta { color: var(--unknown); animation: none; }

.paused-tag {
  position: absolute;
  right: 14px;
  bottom: 40px;
  z-index: 4;
  font-family: var(--font-label);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--muted);
  border: 1px solid var(--line-bright);
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 10px;
}

/* ---------- Tracks ---------- */
.tracks { overflow-y: auto; scrollbar-width: thin; padding: 2px 0; }
.trk {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 5px 10px 5px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-left: 3px solid transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.66rem;
}
.trk:hover { background: rgba(255, 255, 255, 0.04); }
.trk.is-sel { background: var(--acc-soft); border-left-color: var(--acc); }
.trk-a { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.trk-id { font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; font-size: 0.74rem; }
.trk-type { font-family: var(--font-label); font-size: 0.82rem; letter-spacing: 0.1em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.trk-ident {
  margin-left: auto;
  font-family: var(--font-label);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0 6px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.trk-b { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; color: var(--text); }
.trk-b span { white-space: nowrap; }
.trk-b i { font-style: normal; font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--dim); margin-right: 4px; }
.trk.is-friendly .trk-ident { color: var(--friendly); }
.trk.is-unknown .trk-ident { color: var(--unknown); }
.trk.is-hostile .trk-ident { color: var(--hostile); }
.trk.is-hostile .trk-id { color: var(--hostile); }
.trk.is-alert { background: var(--red-bg); }
.trk-empty { padding: 14px 10px; color: var(--dim); font-size: 0.7rem; letter-spacing: 0.1em; }

/* ---------- Sensor ---------- */
.sensor { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 8px 10px 9px; }
.sn { display: flex; flex-direction: column; min-width: 0; }
.sn span { font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.sn b { font-size: 0.72rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Log ---------- */
.log { overflow: hidden; padding: 2px 0; }
.lg-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 3px 10px;
  font-size: 0.64rem;
  line-height: 1.35;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}
.lg-t { color: var(--dim); white-space: nowrap; }
.lg-x { color: #bfcac5; min-width: 0; }
.lg-row.is-alert .lg-x { color: var(--red); font-weight: 600; }
.lg-row.is-new .lg-x { color: var(--acc); }
.lg-row:first-child { animation: rowIn 0.4s ease-out; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ---------- Status bar ---------- */
.rb {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 5px 14px;
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.rb-item b { color: var(--text); font-weight: 600; }
.rb-item.is-bad b { color: var(--red); }
.rb-keys { margin-left: auto; color: var(--dim); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes slowPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Reference content ---------- */
.tool-info {
  max-width: 900px;
  margin: 44px auto 40px;
  padding: 0 24px;
  color: #a2b0aa;
  line-height: 1.7;
  font-size: 0.92rem;
}
.tool-info h1 { color: var(--text); font-size: 1.3rem; letter-spacing: 0.03em; margin-bottom: 14px; line-height: 1.35; }
.tool-info h2 {
  color: var(--text);
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 32px 0 10px;
  padding-left: 10px;
  border-left: 3px solid #3dff7a;
}
.tool-info h3 { color: var(--text); font-size: 0.94rem; margin: 22px 0 6px; }
.tool-info p { margin-bottom: 12px; }
.tool-info ul { margin: 0 0 12px 22px; }
.tool-info li { margin-bottom: 6px; }
.tool-info a { color: #6dffa0; }
.tool-info strong { color: var(--text); }
.tool-info code { font-family: var(--font-data); font-size: 0.86em; color: var(--text); }
.tool-info kbd {
  font-family: var(--font-data);
  font-size: 0.8em;
  border: 1px solid var(--line-bright);
  border-bottom-width: 2px;
  padding: 0 5px;
  border-radius: 3px;
  color: var(--text);
}
.glossary { margin: 0 0 12px; }
.glossary dt { color: var(--text); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.84rem; margin-top: 16px; }
.glossary dd { margin: 4px 0 0; }
.formula { font-family: var(--font-data); color: var(--text); background: var(--panel); border-left: 3px solid #3dff7a; padding: 8px 14px; margin: 0 0 14px; }

.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.info-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 520px; }
.info-table th, .info-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.info-table th { color: var(--text); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; border-bottom-color: var(--line-bright); }
.info-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(255, 255, 255, 0.2); }

.site-foot {
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  padding: 15px;
  text-align: center;
  font-size: 0.8rem;
}
.site-foot-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.site-foot-links a { color: var(--text); text-decoration: none; }
.site-foot-links a:hover { text-decoration: underline; }
.site-foot-note { color: var(--muted); font-size: 0.72rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1700px) {
  .rh-pick span { display: none; }
}

@media (max-width: 1380px) {
  .rh-sub, .rh-sim { display: none; }
  .rh-clock { font-size: 1.45rem; }
  .rh .rbtn { padding: 6px 7px; letter-spacing: 0.06em; }
  .rh-right { gap: 6px; }
  .rb-keys { display: none; }
}

@media (max-width: 1100px) {
  .radar { height: auto; min-height: 0; }
  .rh { flex-wrap: wrap; }
  .rh-left, .rh-right { flex: 1 1 auto; }
  .rh-center { order: -1; width: 100%; }
  .rgrid { grid-template-columns: 1fr; }
  .p-scope { flex: 0 0 auto; height: min(92vw, 640px); }
  .col-side { display: grid; grid-template-columns: 1fr 1fr; }
  .p-tracks { grid-row: span 2; height: 420px; }
  .p-log { height: 260px; }
  .rb { flex-wrap: wrap; white-space: normal; justify-content: center; gap: 6px 16px; }
}

@media (max-width: 680px) {
  .rgrid { padding: 6px; gap: 6px; }
  .col-side { grid-template-columns: 1fr; }
  .p-tracks { grid-row: auto; height: 360px; }
  .rh-right { justify-content: center; }
  .rh-left { justify-content: center; flex-wrap: wrap; }
  .alert-banner { flex-wrap: wrap; gap: 4px 10px; }
  .ab-word { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rh-logo::before, .rh-status .dot, .ab-word, .lg-row:first-child { animation: none; }
  .rh-logo::before { transform: rotate(-45deg); }
}
