.skills {
  padding: 1rem 1.5rem 0;
}

.skills::after {
  margin: 70px auto 50px;
}

.skills-container {
  max-width: 1280px;
  margin: 0 auto;
}

.skills-title {
  margin: 0 0 0.6rem;
  font-size: clamp(2.25rem, 4.5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--color-heading);
}

.skills-subtitle {
  margin: 0 0 3rem;
  font-size: 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* Marquee */

.marquee-viewport {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.marquee-row {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow-x: hidden;
  overflow-y: visible;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: marquee-scroll-left var(--marquee-duration, 45s) linear infinite;
}

.marquee-track--right {
  animation-name: marquee-scroll-right;
}

.marquee-row:hover .marquee-track {
  animation-play-state: paused;
}

/*
  Once js/components/skills-marquee.js takes over, the row is something you
  can grab — so the keyframe animation has to go. A keyframe loop can't be
  interrupted, can't take the velocity of a flick, and would fight the
  transform the drag is writing every frame. The CSS animation stays as the
  no-JS fallback; `.is-interactive` is only ever added once JS is driving.
*/
.marquee-track.is-interactive {
  animation: none;
}

.marquee-row.is-draggable {
  cursor: grab;
  /* Vertical stays the browser's page scroll; horizontal is ours. */
  touch-action: pan-y;
  /* A drag across the labels must not turn into a text selection — and the
     selection would start before the 10px threshold decides it's a drag, so
     this can't wait for `.is-dragging`. */
  user-select: none;
  -webkit-user-select: none;
}

.marquee-row.is-dragging {
  cursor: grabbing;
}

.marquee-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.85rem;
  padding-right: 0.85rem;
}

@keyframes marquee-scroll-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes marquee-scroll-right {
  from {
    transform: translateX(-50%);
  }
  to {
    transform: translateX(0);
  }
}

/* Chips */

.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  height: 42px;
  padding: 0 1.15rem;
  border-radius: var(--radius-pill);
  border: 2px solid rgba(var(--color-hairline-rgb), 0.08);
  background: var(--color-surface);
  box-shadow: 0 2px 10px rgba(var(--color-black-rgb), 0.05);
  white-space: nowrap;
  color: var(--color-body);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.7;
  transition: opacity var(--response) var(--ease-enter),
    transform var(--response) var(--ease-enter),
    box-shadow var(--response) var(--ease-enter),
    border-color var(--response) var(--ease-enter);
}

.skill-chip--badge {
  color: var(--color-body);
  font-weight: 600;
}

.skill-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: currentColor;
}

.marquee-row:not(.is-dragging) .marquee-track:hover .skill-chip {
  opacity: 0.35;
}

.marquee-row:not(.is-dragging) .marquee-track:hover .skill-chip:hover {
  opacity: 1;
  transform: scale(1.08);
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-on-brand);
  box-shadow: 0 8px 20px rgba(var(--color-brand-rgb), 0.28);
}

@media (max-width: 640px) {
  .skills-title {
    font-size: 2rem;
  }

  .skill-chip {
    height: 36px;
    padding: 0 0.9rem;
    font-size: 0.85rem;
  }

  .skill-icon {
    width: 17px;
    height: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track {
    animation: none;
  }

  .marquee-group[aria-hidden="true"] {
    display: none;
  }
}
