/* ==========================================================================
   V/H/S PROTOCOL - shared theme
   Dark analog-horror terminal: near-black, dirty white, thin borders,
   monospace. Effects are subtle and must never harm readability.
   ========================================================================== */

:root {
  --bg: #090909;
  --bg-2: #101010;
  --bg-3: #151513;
  --ink: #ece8e1;
  --ink-dim: #9b968c;
  --ink-faint: #605d55;
  --line: #2c2b27;
  --line-strong: #55524a;
  --warn: #c8502e;
  --ok: #7d9c7d;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, SFMono-Regular,
    Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- VHS overlays ------------------------------------------------------- */

body::before {
  /* scanlines */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
  background: repeating-linear-gradient(
    0deg,
    rgba(236, 232, 225, 0.028) 0px,
    rgba(236, 232, 225, 0.028) 1px,
    transparent 1px,
    transparent 3px
  );
}

body::after {
  /* vignette + faint tape tint */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9991;
  background: radial-gradient(
    ellipse at center,
    transparent 58%,
    rgba(0, 0, 0, 0.42) 100%
  );
}

/* --- headings / glitch --------------------------------------------------- */

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.glitch {
  position: relative;
  animation: glitch-shadow 3.4s infinite steps(1);
}

@keyframes glitch-shadow {
  0%, 93%, 100% { text-shadow: none; }
  94% { text-shadow: -2px 0 rgba(255, 60, 60, 0.55), 2px 0 rgba(60, 120, 255, 0.55); }
  95% { text-shadow: 2px 0 rgba(255, 60, 60, 0.4), -2px 0 rgba(60, 120, 255, 0.4); }
  96% { text-shadow: none; }
}

.blink {
  animation: blink 1.15s infinite steps(1);
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0.15; }
}

/* --- controls ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  text-align: center;
}

.btn:hover { border-color: var(--ink-dim); }
.btn:active { background: var(--ink); color: var(--bg); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { border-color: var(--ink); }
.btn-danger { border-color: var(--warn); color: var(--warn); }
.btn-danger:active { background: var(--warn); color: var(--bg); }
.btn-small { min-height: 44px; padding: 6px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: #0d0d0c;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  border-radius: 0;
}

input:focus, textarea:focus, select:focus {
  outline: 1px solid var(--ink-dim);
  outline-offset: 0;
}

textarea { resize: vertical; min-height: 90px; }

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--ink);
}

/* --- panels / notes ------------------------------------------------------ */

.panel {
  border: 1px solid var(--line);
  background: var(--bg-2);
  padding: 14px;
  margin-bottom: 14px;
}

.panel > h2, .panel > h3 {
  font-size: 13px;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-dim);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  white-space: pre-wrap;
}

.note-warn { border-left-color: var(--warn); color: var(--warn); }
.note-ok { border-left-color: var(--ok); }

.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.warn-text { color: var(--warn); }
.hidden { display: none !important; }

.mono-block {
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- tables -------------------------------------------------------------- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th, .tbl td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.tbl th {
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 400;
  font-size: 11px;
  background: var(--bg-2);
}

.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--bg-3); }

/* --- overlay ------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000; /* above the camera overlay (9999) */
  background: rgba(5, 5, 5, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.overlay-box {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.overlay-box h2 {
  font-size: 14px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.overlay-box.critical {
  border-color: var(--warn);
}

.overlay-box.critical h2 { color: var(--warn); }

/* --- misc ---------------------------------------------------------------- */

.statusbar-tag {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.rec-dot::before {
  content: "\25CF ";
  color: var(--warn);
  animation: blink 1.6s infinite steps(1);
}

.progress {
  width: 100%;
  height: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
}

.progress > div {
  height: 100%;
  width: 0;
  background: var(--ink);
}

::selection { background: var(--ink); color: var(--bg); }

/* --- reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .glitch { animation: none; }
  .blink, .rec-dot::before { animation: none; opacity: 1; }
}
