/* ==========================================================================
   Homepage tech stack (CHK-47): categorized stack wall, the same treatment as
   the outbound page's stack. Tiles light up (grayscale -> color + "connected"
   dot) once .reveal fires. The section keeps the .partner-grid class because
   js/scroll-animations.js anchors the certification-badge fade-out on it.
   ========================================================================== */

.tech-stack {
  position: relative;
  z-index: 10;
  padding-block: var(--space-4xl) var(--space-3xl);
  background: var(--bg-primary);
  overflow-x: clip;
}

.tech-stack__header {
  max-width: 640px;
  margin: 0 auto var(--space-2xl);
  text-align: center;
}
.tech-stack__header .overline { display: block; margin-bottom: var(--space-sm); }
.tech-stack__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.15;
  margin: 0 0 var(--space-sm);
  text-wrap: balance;
}
/* CJK breaks between any two characters; keep-all + <wbr> in the ja copy breaks at the phrase */
:lang(ja) .tech-stack__title { word-break: keep-all; }
:lang(ja) .tech-stack__sub { word-break: auto-phrase; }
.tech-stack__sub { color: var(--text-secondary); margin: 0; }

.tech-stack__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.625rem; }
.tech-stack__num {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.tech-stack__label {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.tech-stack__hint { font-size: 0.8125rem; font-style: italic; color: var(--text-secondary); }

.tech-stack__tiles { list-style: none; margin: 0; padding: 0; }
.tech-stack__tile { display: flex; align-items: center; min-width: 0; }
.tech-stack__name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Icon frame normalizes square app icons and transparent marks alike */
.tech-stack__icon {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 4px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tech-stack__icon img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
[data-theme="dark"] .tech-stack__icon { border-color: rgba(255, 255, 255, 0.08); }
.tech-stack__icon::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 0 2px var(--bg-card);
}

/* Light-up: start states only when JS runs (html.js), so no-JS shows full color */
:where(.js) .tech-stack__icon img { filter: grayscale(100%); opacity: 0.5; }
:where(.js) .tech-stack__icon::after { transform: scale(0); }
.tech-stack__icon img,
.tech-stack__icon::after {
  transition: filter 0.5s ease, opacity 0.5s ease, transform 0.35s cubic-bezier(0.22, 1.6, 0.36, 1);
  transition-delay: calc(var(--tile, 0) * 70ms + 250ms);
}
.is-visible .tech-stack__icon img { filter: none; opacity: 1; }
.is-visible .tech-stack__icon::after { transform: scale(1); }

/* Four categorized columns, 2x2 hairline tiles each */
.tech-stack .tech-stack__layers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  max-width: 1120px;
  margin-inline: auto;
}
.tech-stack .tech-stack__head {
  flex-direction: column;
  gap: 0.125rem;
  padding-bottom: 0.625rem;
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}
.tech-stack .tech-stack__tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.tech-stack .tech-stack__tile {
  flex-direction: column;
  justify-content: center;
  gap: 0.625rem;
  min-height: 118px;
  padding: var(--space-md) var(--space-sm);
  background: var(--bg-card);
  transition: background var(--transition-fast);
}
.tech-stack .tech-stack__tile:hover { background: var(--bg-secondary); }
.tech-stack .tech-stack__name { text-align: center; }

@media (max-width: 960px) {
  .tech-stack .tech-stack__layers { grid-template-columns: repeat(2, 1fr); gap: var(--space-xl) var(--space-lg); }
}
@media (max-width: 560px) {
  .tech-stack .tech-stack__layers { grid-template-columns: 1fr; }
  .tech-stack .tech-stack__head { flex-direction: row; align-items: baseline; margin-bottom: var(--space-sm); }
  .tech-stack .tech-stack__tiles { grid-template-columns: repeat(4, 1fr); border-radius: 12px; }
  .tech-stack .tech-stack__tile { min-height: 92px; gap: 0.5rem; padding: 0.75rem 0.25rem; }
  .tech-stack .tech-stack__icon { width: 40px; height: 40px; }
  .tech-stack .tech-stack__name { font-size: 0.6875rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tech-stack__icon img,
  .tech-stack__icon::after { transition: none; }
}
