/* ----------------------------------------------------------
 *  The Indie Web Map — page-specific styles
 *  Rides on top of the shared ../style.css design tokens.
 *  ---------------------------------------------------------- */

/* Let the map window use the full width of the page instead of the
   two-column grid the rest of the site uses. */
.page-map .site-main {
  grid-template-columns: 1fr;
}

/* Visually-hidden but still available to screen readers. */
.page-map .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toolbar above the graph */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}

.map-toolbar label {
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

.map-search {
  display: flex;
  gap: 0.4rem;
  flex: 1 1 240px;
  min-width: 200px;
}

.map-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  font-family: "VT323", "Courier New", monospace;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--bevel-mid);
  padding: 0.25rem 0.5rem;
}

.map-search input[type="search"]:focus {
  outline: 3px dashed var(--accent);
  outline-offset: 2px;
}

.map-btn {
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 2px solid var(--bevel-mid);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.18),
    inset -1px -1px 0 rgba(0, 0, 0, 0.45);
  padding: 0.3rem 0.7rem;
}

.map-btn:hover { border-color: var(--accent); color: var(--accent); }
.map-btn:active { transform: translateY(1px); }

.map-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
}

/* The canvas host */
.map-stage {
  position: relative;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 380px;
  border: 2px solid var(--bevel-dark);
  background:
    radial-gradient(circle at 50% 40%, rgba(0, 162, 255, 0.10), transparent 60%),
    var(--bg);
  overflow: hidden;
  touch-action: none; /* let the graph handle pan/zoom gestures */
}

.map-stage canvas { display: block; }

/* Floating readout for the selected node */
.map-readout {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  max-width: min(320px, calc(100% - 1.2rem));
  max-height: calc(100% - 1.2rem);
  overflow: auto;
  background: rgba(8, 16, 36, 0.92);
  border: 2px solid var(--bevel-mid);
  box-shadow: 0 0 0 2px var(--bevel-dark);
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  line-height: 1.35;
  display: none;
}

.map-readout.is-visible { display: block; }

.map-readout h3 {
  margin: 0 0 0.25rem;
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 1rem;
  color: var(--accent);
  word-break: break-word;
}

.map-readout .map-readout-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

/* "Visit site" button inside the readout */
.map-visit-btn {
  display: inline-block;
  margin: 0 0 0.5rem;
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--bg) !important;
  background: var(--accent);
  border: 2px solid var(--bevel-dark);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.35);
  padding: 0.3rem 0.6rem;
  word-break: break-word;
}

.map-visit-btn:visited { color: var(--bg) !important; }
.map-visit-btn:hover,
.map-visit-btn:focus-visible {
  background: var(--warn);
  color: #000 !important;
}

.map-readout-note {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

/* Neighbour chips that link somewhere get a small blue marker. */
.map-readout li.has-url {
  border-color: var(--link);
}
.map-readout li.has-url::after {
  content: " \2197";
  color: var(--link);
}

.map-readout ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.map-readout li {
  font-size: 0.85rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--bevel-mid);
  padding: 0.05rem 0.35rem;
  cursor: pointer;
  white-space: nowrap;
}

.map-readout li:hover { border-color: var(--accent); color: var(--accent); }

.map-readout .map-readout-close {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: var(--muted);
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.map-readout .map-readout-close:hover { color: var(--hot); }

/* Little hint / legend line */
.map-hint {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Loading / error states shown inside the stage before the graph loads */
.map-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.9rem;
}

.map-status.is-error { color: var(--hot); }

.map-count-pill {
  font-family: "Silkscreen", system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--bg);
  background: var(--accent);
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .map-btn:active { transform: none; }
}
