/* Readable opening view inside the existing map panel. */

#map.gateway-mode {
  overflow: auto;
  touch-action: pan-y;
}

#map.gateway-mode #network {
  display: none;
}

#map.gateway-mode #hoverCard {
  display: none;
}

.cluster-gateways {
  padding: 22px;
}

.cluster-gateways[hidden] {
  display: none;
}

.gateway-intro {
  margin-bottom: 20px;
}

.gateway-intro h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  color: var(--ink, #14251f);
  margin-bottom:0;
}

.gateway-intro p {
  margin: 0;
  color: var(--muted, #5d6d66);
  line-height: 1;
  font-style:italic;
}

.gateway-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.gateway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.gateway-card {
  --gateway-color: #0f6b57;

  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 2px solid var(--gateway-color);
  border-radius: 16px;
  background: #fffdf7;
  box-shadow: 0 5px 16px rgba(20, 37, 31, 0.06);
}

.gateway-card h3 {
  margin: 0 0 8px;
  color: var(--gateway-color);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  line-height: 1.15;
}

.gateway-description {
  margin: 0 0 14px;
  color: #43534d;
  font-size: 0.9rem;
  line-height: 1.45;
}

.gateway-count {
  margin: 0 0 10px;
  color: var(--muted, #5d6d66);
  font-size: 0.78rem;
}

.gateway-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

/* Readable clickable node examples. */
.gateway-node-button {
  padding: 9px 11px;
  border: 1px solid var(--gateway-color, #0f6b57);
  border-radius: 10px;
  background: white;
  color: var(--ink, #14251f);
  font-size: 0.9rem;
  line-height: 1.3;
  text-align: left;
}

.gateway-node-button:hover {
  border-color: var(--gateway-color, #0f6b57);
  background: #eef3ef;
  color: var(--ink, #14251f);
}

.gateway-explore {
  align-self: flex-start;
  margin-top: auto;
  border-color: var(--gateway-color);
  font-weight: 750;
}

.gateway-node-button:focus-visible,
.gateway-explore:focus-visible {
  outline: 3px solid var(--gold, #c79024);
  outline-offset: 3px;
}

/* Expanded cluster: readable node choices, not a tiny fitted graph. */
.gateway-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.gateway-node-card {
  display: block;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--gateway-color, #0f6b57);
  border-left-width: 5px;
  border-radius: 12px;
  background: #fffdf7;
  color: var(--ink, #14251f);
  text-align: left;
}

.gateway-node-card:hover {
  background: #eef3ef;
  color: var(--ink, #14251f);
}

.gateway-node-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 1rem;
  line-height: 1.3;
}

.gateway-node-card span {
  display: block;
  color: #43534d;
  font-size: 0.85rem;
  line-height: 1.45;
}

.gateway-node-card small {
  display: block;
  margin-top: 10px;
  color: var(--gateway-color, #0f6b57);
  font-weight: 750;
}

@media (max-width: 600px) {
  .cluster-gateways {
    padding: 14px;
  }

  .gateway-grid,
  .gateway-node-grid {
    grid-template-columns: 1fr;
  }
}

/* Gateway view: show every card without an internal scrollbar. */
#map.gateway-mode {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

/* Desktop: align the bottoms of the map and information panels. */
@media (min-width: 1181px) {
  .network-layout:has(#map.gateway-mode) {
    align-items: stretch;
  }

  .network-layout:has(#map.gateway-mode) > .map-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .network-layout:has(#map.gateway-mode) #map {
    flex: 1;
  }

  .network-layout:has(#map.gateway-mode) > .detail-panel {
    align-self: stretch;
    height: auto;
    max-height: none;
    position: static;
  }
}

/* Arrange the sample nodes with room for their labels. */
.gateway-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

/* The entire area remains a clickable, accessible button. */
.gateway-node-button {
  position: relative;
  display: grid;
  place-items: center;

  width: 100%;
  min-height: 110px;
  padding: 12px 6px;

  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink, #14251f);

  text-align: center;
}

/* Match the map's colored circle and white outline. */
.gateway-node-circle {
  position: absolute;

  width: 60px;
  height: 60px;

  border:5px solid var(--node-color);
  border-radius: 50%;
  background: var(--node-color, var(--gold));

  box-shadow: 0 3px 6px rgba(20, 37, 31, 0.15);
  pointer-events: none;
}

/* Label overlays the circle, like the map's SVG text. */
.gateway-node-label {
  position: relative;
  z-index: 1;

  max-width: 150px;

  color: var(--ink, #14251f);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;

  white-space: pre-line;
  overflow-wrap: normal;

  /* Pale outline approximates the map's text stroke. */
  text-shadow:
    -1px -1px 0 #fffdf7,
     1px -1px 0 #fffdf7,
    -1px  1px 0 #fffdf7,
     1px  1px 0 #fffdf7,
    -2px  0   0 #fffdf7,
     2px  0   0 #fffdf7,
     0   -2px 0 #fffdf7,
     0    2px 0 #fffdf7;

  pointer-events: none;
}

/* Keep the circle treatment when hovering. */
.gateway-node-button:hover {
  border: 0;
  background: transparent;
  color: var(--ink, #14251f);
}

.gateway-node-button:hover .gateway-node-circle,
.gateway-node-button:focus-visible .gateway-node-circle {
  border-color: var(--gold, #c79024);
}

/* Clear keyboard focus without enlarging into neighboring examples. */
.gateway-node-button:focus-visible {
  outline: 3px solid var(--gold, #c79024);
  outline-offset: 2px;
}

.gateway-examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.gateway-node-button {
  min-width: 0;
}

.gateway-node-label {
  width: 100%;
  max-width: 150px;
  overflow-wrap: anywhere;
}
/* Dim examples without videos, but keep them clickable. */
.gateway-node-button.gateway-without-video,
.gateway-node-card.gateway-without-video {
  opacity: 0.3;
}

/* Keep hovered and keyboard-focused topics readable. */
.gateway-node-button.gateway-without-video:hover,
.gateway-node-button.gateway-without-video:focus-visible,
.gateway-node-card.gateway-without-video:hover,
.gateway-node-card.gateway-without-video:focus-visible {
  opacity: 1;
}

.gateway-video-badge {
  position: absolute;
  top: -6px;
  right: -6px;

  display: grid;
  place-items: center;

  width: 20px;
  height: 20px;

  border: 3px solid var(--node-color);
  border-radius: 50%;
  background: #fff;
  color: var(--node-color);

  font-size: 10px;
  line-height: 1;
  text-indent: 1px;

  pointer-events: none;
}

.gateway-node-button {
  transition: transform 180ms ease;
  transform-origin: center;
}

.gateway-node-button:hover {
  transform: scale(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .gateway-node-button {
    transition: none;
  }
}