/* ============ базовая рамка ============ */
:root {
  --mono: "VT323", "Share Tech Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --grain: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #000; }
body {
  color: var(--fg);
  font-family: var(--mono);
  font-size: 19px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: none;
  transition: color .3s;
}
a { color: inherit; }
:focus-visible { outline: 2px dashed var(--accent2); outline-offset: 2px; }

.rig { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ============ режимы (палитры) ============ */
body[data-mode="vcr"] {
  --bg: #0a0a18; --fg: #ececff; --dim: #8f8fb8; --accent: #ff2d6f; --accent2: #25e6ff;
  --line: rgba(160,160,255,.28); --vig: .55; --grain-op: .14;
  --img-filter: saturate(1.35) contrast(1.05) blur(.35px);
  --glow: 2px 0 rgba(255,0,80,.55), -2px 0 rgba(0,240,255,.55);
}
body[data-mode="cctv"] {
  --bg: #0d100d; --fg: #d9e0d9; --dim: #7f8c7f; --accent: #ff3030; --accent2: #f2f2f2;
  --line: rgba(200,220,200,.28); --vig: .7; --grain-op: .24;
  --img-filter: grayscale(1) contrast(1.15) brightness(.95);
  --glow: 0 0 0 transparent;
}
body[data-mode="nvg"] {
  --bg: #010a03; --fg: #5cff82; --dim: #2fa84d; --accent: #c8ff3d; --accent2: #5cff82;
  --line: rgba(92,255,130,.35); --vig: .9; --grain-op: .4;
  --img-filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(5) brightness(1.15) contrast(1.2);
  --glow: 0 0 7px rgba(80,255,120,.75);
}
body[data-mode="surv"] {
  --bg: #07080a; --fg: #dde2e9; --dim: #7d8895; --accent: #ff3b30; --accent2: #ffd60a;
  --line: rgba(220,230,240,.22); --vig: .5; --grain-op: .1;
  --img-filter: grayscale(1) contrast(1.2);
  --glow: 0 0 0 transparent;
}

/* ============ панель режимов и каналы ============ */
.toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 6px 12px; background: #000; border-bottom: 1px solid #1d1d1d; font-size: 17px;
  padding-top: max(6px, env(safe-area-inset-top));
}
.brand { letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; color: var(--fg); text-shadow: var(--glow); }
.rec { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: var(--accent); margin-right: .45em; animation: blink 1.2s steps(1) infinite; vertical-align: baseline; }
.modes { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.modes button {
  font: inherit; font-size: 16px; letter-spacing: .08em; color: var(--dim); background: transparent;
  border: 1px solid #333; padding: 1px 8px; cursor: pointer; text-transform: uppercase;
}
.modes button:hover { color: var(--fg); border-color: var(--fg); }
.modes button.on { color: #000; background: var(--accent2); border-color: var(--accent2); }

.channels {
  display: flex; overflow-x: auto; background: #000; border-top: 1px solid #1d1d1d; scrollbar-width: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.channels::-webkit-scrollbar { display: none; }
.channels a {
  flex: 0 0 auto; padding: 8px 18px; color: var(--dim); text-decoration: none; white-space: nowrap;
  border-right: 1px solid #1d1d1d; text-transform: uppercase; letter-spacing: .06em; font-size: 18px;
}
.channels a b { font-weight: normal; color: var(--accent); margin-right: .5em; }
.channels a:hover { color: var(--fg); }
.channels a[aria-current="true"] { background: var(--fg); color: var(--bg); }
.channels a[aria-current="true"] b { color: var(--bg); }

/* ============ экран ============ */
.screen { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--bg); isolation: isolate; transition: background .3s; }
.viewport {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  padding: 92px clamp(16px, 5vw, 70px) 96px; scrollbar-width: thin; scrollbar-color: var(--dim) transparent;
  text-shadow: var(--glow);
  outline: none;
}
body[data-mode="cctv"] .viewport { filter: grayscale(.75) contrast(1.06); animation: exposure 6s steps(1) infinite; }
body[data-mode="nvg"] .viewport { animation: nvgpulse 3.4s ease-in-out infinite; }

.hero { margin-bottom: 26px; }
.hero h1 { font-size: clamp(44px, 9vw, 104px); line-height: .95; margin: 0; font-weight: normal; letter-spacing: .04em; text-transform: uppercase; }
.tagline { margin: 8px 0 0; color: var(--dim); font-size: 22px; max-width: 46ch; }

.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%; overflow: hidden; pointer-events: none; }
.glitch::before { color: var(--accent); transform: translate(3px, 0); clip-path: inset(0 0 62% 0); animation: gl1 3.1s steps(1) infinite; }
.glitch::after { color: var(--accent2); transform: translate(-3px, 0); clip-path: inset(62% 0 0 0); animation: gl2 2.6s steps(1) infinite; }

.panel[hidden] { display: none; }
.panel { animation: tune .45s steps(8) 1; }
.panel-head { margin-bottom: 20px; border-left: 3px solid var(--accent); padding-left: 14px; }
.panel-head h2 { margin: 0; font-size: clamp(28px, 4.4vw, 46px); font-weight: normal; text-transform: uppercase; letter-spacing: .06em; }
.sub { margin: 2px 0 0; color: var(--dim); text-transform: uppercase; letter-spacing: .12em; font-size: 17px; }
.intro { margin: 10px 0 0; max-width: 70ch; }

/* ============ блоки ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 22px; align-items: start; }
.block { position: relative; border: 1px solid var(--line); background: rgba(0,0,0,.38); padding: 12px 15px 15px; min-width: 0; }
.block.wide { grid-column: 1 / -1; }
.block-tag { font-size: 14px; letter-spacing: .14em; color: var(--dim); text-transform: uppercase; margin-bottom: 6px; }
.block h3 { margin: 0 0 8px; font-weight: normal; font-size: 26px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); }
.text { margin: 0; max-width: 72ch; }
.cap { margin: 8px 0 0; color: var(--dim); font-size: 17px; }
.block img, .block video, .block iframe { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #000; filter: var(--img-filter); }
.block iframe { aspect-ratio: 16 / 9; height: auto; border: 0; }
.block img.zoom { cursor: zoom-in; }
.btn { display: inline-block; padding: 6px 16px; border: 1px solid var(--accent2); color: var(--accent2); text-decoration: none; text-transform: uppercase; letter-spacing: .1em; }
.btn:hover { background: var(--accent2); color: var(--bg); text-shadow: none; }

/* поверхностная рамка «досье» только для surveillance */
body[data-mode="surv"] .block::before, body[data-mode="surv"] .block::after { content: ""; position: absolute; width: 12px; height: 12px; border: 2px solid var(--accent); pointer-events: none; }
body[data-mode="surv"] .block::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
body[data-mode="surv"] .block::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }
body[data-mode="surv"] .block-tag::after { content: "  // CLASSIFIED"; color: var(--accent); }
body[data-mode="nvg"] .block { background: rgba(0,25,5,.45); }

.redacted { cursor: help; }
body[data-mode="surv"] .redacted { background: var(--fg); color: transparent; text-shadow: none; padding: 0 .15em; transition: background .25s, color .25s; }
body[data-mode="surv"] .redacted:hover, body[data-mode="surv"] .redacted:focus { background: transparent; color: var(--accent2); }

/* аудиоплеер */
.player { display: flex; gap: 12px; align-items: center; }
.pbtn { flex: 0 0 auto; width: 52px; height: 52px; font: inherit; font-size: 22px; color: var(--bg); background: var(--accent2); border: 0; cursor: pointer; text-shadow: none; }
.pbtn:hover { background: var(--fg); }
.pmain { flex: 1; min-width: 0; }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 26px; margin-bottom: 4px; }
.eq i { flex: 1; max-width: 12px; height: 3px; background: var(--accent); display: block; }
.player.playing .eq i { animation: eq .6s ease-in-out infinite alternate; }
.player.playing .eq i:nth-child(2) { animation-duration: .45s; }
.player.playing .eq i:nth-child(3) { animation-duration: .8s; }
.player.playing .eq i:nth-child(4) { animation-duration: .5s; }
.player.playing .eq i:nth-child(5) { animation-duration: .7s; }
.player.playing .eq i:nth-child(6) { animation-duration: .38s; }
.seek { width: 100%; accent-color: var(--accent2); background: transparent; height: 18px; }
.ptime { font-size: 16px; color: var(--dim); }

/* соцсети */
.socials { list-style: none; margin: 28px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.socials a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); text-decoration: none; background: rgba(0,0,0,.38); }
.socials a:hover { border-color: var(--accent2); color: var(--accent2); }
.socials .code { flex: 0 0 auto; min-width: 2.4em; text-align: center; border: 1px solid var(--accent); color: var(--accent); padding: 0 6px; }
.socials .lbl { text-transform: uppercase; letter-spacing: .08em; }
.socials .hnd { color: var(--dim); font-size: 16px; margin-left: auto; overflow-wrap: anywhere; text-align: right; }

/* ============ HUD ============ */
.hud { position: absolute; z-index: 6; pointer-events: none; font-size: 21px; letter-spacing: .08em; text-transform: uppercase; line-height: 1.1; text-shadow: 0 0 3px #000, var(--glow); color: var(--fg); }
.hud.tl { top: 12px; left: 16px; }
.hud.tr { top: 12px; right: 16px; text-align: right; }
.hud.bl { bottom: 10px; left: 16px; }
.hud.br { bottom: 10px; right: 16px; text-align: right; }
.hud small { font-size: 15px; color: var(--dim); display: block; }
.osd-play { color: var(--accent2); }
body[data-mode="cctv"] .hud { color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
body[data-mode="vcr"] .hud { font-size: 24px; }

.osd {
  position: absolute; z-index: 22; left: 6%; top: 22%; font-size: clamp(34px, 6vw, 64px); letter-spacing: .1em;
  color: #7dff9a; text-shadow: 2px 2px 0 #052, 0 0 8px rgba(125,255,154,.6); opacity: 0; transition: opacity .25s; pointer-events: none;
}
.osd.on { opacity: 1; }

/* ============ FX-слои ============ */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.fx-tint { display: none; mix-blend-mode: color; }
body[data-mode="cctv"] .fx-tint { display: block; background: rgba(120,150,120,.16); }
body[data-mode="nvg"] .fx-tint { display: block; background: rgba(0,255,70,.12); mix-blend-mode: screen; }

.fx-grain { inset: -30%; background-image: var(--grain); background-size: 128px 128px; opacity: var(--grain-op); mix-blend-mode: overlay; animation: grain .7s steps(7) infinite; z-index: 7; }
.fx-scan { background: repeating-linear-gradient(to bottom, rgba(0,0,0,.28) 0, rgba(0,0,0,.28) 1px, transparent 1px, transparent 3px); z-index: 7; }
body[data-mode="nvg"] .fx-scan { background: repeating-linear-gradient(to bottom, rgba(0,20,4,.4) 0, rgba(0,20,4,.4) 1px, transparent 1px, transparent 2px); }
.fx-vig { z-index: 8; background: radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,var(--vig)) 100%); }

.fx-track { display: none; height: 13%; bottom: auto; top: -15%; z-index: 7; background: linear-gradient(to bottom, transparent, rgba(255,255,255,.10) 45%, rgba(255,255,255,.04) 55%, transparent); backdrop-filter: blur(1.5px) saturate(1.8); -webkit-backdrop-filter: blur(1.5px) saturate(1.8); animation: trackmove 8s linear infinite; }
body[data-mode="vcr"] .fx-track { display: block; }
.screen.glitch-now .viewport { animation: jolt .22s steps(2) 1; }

.fx-grid { display: none; background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px); background-size: 48px 48px; }
body[data-mode="surv"] .fx-grid { display: block; }
.fx-sweep { display: none; width: 14%; right: auto; background: linear-gradient(90deg, transparent, rgba(255,59,48,.16), transparent); animation: sweep 7s linear infinite; }
body[data-mode="surv"] .fx-sweep { display: block; }

.fx-corners { display: none; z-index: 8; margin: 54px 12px 40px; background:
  linear-gradient(var(--fg), var(--fg)) top left / 26px 2px no-repeat, linear-gradient(var(--fg), var(--fg)) top left / 2px 26px no-repeat,
  linear-gradient(var(--fg), var(--fg)) top right / 26px 2px no-repeat, linear-gradient(var(--fg), var(--fg)) top right / 2px 26px no-repeat,
  linear-gradient(var(--fg), var(--fg)) bottom left / 26px 2px no-repeat, linear-gradient(var(--fg), var(--fg)) bottom left / 2px 26px no-repeat,
  linear-gradient(var(--fg), var(--fg)) bottom right / 26px 2px no-repeat, linear-gradient(var(--fg), var(--fg)) bottom right / 2px 26px no-repeat; opacity: .7; }
body[data-mode="cctv"] .fx-corners, body[data-mode="surv"] .fx-corners { display: block; }

.fx-cross { display: none; z-index: 8; background:
  linear-gradient(var(--fg), var(--fg)) 50% 50% / 40px 1px no-repeat, linear-gradient(var(--fg), var(--fg)) 50% 50% / 1px 40px no-repeat; opacity: .35; }
body[data-mode="nvg"] .fx-cross { display: block; }

.fx-nvg { display: none; z-index: 9; background: radial-gradient(ellipse 80% 92% at 50% 50%, transparent 58%, rgba(0,0,0,.94) 100%); }
body[data-mode="nvg"] .fx-nvg { display: block; }

/* трекер курсора (surveillance) */
.track { display: none; position: absolute; z-index: 10; left: 0; top: 0; width: 96px; height: 96px; margin: -48px 0 0 -48px; pointer-events: none; border: 1px solid var(--accent); }
.track::before, .track::after { content: ""; position: absolute; background: var(--accent); }
.track::before { left: 50%; top: -10px; width: 1px; height: 10px; }
.track::after { top: 50%; left: -10px; height: 1px; width: 10px; }
.track span { position: absolute; top: 100%; left: -1px; margin-top: 4px; white-space: nowrap; color: var(--accent); font-size: 15px; letter-spacing: .1em; text-shadow: 0 0 3px #000; }
body[data-mode="surv"] .track.live { display: block; }

/* переключение канала */
.static { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 20; image-rendering: pixelated; display: none; background: #000; }
.static.on { display: block; }

/* заставка */
.boot { position: fixed; inset: 0; z-index: 50; background: #000; color: #7dff9a; padding: 8vh 7vw; font-size: clamp(20px, 3vw, 30px); letter-spacing: .08em; white-space: pre-wrap; cursor: pointer; text-shadow: 0 0 6px rgba(125,255,154,.6); }
.boot[hidden] { display: none; }

/* лайтбокс */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; padding: 3vmin; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; filter: var(--img-filter); }

/* ============ анимации ============ */
@keyframes blink { 50% { opacity: 0; } }
@keyframes grain { 0% { transform: translate(0,0) } 14% { transform: translate(-6%,4%) } 28% { transform: translate(5%,-7%) } 42% { transform: translate(-3%,8%) } 57% { transform: translate(7%,3%) } 71% { transform: translate(-8%,-4%) } 85% { transform: translate(2%,-9%) } 100% { transform: translate(0,0) } }
@keyframes trackmove { from { top: -15%; } to { top: 108%; } }
@keyframes sweep { from { left: -16%; } to { left: 104%; } }
@keyframes exposure { 0%, 100% { filter: grayscale(.75) contrast(1.06) brightness(1); } 46% { filter: grayscale(.75) contrast(1.06) brightness(1); } 47% { filter: grayscale(.75) contrast(1.1) brightness(1.18); } 48% { filter: grayscale(.75) contrast(1.06) brightness(.92); } 49% { filter: grayscale(.75) contrast(1.06) brightness(1); } }
@keyframes nvgpulse { 0%, 100% { filter: brightness(1) contrast(1.05); } 50% { filter: brightness(1.14) contrast(1.12); } }
@keyframes eq { from { height: 3px; } to { height: 26px; } }
@keyframes tune { 0% { opacity: 0; transform: translateX(-14px) skewX(-6deg); filter: blur(3px); } 40% { opacity: .8; transform: translateX(8px) skewX(4deg); } 100% { opacity: 1; transform: none; filter: none; } }
@keyframes jolt { 0% { transform: translate(0,0); } 25% { transform: translate(-8px,2px) skewX(3deg); } 50% { transform: translate(7px,-1px); } 75% { transform: translate(-3px,0) skewX(-2deg); } 100% { transform: none; } }
@keyframes gl1 { 0%, 100% { clip-path: inset(0 0 62% 0); } 20% { clip-path: inset(10% 0 55% 0); transform: translate(5px,0); } 22% { clip-path: inset(0 0 62% 0); } 60% { clip-path: inset(30% 0 30% 0); transform: translate(-4px,0); } 62% { clip-path: inset(0 0 62% 0); } }
@keyframes gl2 { 0%, 100% { clip-path: inset(62% 0 0 0); } 35% { clip-path: inset(50% 0 20% 0); transform: translate(-6px,0); } 37% { clip-path: inset(62% 0 0 0); } 78% { clip-path: inset(70% 0 5% 0); transform: translate(4px,0); } 80% { clip-path: inset(62% 0 0 0); } }

/* ============ адаптив и доступность ============ */
@media (max-width: 700px) {
  body { font-size: 18px; }
  .toolbar { flex-wrap: wrap; }
  .viewport { padding-top: 84px; padding-bottom: 86px; }
  .hud { font-size: 16px; }
  body[data-mode="vcr"] .hud { font-size: 18px; }
  .hud small { font-size: 12px; }
  .hud.br { display: none; }
  .osd { top: 26%; }
}
@media (hover: none) { .track { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fx-grain { opacity: calc(var(--grain-op) * .5); }
}
