:root {
  --wall-bg-top: #050A0F;
  --wall-bg-bottom: #0A1218;
  --wall-cyan: #22E3C0;
  --wall-red: #FF4D5E;
  --wall-text: #DCEDE9;
  --wall-muted: #7C918C;
  --wall-panel-bg: rgba(255, 255, 255, 0.03);
  --wall-panel-border: rgba(34, 227, 192, 0.12);
  --wall-gap: clamp(16px, 1.2vw, 24px);
  --font-thai: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--wall-bg-top) 0%, var(--wall-bg-bottom) 100%);
  color: var(--wall-text);
  font-family: var(--font-thai);
}

/* ---------------------------------------------------------------- */
/* Grid frame — fixed zones, nothing floats                          */
/* ---------------------------------------------------------------- */

.wall-grid {
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: var(--wall-gap);
  gap: var(--wall-gap);
  grid-template-columns: minmax(0, 13fr) minmax(0, 7fr);
  grid-template-rows: 72px minmax(0, 1fr) 132px 110px;
  grid-template-areas:
    "header    header"
    "graph     spotlight"
    "graph     feed"
    "kpis      kpis";
}

/* ---------------------------------------------------------------- */
/* Header                                                            */
/* ---------------------------------------------------------------- */

.wall-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 6px;
}

.wall-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 200ms ease;
}

.wall-brand:hover,
.wall-brand:focus-visible {
  opacity: 0.85;
}

.wall-brand__mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--header-brand-mark, 52px);
  height: var(--header-brand-mark, 52px);
  overflow: visible;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.wall-brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wall-brand__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.wall-brand__name {
  font-family: var(--font-thai);
  font-size: var(--header-brand-name, 24px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.wall-brand__system {
  font-family: var(--font-thai);
  font-size: var(--header-brand-sub, 13px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.02em;
  overflow-wrap: break-word;
}

.wall-clock {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.wall-clock time {
  font: 600 30px/1 var(--font-mono);
  color: #F2FBF8;
  font-variant-numeric: tabular-nums;
}

.wall-clock span {
  font-size: 14px;
  color: var(--wall-muted);
}

/* ---------------------------------------------------------------- */
/* Shared panel style                                                */
/* ---------------------------------------------------------------- */

.wall-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 16px 18px;
  background: var(--wall-panel-bg);
  border: 1px solid var(--wall-panel-border);
  border-radius: 12px;
  overflow: hidden;
}

.wall-panel__head {
  margin: 0 0 10px;
  font: 600 13px/1.2 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wall-muted);
}

.wall-graph__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-width: 0;
}

.wall-graph__heading .wall-panel__head {
  margin: 0;
  flex: 0 0 auto;
}

.wall-scene-caption {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font: 500 13px/1.3 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--wall-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 400ms ease;
}

.wall-scene-caption.is-fading {
  opacity: 0;
}

.wall-link-legend {
  flex: 0 1 auto;
  max-width: 42%;
  color: var(--wall-muted);
  font: 500 11px/1.3 var(--font-thai);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

/* ---------------------------------------------------------------- */
/* Graph zone                                                        */
/* ---------------------------------------------------------------- */

.wall-graph {
  grid-area: graph;
}

.wall-graph__stage {
  flex: 1;
  min-height: 0;
}

#wall-constellation {
  display: block;
  width: 100%;
  height: 100%;
}

.wall-node circle.core {
  fill: var(--wall-cyan);
  opacity: 0.3;
  transition: opacity 1.2s ease, fill 1.2s ease;
}

.wall-node.is-regional circle.core {
  fill: var(--wall-red);
}

.wall-node circle.ring {
  fill: none;
  stroke: var(--wall-cyan);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.wall-node.is-dimmed {
  opacity: 0.1;
}

.wall-node.is-neighbor {
  opacity: 0.88;
}

.wall-node.is-neighbor circle.core {
  opacity: 0.7;
}

.wall-node.is-focus {
  opacity: 1;
}

.wall-node.is-focus circle.core {
  opacity: 1;
  filter: drop-shadow(0 0 14px rgba(34, 227, 192, 0.65));
}

.wall-node.is-focus.is-regional circle.core {
  filter: drop-shadow(0 0 14px rgba(255, 77, 94, 0.65));
}

.wall-node.is-focus circle.ring {
  opacity: 0.9;
}

.wall-node.is-focus.is-regional circle.ring {
  stroke: var(--wall-red);
}

.wall-node.is-sector-match {
  opacity: 1;
}

.wall-node.is-sector-match circle.core {
  opacity: 0.92;
}

.wall-node.is-sector-match text {
  opacity: 1;
}

.wall-node text {
  fill: #F2FBF8;
  font: 600 17px/1 var(--font-thai);
  paint-order: stroke;
  stroke: rgba(5, 10, 15, 0.85);
  stroke-width: 4px;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.wall-node.is-focus text,
.wall-node.is-neighbor text {
  opacity: 1;
}

.wall-link {
  stroke: var(--wall-cyan);
  stroke-opacity: 0.16;
  stroke-linecap: round;
  transition: stroke-opacity 1.2s ease;
}

.wall-link--evidence {
  stroke-opacity: 0.28;
  stroke-dasharray: none;
}

.wall-link--ttp {
  stroke-opacity: 0.14;
  stroke-dasharray: 5 6;
}

.wall-link.is-dimmed {
  stroke-opacity: 0.04;
}

.wall-link.is-focus {
  stroke-opacity: 0.5;
  stroke-dasharray: none;
}

.wall-ttp-link {
  fill: none;
  stroke: var(--wall-cyan);
  stroke-opacity: 0.55;
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* Spotlight detail panel                                            */
/* ---------------------------------------------------------------- */

.wall-spotlight {
  grid-area: spotlight;
  min-height: 0;
}

.wall-spotlight__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  opacity: 1;
  transition: opacity 400ms ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}

.wall-spotlight__body.is-fading {
  opacity: 0;
}

.wall-spotlight__eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--wall-cyan);
  text-transform: uppercase;
}

.wall-spotlight__region {
  color: var(--wall-red);
}

.wall-spotlight__name {
  margin: 8px 0 2px;
  font: 700 clamp(26px, 2.2vw, 34px)/1.15 var(--font-thai);
  color: #F7FDFB;
}

.wall-spotlight__aliases {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--wall-muted);
  overflow: visible;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wall-spotlight__block {
  margin-bottom: 10px;
}

.wall-spotlight__block h4 {
  margin: 0 0 6px;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wall-muted);
}

.wall-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wall-chips .chip {
  padding: 4px 10px;
  border: 1px solid rgba(34, 227, 192, 0.25);
  border-radius: 999px;
  font-size: 13px;
  color: var(--wall-text);
  white-space: nowrap;
}

.wall-spotlight__summary {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: #B9CCC7;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 0 1 auto;
}

.wall-spotlight__profile {
  display: none;
  margin-top: auto;
  padding-top: 12px;
  color: var(--wall-cyan);
  font: 600 15px/1.3 var(--font-thai);
  text-decoration: none;
}

.wall-spotlight__profile:hover,
.wall-spotlight__profile:focus {
  text-decoration: underline;
}

@media (min-width: 900px) {
  .wall-node {
    cursor: pointer;
  }

  .wall-spotlight__profile:not([hidden]) {
    display: inline-flex;
  }
}

/* ---------------------------------------------------------------- */
/* Ransomware feed ticker                                            */
/* ---------------------------------------------------------------- */

.wall-feed {
  grid-area: feed;
  min-height: 0;
}

.wall-feed__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.wall-feed__list {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template: 1fr / 1fr;
}

.wall-feed__row {
  grid-area: 1 / 1;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
  border: 1px solid rgba(34, 227, 192, 0.14);
  border-left-width: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 420ms ease, transform 420ms ease;
}

.wall-feed__row.is-entering {
  opacity: 0;
  transform: translateY(12px);
}

.wall-feed__row.is-leaving {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.wall-feed__row.is-active {
  opacity: 1;
  transform: translateY(0);
}

.wall-feed__row--regional {
  border-color: rgba(255, 77, 94, 0.4);
  background: rgba(255, 77, 94, 0.05);
}

.wall-feed__row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.wall-feed__group {
  font: 600 14px/1.2 var(--font-mono);
  color: var(--wall-cyan);
  white-space: nowrap;
}

.wall-feed__row--regional .wall-feed__group {
  color: var(--wall-red);
}

.wall-feed__victim {
  flex: 1;
  min-width: 0;
  font: 600 16px/1.3 var(--font-thai);
  color: #F2FBF8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wall-feed__meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--wall-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wall-feed__row--regional .wall-feed__meta strong {
  color: var(--wall-red);
  font-weight: 600;
}

.wall-feed__empty {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  text-align: center;
  font-size: 15px;
  color: var(--wall-muted);
  pointer-events: none;
}

.wall-feed__empty p {
  margin: 0;
  max-width: 18ch;
  line-height: 1.4;
}

.wall-feed__stage.is-syncing .wall-feed__empty {
  display: flex;
}

.wall-feed__stage.is-syncing .wall-feed__list {
  opacity: 0;
}

.wall-feed__pulse {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(34, 227, 192, 0.35);
  box-shadow: 0 0 0 0 rgba(34, 227, 192, 0.35);
  animation: wall-feed-pulse 1.8s ease-out infinite;
  position: relative;
  overflow: hidden;
}

.wall-feed__pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(34, 227, 192, 0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: wall-feed-sweep 2.2s ease-in-out infinite;
}

@keyframes wall-feed-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 227, 192, 0.35);
    transform: scale(0.96);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(34, 227, 192, 0);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 227, 192, 0);
    transform: scale(0.96);
  }
}

@keyframes wall-feed-sweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

/* ---------------------------------------------------------------- */
/* KPI bar                                                           */
/* ---------------------------------------------------------------- */

.wall-kpis {
  grid-area: kpis;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--wall-gap);
}

.wall-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  background: var(--wall-panel-bg);
  border: 1px solid var(--wall-panel-border);
  border-radius: 12px;
  text-align: center;
}

.wall-kpi__num {
  font: 600 clamp(44px, 3.4vw, 52px)/1 var(--font-mono);
  color: var(--wall-cyan);
  font-variant-numeric: tabular-nums;
}

.wall-kpi--risk .wall-kpi__num {
  color: var(--wall-red);
}

.wall-kpi__label {
  font-size: 14px;
  color: var(--wall-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* จอเล็ก — ซ้อนคอลัมน์เดียว เลื่อนแนวตั้งได้ (ขั้นต่ำ: ไม่พัง) */
@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .wall-grid {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(300px, 45vh) auto auto auto;
    grid-template-areas:
      "header"
      "graph"
      "spotlight"
      "feed"
      "kpis";
  }

  .wall-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wall-brand__system {
    max-width: 60vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wall-node circle.core,
  .wall-node circle.ring,
  .wall-node text,
  .wall-link,
  .wall-spotlight__body,
  .wall-feed__row {
    transition: none;
  }
}
