/* Live threat map: the landing page hero (public-hero.css) with the threat globe, then the activity band. */
.threat-map-page {
  --tm-botnet: #22d3ee;
  --tm-scanner: #a78bfa;
  --tm-heartbeat: #fb923c;
  background: linear-gradient(135deg, #0a0e17 0%, #1a103d 50%, #0a1a2e 100%);
  background-attachment: fixed;
  color: #e2e8f0;
  overflow-x: hidden;
}

.threat-map-page [data-source="botnet"] { --tm-color: var(--tm-botnet); }
.threat-map-page [data-source="scanner"] { --tm-color: var(--tm-scanner); }
.threat-map-page [data-source="heartbeat"] { --tm-color: var(--tm-heartbeat); }

.tm-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: .45rem;
  border-radius: 50%;
  background: var(--tm-color, #67e8f9);
  vertical-align: 1px;
}

/* Hero: the shared public hero at the landing page scale (landing.ejs), with the threat
   globe placed like the landing globe, running off the right edge. */
section.public-hero.tm-hero { min-height: 820px; }
.tm-hero .public-hero__layout { align-items: center; gap: 2rem; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.tm-hero .public-hero__copy { max-width: 600px; }
.tm-hero .ranking-header .public-hero__title { max-width: 600px; }
.tm-hero .public-hero__title > span { display: block; }
.tm-hero .ranking-header .public-hero__subtitle { max-width: 540px; }

.tm-total {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .6rem;
  align-items: baseline;
  margin: 1.75rem 0 0;
}

.tm-total-number {
  color: #f8fafc;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.tm-total-label { color: #a9b7ca; font-size: 1rem; }

.tm-status {
  margin: 1rem 0 0;
  color: #fbbf24;
  font-size: .85rem;
  line-height: 1.5;
}

.tm-controls { max-width: 560px; }

.tm-label {
  margin: 1.5rem 0 .6rem;
  color: #8ea1b6;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* Source tiles: count, legend colour and switch in one. Off keeps the count but hollows the dot. */
.tm-sources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem;
}

.tm-source {
  display: flex;
  min-width: 0;
  min-height: 44px;
  padding: .7rem .85rem .75rem;
  flex-direction: column;
  gap: .35rem;
  align-items: flex-start;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: 8px;
  background: rgba(10, 14, 23, .55);
  color: #e2e8f0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}

.tm-source[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--tm-color) 38%, transparent);
  background: color-mix(in srgb, var(--tm-color) 8%, rgba(10, 14, 23, .55));
}

.tm-source-name {
  display: flex;
  align-items: center;
  color: #a9b7ca;
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.tm-source-count {
  max-width: 100%;
  overflow: hidden;
  color: #f8fafc;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-source[aria-pressed="false"] .tm-source-count,
.tm-source[aria-pressed="false"] .tm-source-name { color: #64748b; }
.tm-source[aria-pressed="false"] .tm-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--tm-color); }

@media (hover: hover) {
  .tm-source:hover { border-color: color-mix(in srgb, var(--tm-color) 55%, transparent); }
}

/* The landing hero's secondary button. */
.tm-fullscreen {
  display: inline-flex;
  min-height: 2.75rem;
  margin-top: 1.25rem;
  padding: 0 1.25rem;
  gap: .55rem;
  align-items: center;
  border: 1px solid rgba(167, 139, 250, .5);
  border-radius: 8px;
  color: #a78bfa;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .2s ease, border-color .2s ease;
}

.tm-fullscreen:hover { border-color: #a78bfa; background: rgba(167, 139, 250, .1); }

.tm-fullscreen:focus-visible,
.tm-source:focus-visible {
  outline: 2px solid rgba(103, 232, 249, .55);
  outline-offset: 2px;
}

/* The globe stage. The sphere fills about 0.9 of the stage height (50 degree field of view),
   so the height sets its size. */
.tm-stage { position: relative; }

/* Desktop: a huge globe whose left edge sits just right of the copy column. */
@media (min-width: 1101px) {
  section.public-hero.tm-hero { min-height: calc(100vh - 3.5rem); min-height: calc(100svh - 3.5rem); }
  .tm-hero .public-hero__container { position: static; }
  .tm-hero .public-hero__layout { position: relative; display: grid; grid-template-columns: min(600px, calc(100vw - 660px)) 1fr; align-content: center; }
  .tm-hero .public-hero__copy { position: relative; z-index: 2; grid-column: 1; grid-row: 1; }

  .tm-stage {
    --tm-globe: clamp(900px, 80vw, 1180px);
    position: absolute;
    top: 50%;
    left: calc(min(600px, 100vw - 660px) + 2.5rem - var(--tm-globe) * .147);
    z-index: 1;
    width: calc(var(--tm-globe) * 1.2);
    height: var(--tm-globe);
    transform: translateY(-50%);
  }
}

@media (min-width: 1280px) {
  section.public-hero.tm-hero { min-height: calc(100vh - 4rem); min-height: calc(100svh - 4rem); }
}

.tm-arcs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tm-tip {
  position: absolute;
  z-index: 3;
  max-width: 260px;
  padding: .6rem .75rem;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 8px;
  background: rgba(10, 16, 36, .96);
  color: #e2e8f0;
  font-size: .78rem;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

.tm-tip strong { display: block; color: #f8fafc; font-weight: 600; }
.tm-tip span { display: block; color: #a9b7ca; }
.tm-tip[hidden], .tm-globe-note[hidden], .tm-status[hidden], .tm-note[hidden] { display: none; }

.tm-globe-note {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(320px, 80%);
  margin: 0;
  color: #a9b7ca;
  font-size: .85rem;
  text-align: center;
  transform: translate(-50%, -50%);
}

/* Activity band: headings on one row, the feed and the two country cards below them,
   so the boxes share their top and bottom edges. */
.tm-activity-grid {
  display: grid;
  grid-template-areas: "fh ch" "f c";
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  column-gap: clamp(2rem, 4vw, 3.5rem);
}

.tm-head--feed { grid-area: fh; }
.tm-head--countries { grid-area: ch; }
.tm-feed-panel { grid-area: f; }

.tm-countries {
  display: grid;
  grid-area: c;
  grid-template-rows: 1fr 1fr;
  gap: 1rem;
}

.tm-card {
  min-width: 0;
  padding: 1rem 1.1rem .6rem;
  border-radius: 8px;
  background: rgba(10, 14, 23, .72);
}

/* Headings use the shared public section title and lead. */
.tm-head .public-section-lead { margin: .9rem 0 1.5rem; }

.tm-feed,
.tm-rank {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-feed {
  border-radius: 8px;
  background: rgba(10, 14, 23, .72);
}

.tm-row {
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(100, 116, 139, .14);
}

.tm-row:last-child { border-bottom: 0; }
.tm-row.is-new { animation: tm-row-in .35s ease-out both; }

@keyframes tm-row-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.tm-row-route {
  overflow: hidden;
  color: #e2e8f0;
  font-size: .9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-row-meta {
  display: flex;
  margin-top: .3rem;
  align-items: center;
  gap: .55rem;
  color: #7c8aa0;
  font-size: .76rem;
}

.tm-row-meta time { margin-left: auto; white-space: nowrap; }

.tm-badge {
  padding: .05rem .4rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--tm-color) 16%, transparent);
  color: var(--tm-color);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.tm-note {
  margin: .9rem 0 0;
  color: #a9b7ca;
  font-size: .85rem;
}

.tm-list-title {
  margin: 0 0 .5rem;
  color: #8ea1b6;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.tm-rank li {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) auto;
  gap: .25rem .6rem;
  padding: .45rem 0;
  align-items: center;
}

.tm-rank-index { color: #7c8aa0; font-size: .78rem; font-variant-numeric: tabular-nums; }
.tm-rank-name { overflow: hidden; color: #e2e8f0; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.tm-rank-count { color: #a9b7ca; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .78rem; font-variant-numeric: tabular-nums; }

.tm-rank-bar {
  grid-column: 2 / 4;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(100, 116, 139, .18);
}

.tm-rank-bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #a78bfa, #22d3ee);
}

#tm-origin .tm-rank-bar span { background: linear-gradient(90deg, #f97316, #facc15); }
.tm-placeholder { display: block !important; color: #7c8aa0; font-size: .85rem; }

/* Tablets: copy above the globe, as on the landing page. */
@media (max-width: 1100px) {
  section.public-hero.tm-hero { min-height: 0; }
  .tm-hero .public-hero__layout { padding-top: 1.75rem; }

  .tm-hero .tm-stage {
    align-self: center;
    width: 100vw;
    max-width: none;
    height: min(110vw, 860px);
  }
}

@media (max-width: 860px) {
  .tm-activity-grid {
    grid-template-areas: "fh" "f" "ch" "c";
    grid-template-columns: minmax(0, 1fr);
  }

  .tm-head--countries { margin-top: 3rem; }
  .tm-countries { grid-template-rows: none; }
}

/* Phones: title and total, the globe, then the source tiles. */
@media (max-width: 700px) {
  .tm-copy { display: contents; }
  .tm-overview { order: 1; }
  .tm-controls { order: 3; width: 100%; }

  .tm-total-number { font-size: 1.75rem; }
  .tm-hero .tm-stage { order: 2; }
  .tm-label { margin-top: 0; }

  .tm-activity.public-band { padding: 3.5rem 1rem; }
  .tm-row { padding: .75rem .85rem; }
}

@media (max-width: 639px) {
  .tm-hero .public-hero__title > span { display: inline; }
}

/* Narrow phones: the tiles become rows, name on the left and count on the right. */
@media (max-width: 479px) {
  .tm-sources { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .tm-source { flex-direction: row; justify-content: space-between; align-items: center; padding: .65rem .9rem; }
  .tm-source-count { font-size: 1.1rem; }
  .tm-fullscreen { width: 100%; justify-content: center; }
}

/* A phone held sideways: the whole globe fits the screen below the header. */
@media (max-height: 500px) and (max-width: 1100px) {
  .tm-hero .tm-stage {
    width: min(620px, 100%);
    height: max(280px, calc(100svh - 76px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tm-row.is-new { animation: none; }
  .tm-source, .tm-fullscreen { transition: none; }
}
