/* ============================================
   DefenceHQ — Global Threat Monitor
   ============================================ */

:root {
  --bg-primary:   #0D0D0D;
  --bg-secondary: #141414;
  --bg-tertiary:  #181818;
  --bg-elevated:  #1E1E1E;
  --bg-card:      #222222;
  --bg-surface:   #1A1A1A;

  --text-primary:   #ECECEC;
  --text-white:     #FFFFFF;
  --text-secondary: #CCCCCC;
  --text-muted:     #A5A5A5;
  --text-subtle:    #595959;
  --text-dim:       #454545;

  --accent-red: #E21B22;

  --border-muted:  #A5A5A5;
  --border-subtle: #454545;

  --font-family: "Rethink Sans", -apple-system, "system-ui", "Helvetica Neue", "Segoe UI", sans-serif;

  --header-height: 52px;
  --sheet-width: 40%;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Header --- */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-accent-bar {
  width: 4px;
  height: 24px;
  background: var(--accent-red);
  display: block;
  flex-shrink: 0;
}

.header-logo {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-white);
  letter-spacing: 0.5px;
}

.header-logo-bold {
  font-weight: 700;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #4ADE80;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: #4ADE80;
  border-radius: 50%;
  animation: live-pulse 2s ease-in-out infinite;
}

.header-time {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* --- Map --- */
#map {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: var(--bg-primary);
}

/* --- Leaflet Overrides --- */
.leaflet-control-zoom {
  border: none !important;
}

.leaflet-control-zoom a {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 0 !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  transition: background 0.15s, color 0.15s;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-elevated) !important;
  color: var(--text-white) !important;
}

.leaflet-control-attribution {
  background: rgba(13, 13, 13, 0.85) !important;
  color: var(--text-subtle) !important;
  font-size: 10px !important;
  font-family: var(--font-family) !important;
  border-radius: 0 !important;
}

.leaflet-control-attribution a {
  color: var(--text-dim) !important;
}

/* --- Pulse Markers --- */
.pulse-marker {
  background: transparent !important;
  border: none !important;
}

.pulse-dot {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pulse-core {
  width: var(--dot-size, 10px);
  height: var(--dot-size, 10px);
  background: var(--dot-color, #E21B22);
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 8px 2px var(--dot-color, #E21B22);
  transition: transform 0.2s ease;
}

.pulse-dot:hover .pulse-core {
  transform: scale(1.5);
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--dot-size, 10px);
  height: var(--dot-size, 10px);
  border-radius: 50%;
  border: 1.5px solid var(--dot-color, #E21B22);
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  animation: ring-expand var(--pulse-speed, 2s) ease-out infinite;
}

.pulse-ring-delayed {
  animation-delay: calc(var(--pulse-speed, 2s) * 0.5);
}

/* --- Custom Tooltip --- */
.dark-tooltip {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  font-family: var(--font-family) !important;
  font-size: 12px !important;
  box-shadow: none !important;
  white-space: nowrap;
}

.dark-tooltip::before {
  display: none !important;
}

.tooltip-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-white);
  margin-bottom: 3px;
}

.tooltip-type {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tooltip-severity {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

/* --- Legend --- */
.legend-control {
  background: rgba(13, 13, 13, 0.92) !important;
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
  font-family: var(--font-family);
  border-radius: 0;
}

.legend-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* --- Sheet Overlay --- */
#sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1500;
}

/* --- Detail Sheet --- */
#detail-sheet {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--sheet-width);
  max-width: 560px;
  height: calc(100% - var(--header-height));
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detail-sheet.open {
  transform: translateX(0);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 12px;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sheet-accent-bar {
  width: 4px;
  height: 20px;
  background: var(--accent-red);
  display: block;
  flex-shrink: 0;
}

#sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sheet-close {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  font-family: var(--font-family);
  line-height: 1;
}

#sheet-close:hover {
  color: var(--text-white);
  border-color: var(--text-muted);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.sheet-body::-webkit-scrollbar {
  width: 4px;
}

.sheet-body::-webkit-scrollbar-track {
  background: transparent;
}

.sheet-body::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
}

/* --- Sheet Content --- */
.sheet-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg-primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.conflict-type-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sheet-images {
  margin-bottom: 20px;
}

.sheet-images img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 0;
}

.sheet-images img + img {
  margin-top: 8px;
}

.sheet-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-text {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 24px;
}

.sheet-links {
  margin-bottom: 24px;
}

.sheet-link {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-family);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-link + .sheet-link {
  margin-top: 6px;
}

.sheet-link::before {
  content: "\2192\00a0\00a0";
  color: var(--text-dim);
}

.sheet-link:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
  border-color: var(--text-muted);
}

.sheet-timestamp {
  font-size: 11px;
  color: var(--text-subtle);
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .header-center {
    display: none;
  }

  .header-time {
    font-size: 12px;
  }

  #sheet-overlay.visible {
    display: block;
  }

  #detail-sheet {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    height: 72vh;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    transform: translateY(100%);
  }

  #detail-sheet.open {
    transform: translateY(0);
  }

  .sheet-head {
    position: relative;
    padding-top: 22px;
  }

  .sheet-head::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--border-subtle);
  }

  #sheet-title {
    font-size: 15px;
  }

  .sheet-body {
    padding: 16px;
  }

  .legend-control {
    display: none !important;
  }
}

/* --- Animations --- */
@keyframes ring-expand {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
  }
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
