/* Atropos radar viewer. Brand from the client menu (Noto Sans, menu icon font, graphite surfaces, the owner's red
   accent, menu toggles); polish rules after "unslop" by Damir Sokolovsky (@heydamir), CC BY 4.0:
   quiet chrome, one bright element (the map), 4px grid, sentence case, three text roles, no glows. */
@font-face { font-family: "Noto"; src: url("/radar/assets/fonts/NotoSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto"; src: url("/radar/assets/fonts/NotoSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Noto"; src: url("/radar/assets/fonts/NotoSans-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "MenuIcons"; src: url("/radar/assets/fonts/Menu-icons.otf") format("opentype"); font-display: block; }

:root {
  /* graphite ramp (menu surfaces) */
  --bg-deep: #0c0d10;
  --bg: #111216;
  --card: #17181d;
  --raised: #202127;
  --line: rgb(237 237 240 / .08);
  /* three text roles */
  --text: #ececef;
  --text-2: #a1a2aa;
  --text-3: #80818a;
  /* brand accent (menu custom accent) and meaning colours */
  --accent: #ff1a1a;
  --negative: #e5484d;
  --ct: #6a9bff;
  --t: #e9ad4f;
  --track: #07080c;
  --knob: #7d8791;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg-deep); color: var(--text); overflow: hidden;
  font: 400 14px/20px "Noto", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.ic { font-family: "MenuIcons"; font-style: normal; font-weight: 400; line-height: 1; display: inline-block; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

#window { height: 100%; display: grid; grid-template-rows: 56px 1fr; gap: 16px; padding: 16px 24px 24px; max-width: 1600px; margin: 0 auto; }

/* ---------- top bar ---------- */
#header { display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; }
.logo { display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.logo img { width: 20px; height: 20px; }
.logo b { font-weight: 500; font-size: 16px; }
.logo span { color: var(--text-3); font-size: 16px; }
.divider { width: 1px; height: 20px; background: var(--line); }
.map-name { display: flex; align-items: baseline; gap: 8px; }
.map-name b { font-weight: 500; }
.map-name small { color: var(--text-3); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status.live i { background: #4cc38a; }
.status.ended i, .status.error i { background: var(--negative); }
.grow { flex: 1; }
.score { display: inline-flex; align-items: baseline; gap: 8px; font-size: 16px; margin-right: 8px; }
.score[hidden] { display: none; }
.score .ct { color: var(--ct); } .score .t { color: var(--t); } .score b { color: var(--text-3); font-weight: 400; }
.btn { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; transition: background-color .15s var(--ease), color .15s var(--ease); }
.btn:hover { background: #2a2b32; }
.btn:active { transform: scale(.98); }
.btn .ic { font-size: 14px; color: var(--text-2); }
.icon-btn { width: 36px; padding: 0; justify-content: center; }
.icon-btn.on { color: var(--text); background: #2a2b32; }
.icon-btn.on .ic { color: var(--text); }
.btn:focus-visible, .row:focus-within { outline: 2px solid rgb(255 26 26 / .6); outline-offset: 2px; }

/* ---------- body ---------- */
#body { display: grid; grid-template-columns: 280px 1fr 280px; gap: 16px; min-height: 0; }
#window.no-roster #body { grid-template-columns: 1fr; }
#window.no-roster .team { display: none; }
.team, .center { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.section-head { display: flex; align-items: center; gap: 8px; height: 24px; padding: 0 4px; color: var(--text-2); font-size: 13px; }
.section-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.ct .dot, .dot.ct { background: var(--ct); } .t .dot, .dot.t { background: var(--t); }
.section-head em { font-style: normal; margin-left: auto; color: var(--text-3); font-size: 12px; }
.cards { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #2a2b32 transparent; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

/* player card */
.pc { padding: 12px; }
.pc.me { background: #1b1c22; box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); }
.pc.dead { opacity: .5; }
.pc .top { display: flex; align-items: center; gap: 8px; min-width: 0; height: 20px; }
.pc .top .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pc .name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc .you { color: var(--text-3); font-size: 12px; }
.pc .money { color: var(--text-2); font-size: 12px; }
.pc .stats { display: flex; align-items: center; gap: 12px; margin-top: 8px; height: 16px; font-size: 12px; color: var(--text-2); }
.pc .hp { width: 28px; color: var(--text); }
.pc .hpbar { flex: 1; height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.pc .hpbar b { display: block; height: 100%; border-radius: 2px; background: var(--text-2); transition: transform .25s var(--ease); transform-origin: left; }
.pc .hpbar b.low { background: var(--negative); }
.pc .armor { display: inline-flex; align-items: center; gap: 4px; }
.pc .gear { display: flex; align-items: center; gap: 8px; height: 24px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); box-sizing: content-box; }
.pc .gear .wp { height: 16px; opacity: .4; transition: opacity .15s var(--ease); }
.pc .gear .wp.primary { height: 18px; }
.pc .gear .wp.melee { height: 14px; }
.pc .gear .wp.active { opacity: 1; }
.pc .gear .nades { display: inline-flex; gap: 4px; margin-left: auto; }
.pc .gear .nade { height: 16px; opacity: .5; }
.pc .gear .nade.active { opacity: 1; }
.pc .dead-tag { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--text-3); font-size: 12px; }
.mi { display: inline-block; background: currentColor; -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat; }
.mi.small { width: 14px; height: 14px; color: var(--text-3); }
.mi.c4 { width: 16px; height: 16px; color: var(--accent); }
.mi.kit { width: 16px; height: 16px; color: var(--text-2); }

/* map: the one bright element */
.center .map-card { flex: 1; position: relative; overflow: hidden; min-height: 0; background: var(--bg); }
#radar { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#radar.drag { cursor: grabbing; }
.map-tools { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.map-tools .btn { background: rgb(17 18 22 / .9); }
#overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(12 13 16 / .7); }
#overlay[hidden] { display: none; }
.popup { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 40px rgb(0 0 0 / .45); }
#overlay .popup { padding: 24px 28px; text-align: center; max-width: 340px; }
#overlay h2 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
#overlay p { margin: 0; color: var(--text-2); font-size: 13px; }

/* settings popover: menu cards with menu toggles */
.menu-popup { position: fixed; z-index: 10; top: 80px; right: 32px; width: 272px; padding: 8px;
  animation: rise .18s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.menu-popup[hidden] { display: none; }
.popup-title { font-weight: 500; padding: 8px 8px 12px; }
.popup-card { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 8px; border-radius: 4px; cursor: pointer; color: var(--text-2); font-size: 13px;
  transition: background-color .15s var(--ease), color .15s var(--ease); }
.row:hover { background: var(--raised); color: var(--text); }
.row > span { flex: 1; }
.row input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.toggle { width: 32px; height: 16px; border-radius: 8px; background: var(--track); position: relative; flex: none; transition: background-color .18s var(--ease); }
.toggle::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--knob);
  transition: transform .18s var(--ease), background-color .18s var(--ease); }
input:checked + .toggle { background: var(--accent); }
input:checked + .toggle::after { transform: translateX(16px); background: #fff; }
.row.slider input { flex: 1.4; height: 4px; -webkit-appearance: none; appearance: none; border-radius: 2px; outline: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--fill, 50%) 100% no-repeat, var(--raised); }
.row.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.row.slider input::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; }
.row.slider b { width: 32px; text-align: right; font-weight: 400; color: var(--text); font-size: 12px; }
.hint { margin: 4px 8px 8px; color: var(--text-3); font-size: 12px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 16px; font-size: 13px; z-index: 20; animation: rise .18s var(--ease); }

@media (max-width: 1100px) {
  html, body { overflow: auto; }
  #window { height: auto; min-height: 100%; padding: 12px; }
  #body { grid-template-columns: 1fr 1fr; grid-template-areas: "map map" "ct t"; }
  .center { grid-area: map; } .team.ct { grid-area: ct; } .team.t { grid-area: t; }
  .center .map-card { flex: none; aspect-ratio: 1; }
  .score { display: none; }
}
@media (max-width: 640px) {
  #window { gap: 12px; padding: 8px; }
  #body { grid-template-columns: 1fr; grid-template-areas: "map" "ct" "t"; }
  .map-name small, .logo span, .btn .label { display: none; }
}

/* ---- round 3: menu toggles (40x19 track, 14px knob, menu colours), popover motion, loader, bomb chip ---- */
.toggle { width: 40px; height: 19px; border-radius: 10px; background: var(--track); position: relative; flex: none;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .04); transition: background-color .22s var(--ease); }
.toggle::after { content: ""; position: absolute; left: 2.5px; top: 2.5px; width: 14px; height: 14px; border-radius: 50%; background: var(--knob);
  transition: transform .22s var(--ease), background-color .22s var(--ease); }
input:checked + .toggle { background: var(--accent); }
input:checked + .toggle::after { transform: translateX(21px); background: #fff; }
.row:active .toggle::after { width: 16px; }
input:checked + .toggle:active::after { transform: translateX(19px); }

.menu-popup { animation: none; opacity: 0; transform: translateY(6px) scale(.98); transform-origin: top right;
  transition: opacity .18s var(--ease), transform .18s var(--ease); }
.menu-popup.open { opacity: 1; transform: none; }
.row { transition: background-color .15s var(--ease), color .15s var(--ease); }

.loader { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(12 13 16 / .55); pointer-events: none;
  opacity: 1; transition: opacity .25s var(--ease); }
.loader[hidden] { display: grid; opacity: 0; }
.loader span { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--raised); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bomb-chip { position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-width: 200px;
  background: rgb(17 18 22 / .92); border: 1px solid var(--line); border-radius: 12px; animation: rise .2s var(--ease); }
.bomb-chip[hidden] { display: none; }

/* full-screen map */
#window.map-full { padding: 8px; gap: 0; grid-template-rows: 1fr; max-width: none; height: 100vh; height: 100dvh; }
#window.map-full #header { display: none; }
#window.map-full #body { gap: 8px; }
#window.map-full .center .map-card { flex: 1; }
html:fullscreen, html:-webkit-full-screen { background: var(--bg-deep); }
@media (min-width: 1101px) { #window.map-full #body { grid-template-columns: 280px 1fr 280px; } }
@media (max-width: 1100px) {
  /* narrow screens in full screen: map on top filling the width, cards in two columns under it */
  #window.map-full { height: auto; min-height: 100vh; }
}
.map-tools .btn.on { color: var(--text); background: #2a2b32; }
.bomb-chip .mi.c4 { width: 20px; height: 20px; }
.bomb-chip.defusing .mi.c4 { color: var(--ct); }
.bomb-text { flex: 1; min-width: 0; }
.bomb-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.bomb-line b { font-weight: 500; flex: 1; }
.bomb-line span { color: var(--text); }
.bomb-track { height: 4px; border-radius: 2px; background: var(--raised); margin-top: 6px; overflow: hidden; }
.bomb-track i { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.bomb-chip.defusing .bomb-track i { background: var(--ct); }
.bomb-chip.late .bomb-track i { background: var(--negative); }
.bomb-chip small { display: block; margin-top: 4px; color: var(--text-3); font-size: 12px; }
.bomb-chip small:empty { display: none; }
