/* Estils exclusius de la home (index.html). Es carrega després de /styles.css i /css/sistema.css,
   que conté els tokens, la capçalera, la retícula, la construcció amb el scroll i el peu. */

/* ============================================================
   Hero · entrada (com a la referència)
   Només s'amaga si hi ha JS (.js) i fins que loader.js afegeix .go.
   ============================================================ */
.hero-cv {
  transition: opacity 1.6s ease;
}

.js:not(.go) .hero-cv,
.js:not(.go) .hero-kicker,
.js:not(.go) .hero-foot,
.js:not(.go) .hero .word {
  opacity: 0;
}

.js:not(.go) .hero h1 > span {
  transform: translateY(108%);
  clip-path: inset(-0.2em -0.1em 108% -0.1em);
}

/* La primera línia puja des de sota d'una màscara (equivalent a .ln de la referència) */
.go .hero h1 > span {
  animation: hero-up 1.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.go .hero .word {
  animation: hero-fade 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.go .hero-kicker,
.go .hero-foot {
  animation: hero-fade 1s cubic-bezier(0.16, 1, 0.3, 1) 0.7s both;
}

@keyframes hero-up {
  from {
    transform: translateY(108%);
    clip-path: inset(-0.2em -0.1em 108% -0.1em);
  }
  to {
    transform: none;
    clip-path: inset(-0.2em -0.1em -0.2em -0.1em);
  }
}

@keyframes hero-fade {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-cv,
  .hero h1 > span,
  .hero .word,
  .hero-kicker,
  .hero-foot {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Seqüència de l'estudi
   Base (sense scroll-driven o amb moviment reduït): passos apilats i llegibles.
   ============================================================ */
.studio {
  position: relative;
  background: var(--media);
  color: var(--cream);
}

.st-sticky {
  position: relative;
  overflow: hidden;
}

.st-media {
  position: absolute;
  inset: 0;
  background: #121a22;
}

.st-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.st-shade {
  position: absolute;
  inset: 0;
  background: var(--navy);
  opacity: 0.55;
}

.st-steps {
  position: relative;
  z-index: 2;
}

.st-step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(80vh, 47.5rem);
  padding: 6rem 0;
}

.st-c {
  justify-content: flex-end;
}

.st-wordmark {
  margin: 0;
  line-height: 0;
  color: var(--cream);
}

.st-wordmark svg {
  display: block;
  width: min(74vw, 67.5rem);
  height: auto;
}

.st-lead {
  max-width: 30ch;
  margin: clamp(1.25rem, 3vh, 2.25rem) 0 0;
  color: rgb(238 231 220 / 0.82);
  font-size: clamp(1.05rem, 1.4vw, 1.4rem);
  line-height: 1.4;
}

.st-statement {
  max-width: 15ch;
  margin: 0;
  color: var(--cream);
  font-size: clamp(2.4rem, 5.8vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
}

.st-c .g12 {
  width: 100%;
}

.st-body {
  display: flex;
  flex-direction: column;
  grid-column: 6 / span 6;
  gap: 1.75rem;
}

.st-body p {
  margin: 0;
  color: var(--cream);
  font-size: clamp(1.15rem, 1.7vw, 1.7rem);
  line-height: 1.45;
}

.st-link {
  align-self: flex-start;
  padding: 0.625rem 0;
  color: var(--cream);
}

/* Millora: vídeo fix i passos que entren i surten amb el scroll.
   El bloc ocupa tota la pantalla: en baixar, la capçalera s'amaga. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .studio {
      height: min(340vh, 212.5rem);
      view-timeline-name: --st;
      view-timeline-axis: block;
    }

    .st-sticky {
      position: sticky;
      top: 0;
      height: 100vh;
      height: 100svh;
    }

    .st-steps {
      position: absolute;
      inset: 0;
    }

    .st-step {
      position: absolute;
      inset: 0;
      min-height: 0;
      padding: 0 var(--page-pad) clamp(2.5rem, 8vh, 6rem);
    }

    .st-media {
      animation: st-media linear both;
      animation-timeline: --st;
      animation-range: contain 0% contain 100%;
    }

    .st-shade {
      animation: st-shade linear both;
      animation-timeline: --st;
      animation-range: contain 0% contain 100%;
    }

    .st-a {
      animation: st-in linear both;
      animation-timeline: --st;
      animation-range: contain 0% contain 34%;
    }

    .st-b {
      animation: st-in linear both;
      animation-timeline: --st;
      animation-range: contain 30% contain 66%;
    }

    .st-c {
      animation: st-last linear both;
      animation-timeline: --st;
      animation-range: contain 62% contain 100%;
    }
  }
}

@keyframes st-media {
  from { transform: scale(1.12); }
  to { transform: scale(1); }
}

@keyframes st-shade {
  from { opacity: 0.18; }
  to { opacity: 0.74; }
}

@keyframes st-in {
  0% { opacity: 0; transform: translateY(48px); }
  28% { opacity: 1; transform: none; }
  74% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-48px); }
}

@keyframes st-last {
  0% { opacity: 0; transform: translateY(48px); }
  35% { opacity: 1; transform: none; }
  100% { opacity: 1; transform: none; }
}

/* ============================================================
   Índexs (projectes i equip) amb imatge que segueix el cursor
   ============================================================ */
.home-projects {
  padding: var(--space-section) 0 var(--space-block);
}

.idx {
  position: relative;
}

.row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--grid-gap);
  align-items: center;
  padding: clamp(1.5rem, 2.6vw, 2.75rem) 0;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  text-decoration: none;
  transition: opacity 0.45s ease;
}

.row:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 4px;
}

.idx.hov .row {
  opacity: 0.26;
}

.idx.hov .row.on {
  opacity: 1;
}

.row .no {
  grid-column: 1 / span 1;
}

.row .nm {
  grid-column: 2 / span 5;
  margin: 0;
  font-size: clamp(2.4rem, 5.6vw, 5.6rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.035em;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.row.on .nm {
  transform: translateX(clamp(0.625rem, 1.4vw, 1.375rem));
}

.row-info {
  display: flex;
  flex-direction: column;
  grid-column: 7 / span 4;
  gap: 0.375rem;
}

.row-type {
  font-size: 0.9375rem;
  font-weight: 500;
}

.row-tags {
  font-size: 0.8125rem;
  line-height: 1.45;
}

.row-meta {
  display: flex;
  grid-column: 11 / span 2;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.875rem;
}

.row .go-arr {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.row.on .go-arr {
  opacity: 1;
  transform: none;
}

/* Imatge que segueix el cursor: una pila d'imatges; es mostra la de la fila activa */
.fol {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  aspect-ratio: 4 / 5;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

.fol--project {
  width: clamp(16.25rem, 24vw, 23.75rem);
}

.fol.show {
  opacity: 1;
}

.fol img {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.92);
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.fol.show img.on {
  opacity: 1;
  transform: none;
}

/* Imatge dins de cada fila: només en pantalles estretes */
.rimg {
  display: none;
}

.home-projects .idx {
  margin-top: clamp(2rem, 4vw, 4rem);
}

.home-projects-foot {
  margin-top: clamp(2rem, 3.5vw, 3rem);
}

.home-projects-foot p {
  grid-column: 1 / span 6;
  margin: 0;
  font-size: 0.875rem;
}

.home-projects-foot a {
  grid-column: 10 / span 3;
  justify-self: end;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ============================================================
   On hem participat: logotips oficials en bucle horitzontal
   Dos grups idèntics es desplacen el 50 % i tornen a començar sense salt.
   ============================================================ */
.home-venues {
  /* Alçada de referència dels logotips; cada un s'hi ajusta segons la seva forma */
  --logo-h: clamp(1.75rem, 3.2vw, 3.25rem);
  padding: 0 0 var(--space-block);
}

.marquee {
  margin-top: clamp(2.5rem, 5vw, 4.5rem);
  overflow: hidden;
  /* Extrems esvaïts */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 36s linear infinite;
}

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

.marquee-group {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.marquee-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-inline: clamp(2rem, 4.5vw, 4.5rem);
  white-space: nowrap;
}

/* Separador: el rombe del teixit */
.marquee-item::after {
  align-self: center;
  width: 7px;
  height: 22px;
  margin-left: clamp(2rem, 4.5vw, 4.5rem);
  margin-right: calc(-1 * clamp(2rem, 4.5vw, 4.5rem));
  background: var(--acc);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  content: "";
}

/* Logotips oficials en el color del text: el fitxer fa de màscara (forma) i el color és el de la web */
.marquee-logo {
  display: block;
  flex: none;
  height: var(--logo-h);
  background-color: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat;
}

.marquee-logo--llum-bcn {
  --logo: url("/public/assets/logos/entitats/llum-bcn-2026.svg");
  height: calc(var(--logo-h) * 0.62);
  aspect-ratio: 183 / 21;
}

.marquee-logo--mira {
  --logo: url("/public/assets/logos/entitats/mira.svg");
  height: calc(var(--logo-h) * 0.8);
  aspect-ratio: 337.6 / 51.85;
}

.marquee-logo--jardi {
  --logo: url("/public/assets/logos/entitats/el-jardi-digital.svg");
  height: calc(var(--logo-h) * 0.5);
  aspect-ratio: 1441.6 / 95.3;
}

.marquee-logo--cluster {
  --logo: url("/public/assets/logos/entitats/cluster-audiovisual.png");
  height: calc(var(--logo-h) * 1.25);
  aspect-ratio: 900 / 268;
}

/* SunRanxx: el logotip oficial té fons blanc; el filtre (a index.html) treu el blanc i el pinta del color del text */
.marquee-logo--sunranxx {
  height: calc(var(--logo-h) * 1.9);
  aspect-ratio: 877 / 490;
  background: url("/public/assets/logos/entitats/sunranxx.png") center / contain no-repeat;
  -webkit-mask: none;
  mask: none;
  filter: url("#logo-sense-fons");
}

.marquee-place {
  color: var(--mute);
}

@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* Moviment reduït: franja quieta i centrada, sense duplicats */
@media (prefers-reduced-motion: reduce) {
  .marquee {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .marquee-track {
    width: auto;
    justify-content: center;
    animation: none;
  }

  .marquee-group {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 1.5rem;
  }

  .marquee-group + .marquee-group,
  .marquee-group .marquee-item:nth-child(n + 6) {
    display: none;
  }

  /* Cada logotip amb el seu text a sota, sense separadors: hi caben també al mòbil */
  .marquee-item {
    flex-direction: column;
    gap: 0.75rem;
    padding-inline: clamp(1rem, 3vw, 2.5rem);
  }

  .marquee-item::after {
    display: none;
  }
}

/* ============================================================
   (02) Taller: tira horitzontal
   ============================================================ */
.home-workshop {
  padding: var(--space-section) 0;
}

.workshop-head {
  align-items: end;
  row-gap: 1.5rem;
  margin: var(--space-head) 0 var(--space-block);
}

.workshop-head h3 {
  grid-column: 1 / span 7;
  margin: 0;
  font-size: clamp(2.2rem, 4.4vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
}

/* Espais d'imatge d'exemple: tons de la paleta i una etiqueta amb la foto que hi aniria */
.ph {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 8rem;
  color: rgb(238 231 220 / 0.82);
}

/* Construcció amb el scroll a la home (el sistema comú és a sistema.css):
   color de les paraules clau del mur i revelació de les imatges de la home */
.keyword.build-title {
  --ink: var(--mute);
}

.keyword.build-title.is-active {
  --ink: var(--hi);
}

/* Imatges del mur: la peça es revela de baix a dalt en entrar a la pantalla (la resta d'imatges,
   amb la regla comuna de sistema.css) */
.piece.is-building .ph {
  clip-path: inset(100% 0 0 0);
  translate: 0 28px;
  scale: 1.08;
  transition:
    clip-path 1.1s cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms),
    translate 1.1s cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms),
    scale 1.4s cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms);
}

.piece.is-building.is-shown .ph {
  clip-path: inset(0 0 0 0);
  translate: 0 0;
  scale: 1;
}

/* Al mur: el marc buit (plànol) i la línia de guia a la vora de la revelació */
.piece.is-building::before,
.piece.is-building::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.piece.is-building::before {
  inset: 0;
  z-index: 1;
  border: 1px solid color-mix(in srgb, var(--fg) 35%, transparent);
  transition: opacity 0.6s ease calc(var(--reveal-delay, 0ms) + 0.6s);
}

.piece.is-building.is-shown::before {
  opacity: 0;
}

.piece.is-building::after {
  top: 100%;
  right: 0;
  left: 0;
  z-index: 2;
  height: 1px;
  background: var(--hi);
  transition:
    top 1.1s cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms),
    opacity 0.4s ease calc(var(--reveal-delay, 0ms) + 0.8s);
}

/* La línia de guia puja amb la revelació i s'esvaeix en acabar */
.piece.is-building.is-shown::after {
  top: 0;
  opacity: 0;
}

/* ---------- (02) Taller: mur orgànic ----------
   Composició lliure (no una graella): cada peça té posició i amplada en % del contenidor,
   de manera que tot s'escala com un pòster. Paraules clau intercalades.
   En passar per una peça: s'apropa, apareix el peu, les altres s'apaguen i s'encén la seva paraula. */
.workshop-lead {
  grid-column: 9 / span 4;
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
}

.organic {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 100 / 118;
  margin: var(--space-block) var(--page-pad) 0;
}

.piece {
  position: absolute;
  margin: 0;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.piece .ph {
  height: auto;
  min-height: 0;
}

.piece-cap {
  position: absolute;
  top: calc(100% + 0.625rem);
  left: 0;
  max-width: 28ch;
  font-size: 0.875rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.keyword {
  position: absolute;
  margin: 0;
  color: var(--mute);
  font-size: 5.2cqi;
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
  transition: color 0.4s ease;
}

.organic.has-active .piece:not(.is-active) {
  opacity: 0.4;
}

.piece.is-active {
  z-index: 2;
  transform: scale(1.04);
}

.piece.is-active .piece-cap {
  opacity: 1;
  transform: none;
}

.keyword.is-active {
  color: var(--hi);
}

/* Profunditat: cada peça es desplaça a una velocitat diferent amb el scroll */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .piece {
      animation: drift linear both;
      animation-timeline: view();
      animation-range: cover;
    }
  }
}

@keyframes drift {
  from { translate: 0 var(--depth); }
  to { translate: 0 calc(-1 * var(--depth)); }
}

.piece--1 { left: 2%; top: 3.39%; width: 30%; --depth: 2.5rem; }
.piece--1 .ph { aspect-ratio: 4 / 5; }
.piece--2 { left: 38%; top: 0.00%; width: 22%; --depth: 4rem; }
.piece--2 .ph { aspect-ratio: 1 / 1; }
.piece--3 { left: 66%; top: 5.08%; width: 32%; --depth: 1.5rem; }
.piece--3 .ph { aspect-ratio: 3 / 2; }
.piece--4 { left: 40%; top: 27.97%; width: 26%; --depth: 3rem; }
.piece--4 .ph { aspect-ratio: 4 / 5; }
.piece--5 { left: 72%; top: 28.81%; width: 20%; --depth: 5rem; }
.piece--5 .ph { aspect-ratio: 4 / 5; }
.piece--6 { left: 4%; top: 47.46%; width: 28%; --depth: 2rem; }
.piece--6 .ph { aspect-ratio: 3 / 2; }
.piece--7 { left: 66%; top: 59.32%; width: 30%; --depth: 3.5rem; }
.piece--7 .ph { aspect-ratio: 1 / 1; }
.piece--8 { left: 36%; top: 60.17%; width: 24%; --depth: 1.5rem; }
.piece--8 .ph { aspect-ratio: 3 / 2; }
.piece--9 { left: 12%; top: 74.58%; width: 20%; --depth: 4rem; }
.piece--9 .ph { aspect-ratio: 4 / 5; }
.piece--10 { left: 40%; top: 78.81%; width: 22%; --depth: 2.5rem; }
.piece--10 .ph { aspect-ratio: 1 / 1; }

/* Enquadrament de cada foto dins de la seva peça */
.piece .ph img { object-fit: cover; }
.piece--1 img { object-position: 40% 50%; }
.piece--4 img { object-position: 40% 50%; }
.piece--5 img { object-position: 45% 50%; }
.piece--7 img { object-position: 45% 50%; }
.piece--9 img { object-position: 50% 50%; }

/* L'esquema (il·lustració sobre fons clar) necessita un marc per no confondre's amb la pàgina */
.piece--6 .ph { outline: 1px solid var(--line); outline-offset: -1px; }
.piece--10 img { object-position: 50% 60%; }
.keyword--1 { left: 38%; top: 21.19%; }
.keyword--2 { left: 4%; top: 38.14%; }
.keyword--3 { left: 68%; top: 51.69%; }
.keyword--4 { left: 66%; top: 88.14%; }
.keyword--5 { left: 4%; top: 66.10%; }

/* ============================================================
   (03) Disciplines: matriu disciplines × projectes
   ============================================================ */
.home-weave {
  padding: var(--space-section) 0;
}

.weave-head {
  align-items: end;
  row-gap: 1.5rem;
  margin: var(--space-head) 0 var(--space-block);
}

.weave-head h2 {
  grid-column: 1 / span 8;
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 6.2rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.weave-head p {
  grid-column: 9 / span 4;
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
}

.weave {
  position: relative;
  display: grid;
  grid-template-columns: minmax(11.25rem, 3fr) repeat(4, minmax(0, 2fr));
}

/* Les files només agrupen per a l'accessibilitat; la graella és la de .weave */
.weave-row {
  display: contents;
}

.wh {
  display: flex;
  align-items: flex-end;
  padding: 0 0 1.125rem;
  cursor: default;
  transition: color 0.3s ease;
}

.wh[data-weave-col] {
  justify-content: center;
  text-align: center;
}

.wl {
  display: flex;
  align-items: center;
  min-height: 4.5rem;
  padding-right: 1rem;
  color: var(--mute);
  font-size: 0.9375rem;
  cursor: default;
  transition: color 0.3s ease;
}

.wl.hot,
.wh.hot {
  color: var(--fg);
}

.wc {
  position: relative;
  min-height: 4.5rem;
}

.wc .h {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--line);
  transition: background 0.3s ease;
}

.wc .v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--line);
  transition: background 0.3s ease;
}

.wc.hr .h,
.wc.hc .v {
  background: var(--fg);
}

/* Punt de creuament: un rombe allargat (com un fil trenat) */
.wc .s {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 38px;
  margin: -19px 0 0 -4.5px;
  background: var(--acc);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transition: background 0.3s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.wc.hr .s,
.wc.hc .s {
  background: var(--hi);
  transform: scaleY(1.18);
}

.weave.dim .wc:not(.hr):not(.hc) .s {
  opacity: 0.35;
}

/* ---------- Teixit: cada projecte és un fil ----------
   home.js dibuixa els fils a .weave-threads a partir de la posició de les cel·les.
   Sense JS es veu la matriu (línies i rombes). */
.weave {
  /* Color del fil de cada projecte (tons de la paleta; el taronja queda per al ressaltat) */
  --thread-0: var(--sage);
  --thread-1: color-mix(in srgb, var(--teal) 50%, var(--cream));
  --thread-2: var(--cream);
  --thread-3: color-mix(in srgb, var(--orange) 35%, var(--cream));
  view-timeline-name: --weave;
}

.wh[data-weave-col="0"], .wc[data-weave-col="0"] { --thread: var(--thread-0); }
.wh[data-weave-col="1"], .wc[data-weave-col="1"] { --thread: var(--thread-1); }
.wh[data-weave-col="2"], .wc[data-weave-col="2"] { --thread: var(--thread-2); }
.wh[data-weave-col="3"], .wc[data-weave-col="3"] { --thread: var(--thread-3); }

.weave-threads {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.weave-threads path {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.85;
  transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease;
}

.weave-threads path.on {
  stroke: var(--hi);
  stroke-width: 2.5;
  opacity: 1;
}

.weave.dim .weave-threads path:not(.on) {
  opacity: 0.18;
}

/* Amb els fils dibuixats, les verticals rectes i els rombes prenen el color de cada fil */
.weave.has-threads .wc .v {
  display: none;
}

.weave.has-threads .wc .s {
  z-index: 1;
  background: var(--thread);
}

.weave.has-threads .wc.hr .s,
.weave.has-threads .wc.hc .s {
  background: var(--hi);
}

/* Els fils es dibuixen amb el scroll (si el navegador ho permet i no hi ha moviment reduït) */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .weave-threads path {
      stroke-dasharray: 1;
      animation: thread-draw linear both;
      animation-timeline: --weave;
      animation-range: entry 15% cover 55%;
    }
  }
}

@keyframes thread-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* Capçaleres com a botons: projecte (columna) i disciplina (fila) */
.weave-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
}

.weave-btn:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 4px;
}

.weave-swatch {
  inline-size: 1.25rem;
  block-size: 2px;
  background: var(--thread);
}

.wh.hot .weave-swatch {
  background: var(--hi);
}

.wl,
.wh {
  position: relative;
  z-index: 1;
}

.services {
  margin-top: var(--space-block);
  padding-top: clamp(2.5rem, 4vw, 3.5rem);
  border-top: 1px solid var(--line);
}

.services article {
  display: flex;
  flex-direction: column;
  grid-column: span 4;
  gap: 1rem;
  padding-right: 1.5rem;
}

.services h3 {
  margin: 0;
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.services p {
  max-width: 36ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
}

/* ============================================================
   (04) Procés: verbs interactius
   ============================================================ */
.home-process {
  padding: var(--space-section) 0;
}

/* Tres columnes que caben en una pantalla: verbs en vertical, esquema del cicle i detall del pas */
.process-layout {
  align-items: start;
  row-gap: 3rem;
  margin-top: var(--space-head);
}

.verbs {
  display: grid;
  grid-column: 1 / span 4;
  grid-template-columns: max-content;
  margin: 0;
  padding: 0;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  list-style: none;
}

.verb-row,
.verb-arrow {
  grid-column: 1;
}

.verb-arrow {
  padding: 0.15em 0 0.2em 0.08em;
  color: var(--mute);
  font-size: 0.5em;
  font-weight: 300;
  line-height: 1;
}

/* Imatge i text del pas actiu */
/* Esquema del cicle: els nodes també trien el pas */
.process-cycle {
  grid-column: 5 / span 3;
  align-self: start;
}

.cycle {
  display: block;
  width: 100%;
  max-width: 15rem;
  height: auto;
  margin-inline: auto;
  overflow: visible;
}

.cycle-arc,
.cycle-return,
.cycle-arrow {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.35;
  transition: opacity 0.4s ease, stroke 0.4s ease;
}

/* Arc que porta al pas actiu */
.cycle-arc.on {
  stroke: var(--hi);
  stroke-width: 1.8;
  opacity: 1;
}

.cycle-return,
.cycle-arrow--return {
  stroke: var(--hi);
  opacity: 0.9;
}

.cycle-return {
  stroke-dasharray: 3 4;
}

.cycle-return-label {
  fill: var(--hi);
  font: 500 8px/1 var(--font-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cycle-node {
  cursor: pointer;
}

.cycle-node circle {
  fill: var(--bg);
  stroke: var(--fg);
  stroke-width: 1.2;
  transition: fill 0.4s ease, stroke 0.4s ease, r 0.4s ease;
}

.cycle-node:hover circle {
  stroke: var(--hi);
}

.cycle-node text {
  fill: var(--fg);
  font: 500 11px/1 var(--font-text);
  letter-spacing: 0.04em;
  text-anchor: middle;
  transition: fill 0.4s ease;
}

.cycle-node.on circle {
  fill: var(--hi);
  stroke: var(--hi);
  r: 18;
}

.cycle-node.on text {
  fill: var(--navy);
}

.process-detail {
  display: grid;
  grid-column: 8 / span 5;
  gap: 1.5rem;
  padding-top: 0.5rem;
}

.verb {
  all: unset;
  position: relative;
  color: var(--mute);
  cursor: pointer;
  transition: color 0.35s ease;
}

.verb.on,
.verb:hover,
.verb:focus-visible {
  color: var(--fg);
}

.verb::after {
  position: absolute;
  right: 0;
  bottom: 0.04em;
  left: 0;
  height: 2px;
  background: var(--hi);
  content: "";
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.verb.on::after {
  transform: scaleX(1);
}

.verb:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 6px;
}

/* Imatge real de cada pas: es mostra la del pas actiu */
.process-figure {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
}

.process-media {
  aspect-ratio: 16 / 9;
}

.process-media img {
  position: absolute;
  inset: 0;
  transition: opacity 0.6s ease;
}

.process-media img.is-off {
  opacity: 0;
}

.process-text {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.process-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* display: flex anul·laria l'atribut hidden */
.process-panel[hidden] {
  display: none;
}

.process-desc {
  margin: 0;
  font-size: clamp(1.1rem, 1.4vw, 1.375rem);
  line-height: 1.45;
}

.process-out {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.process-aside {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
}

@keyframes swap {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.process-panel.swap {
  animation: swap 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ============================================================
   (05) Estudi: equip
   ============================================================ */
.home-team {
  padding: var(--space-section) 0;
}

.team-lead {
  max-width: 22ch;
  margin: var(--space-head) 0 var(--space-block);
  font-size: clamp(2rem, 3.6vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.idx--team {
  border-top: 1px solid var(--line);
}

.idx--team .nm {
  font-size: clamp(2rem, 4.4vw, 4.4rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.row-role {
  grid-column: 7 / span 2;
}

.row-text {
  grid-column: 9 / span 4;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.fol--team {
  width: clamp(13.75rem, 20vw, 20rem);
}

/* ============================================================
   (06) Contacte
   ============================================================ */
.home-write {
  padding: var(--space-section) 0 var(--space-block);
}

.write-block {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: var(--space-head);
}

.write-mail {
  align-self: flex-start;
  /* Mida perquè l'adreça hi càpiga sencera en una línia també al mòbil */
  font-size: clamp(1.25rem, 7vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.write-mail:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 6px;
}

.write-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.brief {
  row-gap: 1.75rem;
  margin-top: var(--space-block);
  padding-top: clamp(2rem, 3.5vw, 3rem);
  border-top: 1px solid var(--line);
}

.brief > p {
  grid-column: 1 / span 3;
  margin: 0;
}

.brief-item {
  display: flex;
  flex-direction: column;
  grid-column: span 3;
  gap: 0.5rem;
}

.brief-title {
  font-size: 1.0625rem;
  font-weight: 500;
}

.brief-text {
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* ============================================================
   Índexs sense imatge que segueix el cursor: pantalles estretes i dispositius
   sense ratolí (tauletes), on cada fila porta la seva imatge
   ============================================================ */
@media (max-width: 56.25rem), (hover: none) {
  .row {
    grid-template-columns: 2.75rem minmax(0, 1fr);
    row-gap: 0.5rem;
  }

  .row > * {
    grid-column: 2;
  }

  .row > .no {
    grid-row: 1;
    grid-column: 1;
  }

  .row > .nm,
  .row-info,
  .row-meta {
    grid-column: 2;
  }

  .row-meta {
    justify-content: flex-start;
  }

  .row .go-arr {
    display: none;
  }

  .rimg {
    display: block;
    grid-column: 1 / -1;
    aspect-ratio: 16 / 10;
    margin-top: 0.5rem;
  }

  .fol {
    display: none;
  }

  .rimg--portrait {
    aspect-ratio: 4 / 5;
  }
}

/* ============================================================
   Pantalles estretes (900 px a la referència)
   ============================================================ */
@media (max-width: 56.25rem) {

  .home-projects-foot a {
    justify-self: start;
  }

  .cycle {
    max-width: 10rem;
  }

  /* Taller: collage de dues columnes, amb peces desplaçades i paraules a tota l'amplada */
  .workshop-lead {
    grid-column: 1 / -1;
  }

  .organic {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5rem 1rem;
    align-items: start;
    aspect-ratio: auto;
  }

  .organic .piece,
  .organic .keyword {
    position: static;
    width: auto;
  }

  /* En mòbil, la peça inclou el peu: només es revela la imatge, sense marc ni línia de guia */
  .organic .piece {
    inset: auto;
  }

  .organic .piece.is-building::before,
  .organic .piece.is-building::after {
    display: none;
  }

  /* La segona peça de cada parella, una mica més avall */
  .organic .piece--2,
  .organic .piece--5,
  .organic .piece--8,
  .organic .piece--10 {
    margin-top: 2.5rem;
  }

  .organic .piece--3,
  .organic .piece--7 {
    grid-column: 1 / -1;
    width: 80%;
  }

  .organic .piece--7 {
    justify-self: end;
  }

  .organic .keyword {
    grid-column: 1 / -1;
    font-size: 2.6rem;
  }

  /* Paraules alternant esquerra i dreta, en l'ordre en què es veuen */
  .organic .keyword--2,
  .organic .keyword--5 {
    justify-self: end;
  }

  .piece-cap {
    position: static;
    margin-top: 0.5rem;
    opacity: 1;
    transform: none;
  }

  .piece--1 { order: 1; }
  .piece--2 { order: 2; }
  .keyword--1 { order: 3; }
  .piece--3 { order: 4; }
  .keyword--2 { order: 5; }
  .piece--4 { order: 6; }
  .piece--5 { order: 7; }
  .keyword--3 { order: 8; }
  .piece--6 { order: 9; }
  .piece--8 { order: 10; }
  .piece--7 { order: 11; }
  .keyword--5 { order: 12; }
  .piece--9 { order: 13; }
  .piece--10 { order: 14; }
  .keyword--4 { order: 15; }

  /* La matriu cap sencera: columna de disciplines més estreta i noms de projecte en vertical */
  .wbox {
    overflow-x: auto;
  }

  .weave {
    grid-template-columns: minmax(7.5rem, 1.4fr) repeat(4, minmax(0, 1fr));
  }

  .wl {
    font-size: 0.8125rem;
  }

  .wh[data-weave-col] {
    align-items: flex-end;
  }

  .wh[data-weave-col] .weave-btn {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
  }

  .cols3 {
    grid-template-columns: 1fr;
    row-gap: 2.5rem;
  }
}
