/* ------------------------------------------------------------------
   Technology constellation — interactive bubble map below the hero.
   Colors derive from the site theme variables in site.css so the
   section adapts to both light and dark themes.
   ------------------------------------------------------------------ */

.constellation-section { position: relative; }

.constellation-section .section-copy {
  max-width: 640px;
  margin: 12px 0 0;
  color: var(--text-3);
  line-height: 1.65;
  font-size: var(--fs-md);
}

.constellation-legend {
  display: grid;
  gap: 10px;
  min-width: 230px;
  padding: 15px 17px;
  border: 1px solid var(--line-1);
  background: var(--surface-1);
  border-radius: var(--radius-md);
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.constellation-legend .legend-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.constellation-legend strong { color: var(--text-2); font-weight: 650; }
.legend-scale { display: flex; align-items: center; gap: 5px; }
.legend-scale span {
  display: inline-block;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  background: var(--accent-glow);
}
.legend-scale span:nth-child(1) { width: 10px; height: 10px; }
.legend-scale span:nth-child(2) { width: 16px; height: 16px; }
.legend-scale span:nth-child(3) { width: 23px; height: 23px; }

.map-card {
  position: relative;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
}

.map-toolbar {
  min-height: 66px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-1);
}
.map-toolbar .filters, .map-toolbar .toolset { display: flex; gap: 8px; flex-wrap: wrap; }
.map-toolbar button {
  appearance: none;
  border: 1px solid var(--line-1);
  background: transparent;
  color: var(--text-3);
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.map-toolbar button:hover,
.map-toolbar button.active {
  color: var(--text-1);
  border-color: var(--accent-line);
  background: var(--accent-glow);
}

.density-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.density-control label {
  font-weight: 500;
}
.density-control input[type="range"] {
  width: 120px;
  height: 5px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.density-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent-line);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.density-control input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.density-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent-line);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.density-control input[type="range"]::-moz-range-thumb:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.density-control input[type="range"]::-webkit-slider-runnable-track {
  background: var(--line-2);
  height: 5px;
  border-radius: 2px;
}
.density-control input[type="range"]::-moz-range-track {
  background: transparent;
  border: none;
}
.density-control input[type="range"]::-moz-range-progress {
  background: var(--accent-glow);
  height: 5px;
  border-radius: 2px;
}
.density-control span {
  min-width: 24px;
  text-align: right;
  font-weight: 500;
  color: var(--text-1);
}

.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  min-height: 480px;
  max-height: 760px;
  overflow: hidden;
  touch-action: pan-y;
  cursor: crosshair;
  background:
    linear-gradient(var(--line-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 34px 34px, 34px 34px;
}
/* Inner frame line marking the padded field the bubbles live inside */
.map-stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: clamp(14px, 3.2%, 34px);
  border: 1px solid var(--line-2);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}
.map-stage::after {
  content: "Move through the field to repel the stack";
  position: absolute;
  left: 20px;
  bottom: 18px;
  z-index: 8;
  color: var(--text-3);
  opacity: .65;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  pointer-events: none;
}

.metaballs, .constellation-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
/* The goo layer renders at half resolution and upscales — the filter is
   a blur anyway, and this quarters the per-frame rasterization cost */
.metaballs {
  width: 50%;
  height: 50%;
  transform: scale(2);
  transform-origin: 0 0;
  opacity: .55;
  mix-blend-mode: screen;
}
:root[data-theme="light"] .metaballs { opacity: .3; mix-blend-mode: multiply; }
.constellation-links line { stroke: var(--accent-line); stroke-opacity: .28; stroke-width: 1; }

.bubble {
  --size: 100px;
  --c: var(--accent);
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--c) 42%, transparent);
  background:
    radial-gradient(circle at 34% 26%,
      color-mix(in srgb, var(--c) 22%, var(--surface-2)),
      var(--surface-2) 58%,
      var(--surface-3));
  box-shadow:
    inset 0 1px 1px var(--line-2),
    0 10px 30px color-mix(in srgb, var(--c) 12%, transparent);
  display: grid;
  place-items: center;
  color: var(--text-1);
  padding: 0;
  cursor: pointer;
  transition: opacity .25s ease, border-color .2s ease, filter .25s ease;
  will-change: transform;
}
.bubble::before { content: ""; position: absolute; inset: 8%; border-radius: inherit; border: 1px solid var(--line-2); }
.bubble:hover, .bubble:focus-visible, .bubble.selected {
  outline: none;
  border-color: color-mix(in srgb, var(--c) 88%, var(--text-1));
  filter: brightness(1.1);
}
.bubble.dim { display: none; pointer-events: none; }

.bubble .icon-wrap {
  position: relative;
  z-index: 2;
  width: 56%;
  height: 56%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--chip-bg);
  border: 1px solid var(--chip-line);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
  overflow: hidden;
}
.bubble .icon-wrap img { position: relative; z-index: 2; max-width: 67%; max-height: 67%; object-fit: contain; }
.bubble .monogram {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #0a110e;
  font-size: clamp(8px, calc(var(--size) * .2), 20px);
  font-weight: 850;
  letter-spacing: -.04em;
}
/* Small bubbles carry no name label — the info card handles identity */
.bubble.tiny .bubble-name { display: none; }
.bubble .bubble-name {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: calc(50% + 31%);
  transform: translateX(-50%);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: clamp(8px, calc(var(--size) * .08), 11px);
  font-weight: 700;
  letter-spacing: -.01em;
  pointer-events: none;
}

/* Floating cluster separators — category names that track each
   cluster's centroid so groupings stay legible while the field moves */
.cluster-labels { position: absolute; inset: 0; pointer-events: none; }
.cluster-label {
  --c: var(--accent);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 8%, transparent);
  color: color-mix(in srgb, var(--c) 72%, var(--text-2));
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: .8;
  transition: opacity .25s ease;
  will-change: transform;
}
.cluster-label.dim { opacity: .08; }
:root[data-theme="light"] .cluster-label { color: color-mix(in srgb, var(--c) 40%, var(--text-1)); }

.cursor-halo {
  position: absolute;
  z-index: 3;
  width: 250px;
  height: 250px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease;
  box-shadow: inset 0 0 60px var(--accent-glow);
  /* cursor glow lives here (a small element) instead of repainting the
     whole stage background on every pointer move */
  background: radial-gradient(circle, var(--accent-glow), transparent 65%);
  will-change: left, top;
}
.map-stage.pointer-in .cursor-halo { opacity: .6; }

.constellation-info {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 9;
  width: min(320px, calc(100% - 36px));
  min-height: 142px;
  padding: 17px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-1);
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.constellation-info .info-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.constellation-info .info-category {
  color: var(--info-color, var(--accent-ink));
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 9px;
  font-weight: 700;
}
.constellation-info .info-score { color: var(--text-3); font-size: 10px; }
.constellation-info h3 { margin: 7px 0 6px; font-size: 22px; letter-spacing: -.035em; color: var(--text-1); }
.constellation-info p { margin: 0; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.55; }
.constellation-info .score-track {
  height: 3px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-2);
}
.constellation-info .score-fill {
  width: var(--score, 90%);
  height: 100%;
  background: var(--info-color, var(--accent));
  border-radius: inherit;
  box-shadow: 0 0 14px var(--info-color, var(--accent));
}

@media (max-width: 900px) {
  .constellation-legend { width: 100%; grid-template-columns: 1fr 1fr; }
  .map-toolbar { align-items: flex-start; }
}
/* Tablet portrait — squarer field suits the narrower column */
@media (max-width: 900px) {
  .map-stage { aspect-ratio: 4 / 4.4; max-height: 700px; }
}

@media (max-width: 640px) {
  .map-toolbar { display: grid; }
  .map-toolbar .toolset { justify-content: flex-end; }
  .map-stage { aspect-ratio: 4 / 5.6; min-height: 480px; max-height: 640px; }
  .constellation-info { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .map-stage::after { display: none; }
  .constellation-legend { grid-template-columns: 1fr; }
}

/* Short viewports — landscape phones and small laptops in split view */
@media (max-height: 540px) {
  .map-stage { aspect-ratio: auto; min-height: 340px; height: 80vh; max-height: 440px; }
  .constellation-info { display: none; }
}

/* Ultrawide — cap the stage so clusters don't drift beyond comfortable reach */
@media (min-width: 2000px) {
  .map-stage { aspect-ratio: auto; height: 780px; }
}
