.toolchain {
  --tool-ink: #e5e9e8;
  --tool-muted: #8e9699;
  --tool-line: rgba(229, 233, 232, 0.12);
  position: relative;
  overflow: hidden;
  padding: clamp(72px, 7vw, 104px) 0 clamp(58px, 6vw, 88px);
  color: var(--tool-ink);
  background: var(--surface, #0c0f11);
}

.toolchain-shell {
  width: min(1760px, calc(100% - clamp(48px, 6vw, 144px)));
  margin: 0 auto;
}

.toolchain-head {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(360px, 1.28fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  margin-bottom: clamp(30px, 3vw, 44px);
}

.toolchain-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(36px, 3.4vw, 50px);
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: -0.035em;
}

.toolchain-intro {
  max-width: 720px;
  margin: 0;
  color: var(--tool-muted);
  font-family: var(--sans);
  font-size: clamp(13px, 1.1vw, 16px);
  line-height: 1.75;
}

.toolchain-rail {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 72px 18px;
  scrollbar-width: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}

.toolchain-rail::-webkit-scrollbar { display: none; }

.toolchain-track {
  --toolchain-drift: clamp(36px, 3.4vw, 52px);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: clamp(24px, 3vw, 52px);
  width: max-content;
  min-width: 100%;
  animation: toolchain-drift 15s linear infinite alternate;
  will-change: transform;
}

.toolchain-rail:has(.tool-item:hover) .toolchain-track,
.toolchain-rail:focus-within .toolchain-track,
.toolchain-rail.is-motion-paused .toolchain-track {
  animation-play-state: paused;
}

@keyframes toolchain-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(0px - var(--toolchain-drift)), 0, 0); }
}

.tool-group {
  display: grid;
  flex: 0 0 auto;
  align-content: end;
}

.tool-group + .tool-group {
  padding-left: clamp(22px, 2vw, 36px);
  border-left: 1px solid var(--tool-line);
}

.tool-group-label {
  display: block;
  margin-bottom: 12px;
  color: rgba(229, 233, 232, 0.5);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tool-group-items {
  display: flex;
  align-items: end;
  gap: clamp(8px, 0.7vw, 14px);
}

.tool-item {
  --tool-brand: #a58b63;
  --tool-lift: 0px;
  --tool-scale: 1;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  gap: 9px;
  width: clamp(52px, 4vw, 64px);
  min-height: 74px;
  padding: 0;
  color: rgba(229, 233, 232, 0.43);
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  transform: translate3d(0, var(--tool-lift), 0) scale(var(--tool-scale));
  transform-origin: center bottom;
  transition: color 240ms ease, filter 240ms ease, transform 380ms cubic-bezier(.2,.8,.2,1);
}

.tool-item::after {
  width: 0;
  height: 1px;
  content: "";
  background: var(--tool-brand);
  transition: width 260ms cubic-bezier(.2,.8,.2,1);
}

.tool-item:hover,
.tool-item:focus-visible,
.tool-item.is-active {
  color: var(--tool-ink);
}

.tool-item.is-active::after { width: 34px; }
.tool-item:focus-visible { outline: 2px solid var(--tool-brand); outline-offset: 7px; }

.tool-logo {
  position: relative;
  display: grid;
  width: clamp(32px, 2.7vw, 44px);
  height: clamp(32px, 2.7vw, 44px);
  place-items: center;
  border-radius: 10px;
  transition: background-color 240ms ease, box-shadow 240ms ease;
}

.tool-logo--wide { width: clamp(42px, 3.5vw, 56px); }

.tool-logo img {
  display: block;
  width: min(100%, 48px);
  height: min(100%, 48px);
  object-fit: contain;
  filter: grayscale(1) saturate(0) brightness(.9) contrast(.92);
  opacity: .78;
  transition: filter 240ms ease, opacity 240ms ease, transform 300ms cubic-bezier(.2,.8,.2,1);
}

.tool-logo--wide img { width: 100%; }

.tool-logo--light-surface {
  background: rgba(243, 244, 237, .72);
  box-shadow: 0 3px 14px rgba(0, 0, 0, .2);
}

.tool-logo--light-surface img {
  filter: grayscale(1) saturate(0) brightness(.88) contrast(.94);
  opacity: .74;
}

.tool-item:hover .tool-logo img,
.tool-item:focus-visible .tool-logo img {
  filter: none;
  opacity: 1;
  transform: scale(1.04);
}

.tool-item:hover .tool-logo--light-surface,
.tool-item:focus-visible .tool-logo--light-surface {
  background: #f3f4ed;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .28);
}

.tool-logo--light-surface img { width: calc(100% - 8px); height: calc(100% - 8px); }
.tool-logo--round-surface { border-radius: 50%; }

.tool-label {
  max-width: 82px;
  overflow: hidden;
  color: currentColor;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolchain-readout {
  display: grid;
  grid-template-columns: 56px minmax(130px, 0.65fr) minmax(280px, 1.4fr) max-content;
  gap: clamp(16px, 2vw, 32px);
  align-items: center;
  min-height: 56px;
  margin-top: 8px;
  padding-top: 15px;
  border-top: 1px solid var(--tool-line);
}

.toolchain-readout-index,
.toolchain-readout-meta {
  color: #a58b63;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolchain-readout-index { white-space: nowrap; }

.toolchain-readout strong {
  font-family: var(--display);
  font-size: clamp(16px, 1.4vw, 21px);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.toolchain-readout-description {
  color: var(--tool-ink);
  font-size: 13px;
  line-height: 1.6;
}

.toolchain-readout-meta { color: var(--tool-muted); }

@media (max-width: 1040px) {
  .toolchain-track { min-width: max-content; }
  .toolchain-readout { grid-template-columns: 48px minmax(130px, .7fr) minmax(240px, 1.5fr); }
  .toolchain-readout-meta { grid-column: 2 / -1; }
}

@media (max-width: 767px) {
  .toolchain { padding: 104px 0 54px; }
  .toolchain-shell { width: calc(100% - 32px); }
  .toolchain-head { grid-template-columns: 1fr; gap: 16px; margin-bottom: 28px; }
  .toolchain-title { font-size: clamp(36px, 11vw, 44px); }
  .toolchain-intro { max-width: 34em; }
  .toolchain-rail {
    width: calc(100% + 32px);
    margin-left: -16px;
    padding: 8px 40px 14px 32px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 36px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 36px), transparent 100%);
  }
  .toolchain-track {
    min-width: max-content;
    gap: 24px;
    animation: none;
    will-change: auto;
  }
  .tool-group + .tool-group { padding-left: 24px; }
  .tool-group-items { gap: 10px; }
  .tool-item { width: 58px; scroll-snap-align: start; }
  .toolchain-readout {
    grid-template-columns: 48px auto minmax(0, 1fr);
    gap: 7px 12px;
    min-height: 72px;
    margin-top: 4px;
  }
  .toolchain-readout-index { grid-row: 1 / span 2; align-self: start; padding-top: 5px; }
  .toolchain-readout-description { grid-column: 3; }
  .toolchain-readout-meta { grid-column: 2 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .toolchain-track { animation: none; will-change: auto; }
  .tool-item,
  .tool-item::after,
  .tool-logo,
  .tool-logo img { transition: none; }
  .tool-item { transform: none !important; }
}

html[data-reduced-motion="true"] .tool-item,
html[data-reduced-motion="true"] .tool-item::after,
html[data-reduced-motion="true"] .tool-logo,
html[data-reduced-motion="true"] .tool-logo img { transition: none; }

html[data-reduced-motion="true"] .tool-item { transform: none !important; }
html[data-reduced-motion="true"] .toolchain-track { animation: none; will-change: auto; }
