/* ============================================================
   ADGRID.IO — Terminal CSS
============================================================ */

/* ============================================================
   MODALS
============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #0d0d0d;
  border: 1px solid #1e1e1e;
  box-shadow: 0 0 0 1px #00ff4110, 0 0 60px #00000090;
  width: 520px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}
.modal-box-wide { width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1e1e1e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #00ff41;
  shrink: 0;
}

.modal-close {
  color: #444;
  font-size: 12px;
  line-height: 1;
  padding: 2px 6px;
  border: 1px solid #1e1e1e;
  border-radius: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.modal-close:hover { color: #ff4444; border-color: #ff444430; }

.modal-body {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e #0d0d0d;
}

.modal-section {
  padding: 16px;
  border-bottom: 1px solid #0f0f0f;
  font-size: 11px;
  line-height: 1.7;
  color: #777;
}
.modal-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

/* --- Billboard Grid --------------------------------------- */
.billboard-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);

  flex-shrink: 0;

  border: 1px solid #1e1e1e;
  box-shadow:
    0 0 0 1px #00ff4110,
    0 0 60px #00ff4108,
    inset 0 0 40px #00000080;

  /* Do NOT set overflow:hidden — tooltips must escape cell bounds */
  overflow: visible;
}

/* --- Block Cell ------------------------------------------- */
.block-cell {
  border: 1px solid #151515;
  background-color: #111111;
  overflow: visible;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.owned-block {
  display: flex;
  background-color: #0d1a0d;
  border-color: #00ff4120;
  text-decoration: none;
  overflow: hidden;
}

.owned-block:hover {
  background-color: #0f200f;
  box-shadow: 0 0 16px #00ff4130;
  z-index: 10;
  position: relative;
}

.unowned-block {
  border-color: #1a1a1a;
}

.unowned-block:hover {
  background-color: #0d1a0d;
  border-color: #00ff4155;
  box-shadow: inset 0 0 12px #00ff4108;
}

/* --- Tooltip edge-clipping -------------------------------- */
/* Left column: anchor tooltip to left edge instead of center */
.block-cell:nth-child(16n+1) .tooltip-panel {
  left: 0;
  right: auto;
  transform: translateX(0);
}
/* Right column: anchor tooltip to right edge */
.block-cell:nth-child(16n) .tooltip-panel {
  left: auto;
  right: 0;
  transform: translateX(0);
}

/* Top rows: flip tooltip below the cell instead of above */
.billboard-grid > .block-cell:nth-child(-n+32) .tooltip-panel {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 8px;
}

/* --- War Feed Ticker -------------------------------------- */
.war-feed-ticker {
  display: inline-block;
  will-change: transform;
}

/* --- Scrollbar styling ------------------------------------ */
html {
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e #0d0d0d;
}

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: #0d0d0d; }
::-webkit-scrollbar-thumb  { background: #1e1e1e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #00ff4133; }

/* --- Neon text glow utilities ----------------------------- */
.text-glow-green  { text-shadow: 0 0 8px #00ff4180, 0 0 16px #00ff4140; }
.text-glow-purple { text-shadow: 0 0 8px #7b2fff80, 0 0 16px #7b2fff40; }

/* ============================================================
   PHASE 2: Side Panel
============================================================ */

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background-color: #0d0d0d;
  border-left: 1px solid #1e1e1e;
  box-shadow: -8px 0 40px #00000080, -1px 0 0 #00ff4110;
  z-index: 9000;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

.side-panel.panel-open {
  transform: translateX(0);
  pointer-events: auto;
}

.panel-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 4px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

.panel-input {
  width: 100%;
  background-color: #111;
  border: 1px solid #1e1e1e;
  color: #e0e0e0;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.panel-input:focus {
  border-color: #00ff4155;
  box-shadow: 0 0 0 2px #00ff4110;
}

.panel-input::placeholder {
  color: #2a2a2a;
}

/* Scrollable form area */
.panel-inner form > div {
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e #0d0d0d;
}

/* empty:hidden CSS polyfill — hide error div when it has no text */
#panel-error:empty {
  display: none;
}

/* ============================================================
   HEATMAP / TRAFFIC VIEW
============================================================ */

/* Fade all block content when heatmap is active */
.billboard-grid.heatmap-active .owned-block,
.billboard-grid.heatmap-active .unowned-block {
  opacity: 0.12;
  transition: opacity 0.3s;
}

/* Grid-level glow so there's an unmistakable mode shift */
.billboard-grid.heatmap-active {
  box-shadow:
    0 0 0 1px #00e5ff22,
    0 0 60px #00e5ff18,
    inset 0 0 40px #00000080;
}

/* Thermal overlay on each cell via ::after pseudo-element */
.billboard-grid.heatmap-active .block-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--heat-color, rgba(0, 30, 80, 0.72));
  pointer-events: none;
  z-index: 6;
  transition: background-color 0.4s;
}

/* Keep tooltip above the heatmap overlay */
.billboard-grid.heatmap-active .tooltip-panel {
  z-index: 9999;
}

/* Active state for the Traffic View button */
.heatmap-btn-active {
  color: #00e5ff !important;
  border-color: rgba(0, 229, 255, 0.35) !important;
  text-shadow: 0 0 8px #00e5ff60;
}

/* Click counter glow */
.click-counter {
  text-shadow: 0 0 12px #00ff4130;
  font-variant-numeric: tabular-nums;
}


/* Trending pulse dot on blocks with 1h activity */
@keyframes trending-pulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.6); }
}
.trending-pulse {
  animation: trending-pulse 1.8s ease-in-out infinite;
}

/* Flash & Fade — row scan on block click */
@keyframes cell-flash-scan {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes block-click-glow {
  0%   { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.85), 0 0 18px rgba(255,255,255,0.3); }
  100% { box-shadow: inset 0 0 0 0px transparent, 0 0 0px transparent; }
}

.flash-scan::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  animation: cell-flash-scan 0.45s ease-out var(--flash-delay, 0ms) forwards;
  pointer-events: none;
  z-index: 55;
}

.click-glow {
  animation: block-click-glow 2s ease-out forwards;
}

/* ── Event Log Drawer ─────────────────────────────────────────────────────── */

.event-log-drawer {
  position: fixed;
  bottom: 36px; /* footer h-9 */
  left: 0;
  right: 0;
  height: 220px;
  background: #070707;
  border-top: 1px solid #1e1e1e;
  display: flex;
  flex-direction: column;
  z-index: 8000;
  transform: translateY(calc(100% + 36px));
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 -4px 30px #00000090, 0 -1px 0 #00ff4110;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

.event-log-drawer.open {
  transform: translateY(0);
  pointer-events: auto;
}

/* ── First-visit overlay ──────────────────────────────────────────────────── */

#first-visit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.97);
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}
#first-visit-overlay.hidden { display: none; }

/* Attack pulse — block is under siege */
@keyframes attackPulse {
  0%, 100% { border-color: rgba(255, 68, 68, 0.85); box-shadow: 0 0 6px rgba(255,68,68,0.4); }
  50%       { border-color: rgba(255, 140, 0,  0.50); box-shadow: 0 0 2px rgba(255,140,0,0.2); }
}
.attack-active {
  animation: attackPulse 1s ease-in-out infinite;
  outline: 1px solid rgba(255, 68, 68, 0.7);
}

/* Estate shatter flash — fired when a block loses estate membership */
@keyframes shatter-flash {
  0%   { outline: 2px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 24px rgba(255,255,255,0.35), inset 0 0 12px rgba(255,255,255,0.15); }
  35%  { outline: 2px solid rgba(255, 68,  68,  0.80); box-shadow: 0 0 14px rgba(255, 68, 68, 0.25); }
  100% { outline: 2px solid transparent; box-shadow: none; }
}
.shatter-flash {
  animation: shatter-flash 0.55s ease-out forwards;
  z-index: 50;
}
