/* ====================================================================
   TECH-STACK.CSS – OpenSovereign Tech Stack Page
   Expandable stack layers, pills, tooltips, detail cards, partner legend
   ==================================================================== */

/* ====== SECTION ====== */

.techstack {
  padding: 100px 0;
  border-top: 1px solid var(--border-subtle);
}

/* ====== STACK LAYERS ====== */

.stack-layers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 56px;
}

/* ====== TOOLBAR ====== */

.stack-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 40px;
}

.stack-toolbar + .stack-layers {
  margin-top: 12px;
}

.stack-expand-all {
  font-family: inherit;
  font-size: 12px;
  color: var(--text-gray-light);
  background: transparent;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.stack-expand-all:hover,
.stack-expand-all[aria-pressed="true"] {
  color: var(--text-white);
  border-color: var(--color-accent);
}

.stack-expand-all:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ====== LAYER (<details>) ====== */

/* No overflow:hidden here — it would clip the pill tooltips, which sit above
   the row. The corners are rounded on the children instead. */
.stack-layer {
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  transition: border-color 0.2s, opacity 0.2s;
}

.stack-layer:hover {
  border-color: rgba(255, 49, 49, 0.3);
}

.stack-layer[open] {
  border-color: rgba(255, 49, 49, 0.45);
}

.stack-layer-head {
  display: flex;
  align-items: stretch;
  cursor: pointer;
  list-style: none;
}

.stack-layer-head::-webkit-details-marker {
  display: none;
}

.stack-layer-head:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ====== LAYER LABEL ====== */

.stack-layer-label {
  /* Wide enough for the longest label ("Infrastructure & OS") on one line. */
  width: 210px;
  flex-shrink: 0;
  background: var(--bg-dark-2);
  padding: 14px 20px;
  margin: 0;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border-dark);
  border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px);
}

/* ====== LAYER ITEMS ====== */

.stack-layer-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-dark);
  align-items: center;
}

.stack-layer[open] .stack-layer-label {
  border-bottom-left-radius: 0;
}

/* ====== COUNT + CHEVRON ====== */

.stack-layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--bg-dark);
  border-left: 1px solid var(--border-subtle);
  border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0;
  color: var(--text-gray-light);
  font-size: 12px;
  font-weight: 600;
}

.stack-layer-head:hover .stack-layer-toggle {
  color: var(--text-white);
}

.stack-layer[open] .stack-layer-toggle {
  border-bottom-right-radius: 0;
}

.stack-layer-count {
  min-width: 26px;
  text-align: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-dark-3);
  border: 1px solid var(--border-subtle);
}

.stack-layer-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s;
}

.stack-layer[open] .stack-layer-chevron {
  transform: rotate(-135deg) translateY(-2px);
}

/* ====== PILL ====== */

.stack-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-dark-2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-white);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s, border-color 0.2s;
}

.stack-pill:hover {
  border-color: var(--text-gray);
}

.stack-pill:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ====== FILTER STATES ====== */

.stack-pill.dimmed,
.stack-card.dimmed {
  opacity: 0.25;
}

.stack-pill.matched {
  border-color: var(--color-accent);
}

.stack-layer.dimmed .stack-layer-label {
  opacity: 0.4;
}

/* ====== TOOLTIP ====== */

.stack-pill .pill-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark-2);
  color: var(--text-white);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  border: 1px solid var(--border-dark);
}

.stack-pill .pill-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--bg-dark-2);
}

/* Pointer devices reveal on hover, keyboard users on focus. On touch a tap
   opens the pill's card, which lists the partners as well. */
.stack-pill:hover .pill-tooltip,
.stack-pill:focus-visible .pill-tooltip {
  display: block;
}

/* ====== DETAIL PANEL ====== */

.stack-layer-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--bg-dark-3);
  border-top: 1px solid var(--border-dark);
  border-radius: 0 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px);
}

.stack-layer[open] .stack-layer-detail {
  animation: stack-detail-in 0.25s ease-out;
}

@keyframes stack-detail-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ====== CARD ====== */

.stack-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--bg-dark-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  scroll-margin-top: 120px;
  transition: border-color 0.2s, opacity 0.2s, box-shadow 0.3s;
}

.stack-card:hover {
  border-color: var(--border-dark);
}

.stack-card.is-target {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stack-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
}

.stack-card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-gray-light);
  flex: 1;
}

.stack-card-partners {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stack-card-partners li {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-white);
  background: var(--bg-dark-3);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

.stack-card-links {
  display: flex;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.stack-card-links a {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-gray-light);
  text-decoration: none;
  transition: color 0.2s;
}

.stack-card-links a::after {
  content: " ↗";
}

.stack-card-links a:hover {
  color: var(--color-accent);
}

/* ====== PARTNER LEGEND / FILTER ====== */

.partner-legend {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
}

.partner-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-gray);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.partner-legend-item:hover {
  color: var(--text-white);
  border-color: var(--border-dark);
}

.partner-legend-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.partner-legend-item.active {
  color: var(--text-white);
  background: var(--bg-dark-2);
  border-color: var(--color-accent);
}

.partner-legend-logo {
  display: block;
  height: 20px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.partner-legend-item:hover .partner-legend-logo,
.partner-legend-item.active .partner-legend-logo {
  opacity: 1;
}

.partner-legend-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-gray);
  margin-top: 14px;
}

/* ====== RESPONSIVE ====== */

@media (max-width: 1024px) {
  .stack-layer-head {
    flex-wrap: wrap;
  }

  .stack-layer-label {
    flex: 1;
    width: auto;
    border-right: none;
    border-radius: calc(var(--radius-sm) - 1px) 0 0 0;
  }

  .stack-layer-toggle {
    background: var(--bg-dark-2);
    border-radius: 0 calc(var(--radius-sm) - 1px) 0 0;
  }

  .stack-layer-items {
    flex-basis: 100%;
    order: 3;
    border-top: 1px solid var(--border-dark);
    border-radius: 0 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px);
  }

  .stack-layer[open] .stack-layer-items {
    border-radius: 0;
  }
}

@media (max-width: 640px) {
  /* Keep a focused pill's partner list inside the viewport. */
  .stack-pill .pill-tooltip {
    white-space: normal;
    max-width: min(220px, 70vw);
    text-align: center;
  }

  .stack-layer-detail {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .partner-legend {
    gap: 6px;
  }

  .partner-legend-item {
    padding: 6px 11px;
  }
}
