/* Cyber Terminal - shared dashboard chrome for the wall-display pages
   (cyber-terminal, threat-feed, cyber-ops).
   Inherits the site theme: every color below resolves through the same
   CSS custom properties as the rest of the site, so the dashboards follow
   whatever theme the visitor picked on /customize/. */

:root {
  /* Dashboard aliases over site tokens. Kept as --ct-* so the three
     page stylesheets and JS-injected markup don't need renaming. */
  --ct-bg-0: var(--bg-deep);
  --ct-bg-1: var(--surface);
  --ct-bg-2: var(--bg-2);
  --ct-text: var(--text-1);
  --ct-text-soft: var(--text-2);
  --ct-text-dim: var(--text-3);
  --ct-grn: var(--mint-deep);
  --ct-grn-dim: var(--mint-darker);
  --ct-cyan: var(--mint);
  --ct-red: var(--coral);
  --ct-yellow: var(--amber);
  --ct-orange: var(--coral);
  --ct-panel: var(--surface);
  --ct-panel-line: var(--line);
  --ct-mono: var(--font-mono);
}

html, body.ct-body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ct-text);
  font-family: var(--ct-mono);
  font-size: 14px;
  overflow: hidden;
  letter-spacing: 0.02em;
}

/* Background canvas is retained in the DOM for script compatibility but
   no longer painted - the dashboards share the site's flat background. */
#ct-bg,
.ct-grid-overlay,
.ct-scanlines,
.ct-vignette {
  display: none;
}

.ct-topbar, .ct-grid, .ct-ticker { position: relative; z-index: 10; }

/* ──── Top bar ──── */

.ct-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.1rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}
.ct-head-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
}
.ct-brand {
  display: flex; align-items: baseline; gap: 0.6rem;
  font-weight: 600;
}
.ct-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--mint-deep);
  animation: ct-blink 2.4s ease-in-out infinite;
  align-self: center;
}
@keyframes ct-blink { 0%,100% {opacity:1} 50% {opacity:0.45} }
.ct-title {
  font-family: var(--font-display);
  color: var(--text-0);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}
.ct-sub { color: var(--text-3); font-size: 0.72rem; letter-spacing: 0.06em; }

.ct-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.ct-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.62rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.ct-nav-link:hover,
.ct-nav-link:focus-visible,
.ct-nav-dropdown:hover > .ct-nav-link,
.ct-nav-dropdown:focus-within > .ct-nav-link {
  color: var(--mint);
  border-color: var(--mint-deep);
  background: color-mix(in srgb, var(--mint-deep) 8%, transparent);
}
.ct-nav-link.is-active {
  color: var(--bg-0);
  border-color: var(--mint-deep);
  background: var(--mint-deep);
}
.ct-nav-dropdown {
  position: relative;
}
.ct-nav-caret {
  font-size: 0.92em;
  transition: transform 0.15s ease;
}
.ct-nav-dropdown:hover .ct-nav-caret,
.ct-nav-dropdown:focus-within .ct-nav-caret {
  transform: rotate(180deg);
}
.ct-nav-menu {
  position: absolute;
  top: calc(100% + 0.42rem);
  left: 0;
  min-width: 15rem;
  display: none;
  flex-direction: column;
  padding: 0.35rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
  z-index: 40;
}
.ct-nav-dropdown:hover > .ct-nav-menu,
.ct-nav-dropdown:focus-within > .ct-nav-menu {
  display: flex;
}
.ct-nav-menu a {
  display: block;
  padding: 0.46rem 0.8rem;
  color: var(--text-1);
  text-decoration: none;
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.ct-nav-menu a:hover,
.ct-nav-menu a:focus-visible {
  color: var(--mint-deep);
  background: var(--bg-1);
}
.ct-nav-menu a.is-active {
  color: var(--bg-0);
  background: var(--mint-deep);
}

.ct-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}
.ct-pill {
  font-family: var(--ct-mono); font-size: 0.68rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.ct-pill.ok    { color: var(--mint-deep); }
.ct-pill.warn  { color: var(--amber); }
.ct-pill.alert { color: var(--coral); }
.ct-pulse {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: ct-pulse 2s ease-in-out infinite;
}
@keyframes ct-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.3); }
}
.ct-clock {
  font-family: var(--ct-mono); font-size: 0.78rem;
  color: var(--text-0); margin-left: 0.6rem;
  letter-spacing: 0.08em;
}

/* ──── Main grid ──── */
/* LEFT (data lists)  |  MIDDLE (map, full height)  |  RIGHT (news+research+sources) */
.ct-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 0.7rem;
  padding: 0.7rem 1.1rem 2.2rem;
  height: calc(100vh - 80px);
  box-sizing: border-box;
}
.ct-col { display: flex; flex-direction: column; gap: 0.7rem; min-height: 0; }

/* Left column: 4 panels share the height. Stats panel (Indicators) has its own min height */
.ct-col-left > .ct-panel { flex: 1 1 0; min-height: 0; }
.ct-col-left > .ct-panel-stats { flex: 0 0 auto; }

/* Middle column: single panel fills it entirely */
.ct-col-mid > .ct-panel-map-full { flex: 1 1 0; min-height: 0; }

/* Right column: three panels share the height equally (1/3 segments) */
.ct-col-right > .ct-panel { flex: 1 1 0; min-height: 0; }

@media (max-width: 1280px) {
  .ct-grid { grid-template-columns: 1fr 1.4fr; }
  .ct-col-right { display: none; }
}
@media (max-width: 760px) {
  .ct-topbar { align-items: flex-start; }
  .ct-head-left, .ct-status { width: 100%; }
  .ct-status { margin-left: 0; justify-content: flex-start; }
  .ct-nav-menu { position: static; min-width: 0; margin-top: 0.35rem; }
  .ct-grid { grid-template-columns: 1fr; }
  .ct-col-mid { display: none; }
}

/* ──── Panels ──── */

.ct-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s;
}
.ct-panel:hover { border-color: var(--line-strong); }

.ct-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.ct-panel-h {
  font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}
.ct-tag {
  font-size: 0.6rem; padding: 0.1rem 0.5rem;
  color: var(--mint-deep);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--mint-deep) 8%, transparent);
  border-radius: 999px;
  letter-spacing: 0.1em;
  text-decoration: none;
}
.ct-tag-link {
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ct-tag-link:hover {
  background: var(--mint-deep);
  color: var(--bg-0);
}

/* ──── Lists (skeleton state until JS populates) ──── */

.ct-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.ct-list li {
  display: flex; gap: 0.6rem; align-items: baseline;
  padding: 0.32rem 0.8rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}
.ct-list li:hover { background: color-mix(in srgb, var(--mint-deep) 5%, transparent); }
.ct-list li.ct-skel { animation: ct-pulse-row 1.6s ease-in-out infinite; }
@keyframes ct-pulse-row { 0%,100% { opacity: 0.4 } 50% { opacity: 0.85 } }

/* Clickable rows wrap their content in <a>. Make the entire row a hit target. */
.ct-list li a.ct-row {
  display: flex; gap: 0.6rem; align-items: baseline;
  flex: 1; min-width: 0;
  color: inherit; text-decoration: none;
  border: none;
}
.ct-list li a.ct-row:hover {
  color: var(--mint);
}
.ct-list li:has(a.ct-row) {
  padding: 0;
}
.ct-list li:has(a.ct-row) a.ct-row {
  padding: 0.32rem 0.8rem;
}

.ct-sk-tag {
  color: var(--mint-darker);
  font-size: 0.7rem; letter-spacing: 0.08em;
}
.ct-sk-line {
  flex: 1;
  height: 0.6rem;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--mint-deep) 12%, transparent),
    color-mix(in srgb, var(--mint-deep) 4%, transparent));
  border-radius: 1px;
}

/* ──── Trusted sources list (static curated links) ──── */
.ct-sources li { padding: 0; }
.ct-sources li a {
  display: flex; gap: 0.6rem; align-items: baseline;
  padding: 0.42rem 0.8rem;
  color: inherit; text-decoration: none;
  border: none;
  width: 100%;
}
.ct-sources li a:hover {
  color: var(--mint);
  background: color-mix(in srgb, var(--mint-deep) 5%, transparent);
}
.ct-sources .ct-sk-tag {
  color: var(--mint-deep);
  min-width: 5.5em;
}
.ct-src-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ──── Map ──── */

.ct-panel-map { flex: 1; min-height: 0; }
.ct-map {
  flex: 1; min-height: 0;
  background: var(--bg-2);
  cursor: grab;
}
.ct-map:active { cursor: grabbing; }
.ct-map.leaflet-container { background: var(--bg-2) !important; }
.ct-map .leaflet-control-attribution {
  background: color-mix(in srgb, var(--bg-deep) 75%, transparent) !important;
  color: var(--text-2) !important;
  font-size: 9px !important;
}
.ct-map .leaflet-control-attribution a { color: var(--mint-deep); }
.ct-map .leaflet-control-zoom {
  display: block;
  margin: 0.7rem !important;
  border: none !important;
  box-shadow: none !important;
}
.ct-map .leaflet-control-zoom a {
  width: 30px;
  height: 30px;
  line-height: 28px;
  border: 1px solid var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--text-0) !important;
}
.ct-map .leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
  color: var(--mint) !important;
}
.ct-map .leaflet-popup-content-wrapper,
.ct-map .leaflet-popup-tip {
  background: var(--surface);
  color: var(--text-1);
}
.ct-map .leaflet-popup-content {
  margin: 0.75rem 0.85rem;
  font-family: var(--ct-mono);
  font-size: 0.8rem;
  line-height: 1.45;
}
.ct-map .leaflet-popup-close-button {
  color: var(--text-2) !important;
}
/* Attack markers */
.ct-attack-dot {
  border-radius: 50%;
  background: color-mix(in srgb, var(--coral) 70%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--coral) 25%, transparent);
  animation: ct-mapdot 2.2s ease-in-out infinite;
}
@keyframes ct-mapdot {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50%      { transform: scale(1.4); opacity: 0.45; }
}

/* ──── Stats panel ──── */

.ct-panel-stats { flex-shrink: 0; }
.ct-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--line);
  flex: 1;
}
.ct-stat {
  background: var(--surface);
  padding: 0.55rem 0.8rem;
  display: flex; flex-direction: column; justify-content: center;
}
.ct-stat-lbl {
  font-size: 0.6rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-2);
}
.ct-stat-val {
  font-size: 1.5rem; font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-0); line-height: 1.05;
  margin-top: 0.2rem;
}
.ct-stat-val.red    { color: var(--coral); }
.ct-stat-val.yellow { color: var(--amber); }
.ct-stat-val.cyan   { color: var(--mint-deep); }

/* ──── Bottom ticker ──── */

.ct-ticker {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 36px; overflow: hidden;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.ct-ticker-track {
  display: flex; gap: 4rem;
  white-space: nowrap;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  line-height: 36px;
  color: var(--text-2);
  animation: ct-marquee 70s linear infinite;
  padding-left: 100%;
}
@keyframes ct-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.ct-ticker-item { display: inline-block; }
.ct-ticker-item .sev-crit  { color: var(--coral); }
.ct-ticker-item .sev-high  { color: var(--coral); }
.ct-ticker-item .sev-med   { color: var(--amber); }
.ct-ticker-item .sev-info  { color: var(--mint-deep); }
.ct-ticker-item .ct-cve-id { color: var(--amber); }

/* ──── Scrollbar styling ──── */
.ct-list::-webkit-scrollbar { width: 6px; }
.ct-list::-webkit-scrollbar-track { background: transparent; }
.ct-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.ct-list::-webkit-scrollbar-thumb:hover { background: var(--mint-deep); }

/* ──── Reduced motion ──── */
@media (prefers-reduced-motion: reduce) {
  .ct-dot, .ct-pulse, .ct-attack-dot, .ct-list li.ct-skel { animation: none; }
  .ct-ticker-track { animation: none; }
}
